iTranslated by AI
Level Up Your Vertical Navigation in Vim with 5j and 5k
Hello. I'm anozon, who realized in my 8th year of using Vim that I had been mixing up Visual Mode with Virtual Mode.
I'm proposing a Vim configuration that I've been using for about two years and has been working well for me.
nnoremap <C-j> 5j
nnoremap <C-k> 5k
vnoremap <C-j> 5j
vnoremap <C-k> 5k
Vim's Weakness
Vim possesses powerful capabilities for both horizontal and vertical movement. You can reach almost anywhere on the screen in just a few strokes.


(There are also <C-d> <C-f> <C-u> <C-b> movements.)
However, there is also a weakness. It's here.

Mapping to C-j, C-k
-7 `<C-k>` kk
-6 `<C-k>` k
-5 `<C-k>`
-4 `<C-k>` j
-3 kkk
-2 kk
-1 k
0 `<current>`
+1 j
+2 jj
+3 jjj
+4 `<C-j>` k
+5 `<C-j>`
+6 `<C-j>` j
+7 `<C-j>` jj
You can now access the 7 lines above and below in a maximum of 3 strokes.
Going Beyond
For these 5th lines above and below, you don't know the landing point until you've actually jumped.
I used set rnu for a while, but the eye movement felt awkward.
So, I created a plugin that always displays the landing points.
I have some sad news: it's not a Vim Script Plugin. Since I've been using VSCode (with VSCodeVim, of course) for a long time, what I've created is a VSCode Extension.
Discussion