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

How do I make mappings feel snappier without breaking key-code timing?

Answer

:set timeout timeoutlen=400 ttimeoutlen=30

Explanation

If custom mappings feel laggy, the issue is often timeout tuning rather than mapping design. Vim waits for possible key-sequence continuations, and the defaults can feel slow when you use many leader mappings. Splitting timeoutlen from ttimeoutlen lets you keep reliable multi-key mappings while making terminal key-code handling feel immediate.

How it works

  • timeout enables timeout logic for mapped key sequences
  • timeoutlen=400 sets mapping wait time to 400ms, which is responsive without being too aggressive for leader combos
  • ttimeoutlen=30 shortens terminal key-code timeout, reducing delay after keys like <Esc> in terminal environments

Example

Before tuning, pressing <leader>f may feel sticky when your leader is followed by many mapped alternatives, and exiting insert mode in a terminal can pause briefly.

Symptom: short delay after pressing mapped prefixes
Cause: long global timeout values

After applying the setting:

Mappings: still resolved correctly
Terminal keycodes: noticeably more responsive

Tips

  • If 400ms is too short for your typing speed, raise timeoutlen gradually (for example, 500 or 600).
  • Keep ttimeoutlen low in terminal Vim; GUI clients often do not need the same tuning.
  • Put this in your config so behavior is consistent across sessions.

Next

How do I remove trailing spaces only within the currently selected visual block?