Avoiding the ESC key in Vim (and Readline)


It’s probably safe to say that I should’ve changed this (ugh) habit years ago, but I just never got around to it. Thanks to Stephen, I’ve finally updated my .vimrc to exit insert mode using:

inoremap jk <ESC>

Yay!

More importantly, if you tend to set vi editing mode in readline, you definitely want to change its bindings as well. I found this gem hidden deep in the Vim Tips Wiki.

All you have to do is edit your .inputrc file with the following:

set editing-mode vi
set keymap vi

$if mode=vi
    set keymap vi-command
    "ii": vi-insertion-mode
    set keymap vi-insert
    "jk": vi-movement-mode
$endif

As a note: Readline will also pick these settings up for every readline enabled app (IPython, etc)

Happy Vimming! :D