diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index e3c22416b7..b0341c2e98 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -791,7 +791,8 @@ Tag Char Note Normal-mode action ~ |g@| g@{motion} call 'operatorfunc' |g~| g~{motion} 2 swap case for Nmove text |g| g 1 same as "gj" -|g| g 1 same as "g$" +|g| g 1 same as "g$" but go to the rightmost + non-blank character instead |g| g 1 same as "g0" |g| g same as g same as diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 3d4eef6f8e..c5d1e9c431 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -5353,7 +5353,7 @@ static void nv_g_dollar_cmd(cmdarg_T *cap) if (flag) { do { i = gchar_cursor(); - } while (ascii_iswhite(i) && oneleft() == OK); + } while (ascii_iswhite_or_nul(i) && oneleft() == OK); curwin->w_valid &= ~VALID_WCOL; } } diff --git a/test/old/testdir/test_normal.vim b/test/old/testdir/test_normal.vim index 0cc9925db2..5e15858ec3 100644 --- a/test/old/testdir/test_normal.vim +++ b/test/old/testdir/test_normal.vim @@ -4208,6 +4208,17 @@ func Test_normal33_g_cmd_nonblank() call assert_equal(20, col('.')) exe "normal 0g\" call assert_equal(11, col('.')) + + " Test visual mode at end of line + normal 0$bvg$y + call assert_equal(80, col("'>")) + exe "normal 0$bvg\y" + call assert_equal(71, col("'>")) + setlocal nowrap virtualedit=all + exe "normal 0$\llg\y" + call assert_equal(71, col("'<")) + exe "normal 0$llvg\y" + call assert_equal(71, col("'<")) bw! endfunc