# HG changeset patch # User Christian Brabandt # Date 1692549006 -7200 # Node ID 2ad6e8515a78859f1c2bb51eff54c94bbf5aa81b # Parent ca488d831c3cbc9159bc9ed3e72c40e72a8620b9 patch 9.0.1761: g behaves different from g Commit: https://github.com/vim/vim/commit/654bdbbd329e7267051cc2eb496bc52b66053081 Author: zeertzjq Date: Sun Aug 20 18:24:20 2023 +0200 patch 9.0.1761: g behaves different from g Problem: g behaves different from g Solution: Make g behave like g closes: #12861 Signed-off-by: Christian Brabandt Co-authored-by: zeertzjq diff --git a/runtime/doc/motion.txt b/runtime/doc/motion.txt --- a/runtime/doc/motion.txt +++ b/runtime/doc/motion.txt @@ -255,7 +255,8 @@ g$ When lines wrap ('wrap' on): To the instead of going to the end of the line. When 'virtualedit' is enabled moves to the end of the screen line. - *g* + + *g* *g* g Like |g$| but to the last non-blank character instead of the last character. diff --git a/src/normal.c b/src/normal.c --- a/src/normal.c +++ b/src/normal.c @@ -5823,7 +5823,7 @@ nv_g_dollar_cmd(cmdarg_T *cap) int col_off = curwin_col_off(); int flag = FALSE; - if (cap->nchar == K_END) + if (cap->nchar == K_END || cap->nchar == K_KEND) flag = TRUE; oap->motion_type = MCHAR; diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim --- a/src/testdir/test_normal.vim +++ b/src/testdir/test_normal.vim @@ -4105,20 +4105,24 @@ func Test_normal_click_on_double_width_c endfunc func Test_normal33_g_cmd_nonblank() - " Test that g$ goes to the last non-blank char and g to the last + " Test that g goes to the last non-blank char and g$ to the last " visible column 20vnew setlocal nowrap nonumber signcolumn=no call setline(1, ['fooo fooo fooo fooo fooo fooo fooo fooo ']) - exe "normal 0g\" + exe "normal 0g\" call assert_equal(11, col('.')) normal 0g$ call assert_equal(20, col('.')) + exe "normal 0g\" + call assert_equal(11, col('.')) setlocal wrap - exe "normal 0g\" + exe "normal 0g\" call assert_equal(11, col('.')) normal 0g$ call assert_equal(20, col('.')) + exe "normal 0g\" + call assert_equal(11, col('.')) bw! endfunc diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1761, +/**/ 1760, /**/ 1759,