68
17
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.
1This makes me wish I could give you 10 upvotes. Found this after an hour of battling timeouts in vim. Thank you! – malvim – 2014-07-11T14:30:01.063
This doesn't work for me. I even killed the server and restarted, but the delay in vim is still there. I'm using tmux 1.9-6 (in debian testing). – FrontierPsycho – 2014-12-10T14:51:08.493
It might be vim's own timeoutlen option. Reducing that from the default 1000 to 100 improved things a lot. – FrontierPsycho – 2014-12-10T15:03:15.063
@MarkZar, which version of tmux are you using? – Ton van den Heuvel – 2015-12-01T16:00:45.790
@TonvandenHeuvel It worked after I rebooted my PC, I don't know why it needs a restart, but any way it works. Now working with vim in tmux is like a joyful journey, thanks! – Searene – 2015-12-02T07:01:21.303
@Searene That is probably because you had the tmux daemon running, it needs to be restarted for any settings changes to take effect. – Ton van den Heuvel – 2016-01-29T20:29:47.673
@TonvandenHeuvel You changed my life!!! Thank you!!! – PiersyP – 2016-02-12T13:28:28.053
thanks! I never realised this could be fixed and it was driving me crazy, this is fantastic!! – the_velour_fog – 2016-02-15T05:10:28.637
This setting works with the vim plugin airline (or other plugins), but at first may look like it hasn't worked. I set this and killed the tmux server, and tested it. airline still takes about half a second to update the screen from showing
INSERT
toNORMAL
, so I thought it wasn't working and went down a rabbit hole. After actually trying commands during that split second where it still showedINSERT
, I realized this setting worked, and I was actually in command mode. – user1902689 – 2018-11-12T03:16:35.840... To fix the apparent delay from plugins I mentioned, consider in
– user1902689 – 2018-11-12T03:23:46.883vimrc
set ttimeoutlen=0
or maybe=10
. See https://stackoverflow.com/questions/15550100/exit-visual-mode-without-delay/15550436#15550436Funny, I never encountered this problem because I don't use esc in vim, I use ^[ always. It's a quicker movement than reaching for the esc key. – Michael Brown – 2019-08-28T16:29:36.793
1@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 ^[. – Ton van den Heuvel – 2019-08-29T09:17:48.317
2Where did you find this? I can't find escape-time anywhere in
man tmux
, and the command doesn't work for me. – djeikyb – 2011-04-05T15:41:48.793I suspect is is only available in the development version. You can get it here: https://github.com/ThomasAdam/tmux
– Ton van den Heuvel – 2011-04-05T16:15:27.857I love everything about you for this answer. This just solved an obscure emacs problem for me and now I can go to bed finally! – Bo Jeanes – 2012-08-19T05:13:25.823
5I had to use tmux kill-server before this setting worked for me. Thanks! – Sam – 2013-09-08T15:46:22.010