Vim Tip: Remapping `jj` to Escape
Eric Van Johnson • May 13, 2017
The Escape key is probably one of the more important keys for a Vim user. Whenever in insert mode, the Escape key kicks you back to normal mode. But here's the thing, the Escape key is soooooo far away.
Alright, it's not that bad, but when you are typing away, breaking away from the home row isn't optimal. I have a small mapping in my .vimrc file where, while in
insert mode if I hit
jj it will take me back to
Edit your .vimrc file
Add the following entry
note: you can see I have a similar mapping for kk but I honestly rarely use it
Save it and that’s it :wq
Relaunch Vim and you should now be able to hit jj while in insert mode
One thing to remember with this shortcut, if you make use of recording macros when with your Vim, the jj shortcut will not work in the recording. You have to remember to actually hit the Escape key.