Updated:
Published:

Escape key alternatives in VIM

Summary

  • Ctrl-[ is the same as the escape key in VIM
  • Ctrl-c is another alternative to the escape key but will not expand abbreviations or trigger the InsertLeave event
  • You can create your own custom mapping for the escape key (e.g. :inoremap jj <Esc>)

The Details

I have been using VIM for almost two years now and one thing that has always bothered me has been the escape key. According to the VIM Tips Wiki:

The Vi editor was originally written on an ADM-3A terminal, which had the Escape key positioned where the Tab key occurs on most modern keyboards.

Well, I guess it would be a good idea to use something other than the escape key to return to normal mode. Luckily, Ctrl-[ does the exact same thing as the escape key in VIM. Although it does require you to use two fingers, I have felt that it doesn't cause as much of a disturbance to your VIM workflow as the escape key does.

Another alternative would be Ctrl-c, which lets you return to normal mode. One of the things that I like most about Ctrl-c is that it doesn't show any lag in returning to normal mode like Ctrl-[ and the escape key do. The downsides to using Ctrl-c is that it does not expand any abbreviations or trigger the InsertLeave event, so it could cause some issues with plugins or with your .vimrc config.

Of course, you can always create your own custom mapping (e.g. :inoremap jj <Esc>) for the escape key if you don't like any of the alternatives. I am probably going to play around with the alternatives and see which one I like most for a bit longer though.

Edit: Updated :imap jj <Esc> to :inoremap jj <Esc>. Thanks to bilalq's comment on HN.