I like the -
and <C-M>
normal-mode keys for going to the first non-whitespace character of the previous/next line.
Are there coresponding keys for going to the last non-whitespace character on the previous/next line?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityg_
moves the cursor to the last non-blank character of the current line. From Vim's :help g_
:
g_ To the last non-blank character of the line and
[count - 1] lines downward |inclusive|. {not in Vi}
Unfortunately, I think the only options you have to move to the non-blank character of the previous/next line is kg_
or jg_
respectively or using a count to move downwards.
However, it is easy to map them to something easier:
nnoremap <F3> kg_
nnoremap <F4> jg_
2g_
will also work if you want to go to the last non whitespace character on the next line. However, this can't be used for the previous line. The advantage of 2g_
is that it can be repeated with .
May 17, 2015 at 13:27
g_
) are not repeatable with .
. Generally, only things that change the state of the buffer can be repeated.
If you mean the next non-whitespace character of the previous/next lines (by going vertically), then try:
map <C-k> :call search('\%' . virtcol('.') . 'v\S', 'bW')<CR>
map <C-j> :call search('\%' . virtcol('.') . 'v\S', 'wW')<CR>