escaping the "insert mode" of the zsh vi-mode when using tmux

Viewed 1058

I'm using zsh with its vi-mode and the plugin vi-mod. I choose to escape the insert mode with the combinaison of keys jk. At the begining, the time allowed to put k with the j was too short, I set export KEYTIMEOUT="30" in my .zsh to solve this.

Unfortunately, I met the same probleme with tmux: the delay to type k with j is too short.. I've seen in some forum the option set -s escape-time NUMBER but this doesn't seem to fit, I've still a too short delay with NUMBER=0 or NUMBER=500..

Any idea? Thanks for reading me!

(I work with debian buster, by the way)

2 Answers

I had a similar problem (I too use vi-mode), and I fixed it with bindkey.

If you run that command, it lists a lot of unusual binds that you may not expect. You might find one related to the keystrokes that you are using.

My issue/delay was search related, so the solution was to put this (removal) line in my .zshrc:

bindkey -r '\e/'

Indeed, when you set the KEYTIMEOUT too small such as KEYTIMEOUT=1, additional problems will be introduced, otherwise you need to continue to tolerate the key delay.

Although you can temporarily solve it by removing the prefix key, that is bindkey -r '\e/', you may also know that such a solution is not perfect.

But if you don't mind using a plugin, I think the below one can help you perfectly, also the additional bonus of better experience on vi mode and so on.

zsh-vi-mode: A better and friendly vi(vim) mode plugin for ZSH.
https://github.com/jeffreytse/zsh-vi-mode

This plugin has settled your concern down and has below features:

  • Better experience with the near-native vi(vim) mode.
  • ⌛ Lower delay and better response (Mode switching, widget calling).
  • ✏️ Mode indication with different cursor styles.
  • Cursor movement (Navigation).
  • Insert & Replace (Insert mode).
  • Text Objects (A word, inner word, etc.).
  • Searching history.
  • ❇️ Undo, Redo, Cut, Copy, Paste, and Delete.
  • Better surrounds functionality (Add, Replace, Delete, Move Around, and Highlight).
  • Switch keywords (Increase/Decrease Number, Boolean, Weekday, Month, etc.).
  • ...
Related