When I hit esc or Ctrl-[ in insert mode vim, it hangs for half a second before exiting insert mode. It's not a performance-rooted hang, as I can type any character and vim will exit insert mode immediately, but if I hit esc and nothing else then vim will wait for half a second.

I believe that this is because there is some other key binding for esc, and vim is waiting to see if I hit it. This suspicion is re-enforced by the fact that when I set notimeout, vim will wait indefinitely for me to press another key before existing insert mode. This is quite annoying, as sometimes I like to have notimeout set.

Does anyone know how to make esc act immediately? Is there some other key binding that starts with esc that I can turn off?

For what it's worth, :map <Esc> and :imap <Esc> yield No mapping found, and I can reproduce this on a fresh install of vim with no .vimrc or .vim present.

  • 1
    It may be because the escape character is part of a command sequence introducer Apr 23, 2012 at 21:51
  • That is likely. Is there a way to tell vim to ignore such command sequences?
    – So8res
    Apr 23, 2012 at 21:54
  • No, because then a lot of other keys won't work. Apr 23, 2012 at 21:55
  • The presence of <Esc> in such command sequences is not causing this problem. Vim handles the timing of <Esc> in those sequences differently than it handles <Esc> at the start of mappings. See ":help 'timeout'". Try executing ":imap <Esc>" to see if you have any insert-mode mappings beginnig with <Esc>.
    – garyjohn
    Apr 23, 2012 at 22:20
  • No mappings found. I'm pretty sure it's related to timeout because when I set notimeout the problem is far worse, but there appear to be no mappings. (I can reproduce it with a fresh install / no .vimrc / no .vim too, FWIW.)
    – So8res
    Apr 23, 2012 at 22:30

2 Answers 2


Several keys, including the arrow keys, send escape sequences. So in order for these keys to work, vim has to check for additional characters following ESC to determine whether one of these keys was pressed. By default the escape sequence timeout and mapped sequence timeout are both controlled by the timeoutlen setting, which defaults to 1000 ms. However vim allows the escape sequence timeout to be set independently using ttimeoutlen. (Also set ttimeout if you want it to take effect even when timeout is off.) Unless you like to type escape sequences manually or you are using a 110 baud modem then you should have no issues reducing the escape sequence timeout. For example use :set ttimeoutlen=100 to set the escape sequence timeout to 100 ms. You can also disable recognition of escape sequences when in insert mode using :set noesckeys.

  • For my vim configuration (I compiled my Vim from source) the ttimeoutlen was set to -1 which means it will use the 1000ms timeoutlen for everything. I set it to (a pretty aggressive) 5ms and now it is finally free from "sticky escape".
    – Steven Lu
    May 20, 2013 at 20:16

I had a similar problem where vim would hang indefinitely after hitting ESC. Indeed it was waiting for more characters - your answer was putting me on that train of thought!

It turned out that indeed it was an ESC-character problem but different; I was running vim inside tmux. I decided to check the "TERM" environment variable and it was set to 'screen'. Changing the TERM setting to 'xterm-color' (or whatever is appropriate for your system) made the hanging vim problem disappear.

Not sure that it is applicable to your situation but given that googling for this problem turned up mark4o's answer in the top search results decided to add this potential situation too for others.

  • thx for the edit Journeyman!
    – emvee
    May 26, 2014 at 14:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .