Switching to and from insert mode in Vim is no longer instantaneous since I use tmux. After pressing Esc in insert mode, it takes a noticeable amount of time to actually get out of insert mode. After pressing Esc and any other key afterwards the switch is immediate, and the command for the key pressed after Esc is executed. Any idea what might cause this?

The Vim configuration is not the problem as the delay does not occur when I run Vim outside tmux, so this is probably related to tmux somehow. I use gnome-terminal btw.

Also worth noting, it seems I can not define key bindings in tmux for Esc, my plan was to bind Esc to:

bind Escape send-keys ^[

Alas, it seems binding anything to Esc for tmux does not work. The same problem occurs in screen as well.

4 Answers 4


After plowing through the man pages it turns out tmux has an option for this. The following in ~/.tmux.conf fixes the delay problem:

 set -sg escape-time 0

You have to restart your tmux server or reload your config for this to take effect. To do this, issue source-file ~/.tmux.conf from the tmux prompt.

  • 3
    Where did you find this? I can't find escape-time anywhere in man tmux, and the command doesn't work for me.
    – djeikyb
    Apr 5, 2011 at 15:41
  • 1
    I suspect is is only available in the development version. You can get it here: github.com/ThomasAdam/tmux Apr 5, 2011 at 16:15
  • 7
    I had to use tmux kill-server before this setting worked for me. Thanks!
    – Sam
    Sep 8, 2013 at 15:46
  • 2
    This makes me wish I could give you 10 upvotes. Found this after an hour of battling timeouts in vim. Thank you!
    – malvim
    Jul 11, 2014 at 14:30
  • 2
    @MichaelBrown, I do as well, and still hit this problem. It should not matter actually, because the same key code is sent to the terminal emulator regardless of whether you press escape or ^[. Aug 29, 2019 at 9:17

I had a different but similar issue that I was trying to solve when I found this page, so I'll post that here in case it's helpful to anyone else who is in search of this answer and finds this page in the same way.

Problem: vi mode in bash has a delay when switching from insert mode to command mode

Solution: In your ~/.inputrc file, add set keyseq-timeout n where n is some low value greater than 0. n defaults to 500ms, which is what causes the delay. See documentation here.

Also, if you want to be able to tell which mode you're in, check out Dylan Cali's fork of bash.

  • that is very helpful, i set it to 0.01 and now its pleasingly much more faster. thanks!
    – user373230
    May 17, 2017 at 7:28
  • It could also be appended into /etc/inputrc to make it available for all users.
    – user373230
    May 17, 2017 at 8:27
  • 1
    zsh has an additional delay setting: KEYTIMEOUT -- johnhawthorn.com/2012/09/vi-escape-delays May 21, 2020 at 21:11

As the title mentions Screen, here is the solution to fix the behaviour of Escape key within GNU Screen. (Taken from here.)


maptimeout 5

to .screenrc config file.


It sounds like you are using a mapping that starts with ESC. When you press the ESC, vim has to wait to see if the next key is the one in the mapping. If it is not, it can immediately continue.

The vim configuration can be terminal dependent, so the fact that it does not happen outside of tmux does not mean much. Vim can query the $TERM environment variable and choose different configuration depending on its value.

Since gnome-terminal uses, AFAIK, xterm as the value of the $TERM variable, and tmux uses screen, I would look through all your vim configuration files for settings that are only used is the $TERM variable is equal to screen. My guess is that some vim config file on your system sets mappings for handling of arrow keys (those start with the ESC character) when the terminal is screen.

You can test it by temporarily changing the $TERM variable in tmux before starting vim. If your shell is bash, call vim as

TERM=xterm vim

in tmux and see if the problem persists. You sould not use that as a fix, though, since there may be differences between the terminal capabilities of tmux and xterm, and you may run into some problems.

  • Some good pointers here. I do use bash, but unfortunately TERM=xterm vim did not fix the problem. I'll have to dig a little deeper. Mar 2, 2011 at 21:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.