Last Updated: May 31, 2021
·
5.79K
· saml

Navigate 4x faster with standard navigation keys in vim, by holding Ctrl

When watching demo videos on YouTube, I have realized how even some of the most seasoned developers are cracking their keyboards while navigating around in their code in vim, just to get to the right part.

Obviously many are not using the "smart" navigation keys like w for jumping forward one word, often enough, and there is a need for a simpler solution.

My suggestion is to simply be able to increase the navigation speed of the normal navigation keys (h,j,k,l), by simply holding down Shift or Ctrl, to increase the speed 4 x respectively. I find it to work great, and save my hands and wrists a lot of strain!

To acvitave it, add these lines to your ~/.vimrc file:

" Navigate 4x faster when holding down Ctrl
nmap <c-j> 4j
nmap <c-k> 4k
nmap <c-h> 4h
nmap <c-l> 4l

8 Responses
Add your response

I think this is bad idea, check https://github.com/Lokaltog/vim-easymotion
Also check basic vim navigation:
Ctrl - u half screen up
Ctrl - d half screen down
Ctrl - f screen up
Ctrl - b screen down

2h and 2l - total bizarre you should learn vim text objects and jump by word, sentence, paragraph etc...

over 1 year ago ·

a-b: I have learnt them, and I use them. Still, I find this to be a complement that I use all the time.

I use the Ctrl+u/d keys a lot as well, but that doesn't have the same behavior, since it does not clearly show where the marker is in the code. It works well when just reading text/code, but when you want to quickly go to a specific point in a code for doing an insertion, moving the marker directly just works much better.

over 1 year ago ·

There are always tons of clever ways to do things, but for a lot of us out here, it is sometimes only the simple ones that are simple enough to stick.

As said in the beginning of the main post, figuring this out was motivated in the first place by seeing even seasoned vim:ers hacking their keyboards into pieces (to my mental frustration to death) by moving around one line/character at a time.

I last saw this in a YouTube video from a conference talk demonstrating the power of vim!

Do you start to see my point? Obviously there is some snag here, making even these vim experts neglect some of the most basic commands.

Some times something really simple is what is needed.

over 1 year ago ·

I think you both are correct, since VIM is a tool to be created to be customisable to each person's specific need.

over 1 year ago ·

I don't want to waste my ctrl and hjlk keys to just move updown.

over 1 year ago ·

You should mention the default behavior of these mappings so people know what they will lose (or have to remap).

  • Shift + j: join lines
  • Shift + k: help
  • Shift + h: jump to top of screen
  • Shift + l: jump to bottom of screen

Also, I find it more useful to map Ctrl + j/k/h/l to moving around split panes, which I spend a lot of time doing.

over 1 year ago ·

@saml hey there buddy, why not use { for up, and it show your where is your cursor, and } for down?

over 1 year ago ·