Vim Tip: Remapping `jj` to Escape
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
Add the following entry
imap jj <Esc>
note: you can see I have a similar mapping for
kk but I honestly rarely use it
Save it and that’s it
Relaunch Vim and you should now be able to hit
jj while in insert mode
One this 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.
I’ve manage to duplicate this behavior while using various Vim Plugins in other tools.
~/.ideavimrc and add
imap jj <Esc>
Honestly, I think I had this working in Sublime with the Vintage plugin however I don’t use Sublime anymore and when I tried to launch it, Sublime just stops responding and I honestly don’t care enough about Sublime to worry about getting it working again. If I do happen to get it working in the future I will try to remember to check and update this post what the mapping looked like.
Have not gotten this working in Atom yet using the vim-mode. If you find a solution, tweet it at me (@shocm)