# 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](https://twitter.com/#!/stephenliu), I've finally updated my [.vimrc](https://github.com/ryankanno/vim-config) 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](http://vim.wikia.com/wiki/Avoid_the_escape_key) hidden deep in the [Vim Tips Wiki](http://vim.wikia.com/wiki/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

