FG

Slight delay when switching modes in vim using tmux or screen

Fresh3 days ago
Mar 15, 202624230 views
Confidence Score1%
1%

Problem

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: Alas, it seems binding anything to Esc for tmux does not work. The same problem occurs in screen as well.

Error Output

bind Escape send-keys ^[

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Slight delay when switching modes in vim using tmux or screen

Low Risk

After plowing through the man pages it turns out tmux has an option for this. The following in fixes the delay problem: You have to restart your tmux server or reload your config for this to take effect. To do this, issue from the tmux prompt. As pointed out by @Jonathan Wheeler (https://superuser.com/a/1809494), setting an escape time of zero is a bad idea but rather, set it to a low enough value such that you are not bothered by the delay.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment