vim Tips and tricks to boost productivity Mappings for exiting Insert mode


A lot of Vim users find the Esc too hard to reach, and end up finding another mapping that's easy to reach from the home row. Note that Ctrl-[ may be equivalent to Esc on an English keyboard, and is much easier to reach.


inoremap jk <ESC> 

This one is really easy to trigger; just smash your first two fingers on the home row at the same time. It's also hard to trigger accidentally since "jk" never appears in any English word, and if you're in normal mode it doesn't do anything. If you don't type "blackjack" too much, then consider also adding inoremap kj <ESC> so you don't need to worry about timing of the two keys.

Caps Lock


On Linux, you can use xmodmap to make Caps Lock do the same thing as Esc. Put this in a file:

!! No clear Lock 
clear lock
!! make caps lock an escape key
keycode 0x42 = Escape

Then run xmodmap file. This remaps Caps Lock to Esc.


On Windows you can use SharpKey or AutoHotkey.


If you have macOS 10.12.1 or later, you can remap Caps Lock to Escape using System Preferences. Select Keyboard, go to the Keyboard tab, and click Modifier Keys.

Keyboard Preferences