vimtricks.wiki Concise Vim tricks, one at a time.

How do I speed up mappings without breaking terminal keycode sequences in Vim?

Answer

:set timeoutlen=300 ttimeoutlen=10

Explanation

If key mappings feel laggy, many users reduce timeoutlen and stop there. The better approach is to tune timeoutlen and ttimeoutlen together so mapped sequences resolve quickly while terminal escape-code sequences still decode correctly. This is a high-impact ergonomics setting when you use <leader> maps and terminal Vim all day.

How it works

  • timeoutlen controls how long Vim waits for mapped key sequences (for example after pressing <leader>)
  • ttimeoutlen controls how long Vim waits for terminal key codes (arrow keys, modified keys, function keys)
  • :set timeoutlen=300 ttimeoutlen=10 makes mappings snappy while keeping terminal code parsing strict and fast
  • Keeping ttimeoutlen very low helps avoid visible delays after pressing <Esc> in terminal environments

Example

Apply the settings in a session:

:set timeoutlen=300 ttimeoutlen=10

Then compare behavior:

Before: noticeable pause after <leader> or <Esc>
After:  faster mapping resolution and cleaner mode transitions

Tips

  • If some terminal key chords stop working, increase ttimeoutlen gradually (for example 20 or 30).
  • For remote sessions with latency, use a slightly higher timeoutlen (for example 400-500) to avoid accidental mapping misses.

Next

How do I jump to a literal search target without adding jump-list noise?