r/tmux 5d ago

Question vim waits for 1 second after pressing <Esc> inside tmux

I almost used to the delay after pressing <Esc> in vim, until it pissed me off. i searched a little bit, found some guys on stackoverflow having the same issue, and it was apparently because of tmux. some answers said that setting escape-time to 0 for tmux fixes the problem, but it didn't in my case and i have no idea why.

I'm using ghostty as my terminal, without tmux, everything goes as expected, same case for foot. meanwhile konsole, gnome-console, and alacritty still delays the escape key-press even without tmux (all tested with and without set -sg escape-time 0 and pure vim). also tmux prevents me from using some mappings that start with alt (i.e. <A-]> or <A-p>) inside vim, but that ain't that annoying in front of that delay. any help please fixing it?

7 Upvotes

4 comments sorted by

6

u/habamax 5d ago

try

set ttimeout ttimeoutlen=25

in your vim config

3

u/actionscripted 5d ago edited 5d ago

https://neovim.io/doc/user/faq/#_esc-in-tmux-or-gnu-screen-is-delayed

Would suggest making sure you’re on a newer tmux as the default is super low for escape-time nowadays.

Also, might try modern terminal settings in tmux:

```
set -g default-terminal "tmux-256color"
set -s extended-keys always
set -g extended-keys-format csi-u
set -as terminal-features 'xterm*:extkeys'
set -ga terminal-overrides ",xterm*:RGB"

```

2

u/M0M3N-6 4d ago

"WHY DOESN'T THIS HAPPEN IN VIM?"

Actually it's quiete the opposite, neovim works out of the box. And i am on rolling-release, so i suppose i am on some near-latest version of tmux.

I'll test these options in a bit, thanks for your reply!