Its all relative
Relative line numbers in Vim are fantastic but won’t work with wrapped lines if you remap j
and k
to gj
and gk
respectively… that is, unless you do this:
nnoremap <expr> j v:count ? 'j' : 'gj'
nnoremap <expr> k v:count ? 'k' : 'gk'
Thus allowing you to still jump by a count (that’s the v:count
check part) and also move up and down to the visual next line. I haz cake and I eats it.
Amazing.
- Jun 8, 2018 ( May 30, 2022)