Search code examples
neovim

Neovim how to exit insert mode without any delay


I've just started a new neovim configuration based on kickstart.nvim.

When I'm working I often want to quickly switch out of insert mode to do something in normal mode in one fluid motion. However, when I press the Escape key there is about a half-second delay where I'm still in insert mode.

It kind of feels like neovim is waiting to see if I have other keystrokes to chain after that initial Escape. Is there a way to remove this delay and have Escape instantly register, or some other way to instantly switch from Insert to Normal mode?


Solution

  • The time span of switching out depends on a variable named ttimeoutlen and the Wait time for a mapped sequence to complete depends on timeoutlen. Both are global variables, To decrease the time of switching out from insert mode you can add these lines in your nvim config file,

    lua

    vim.opt.ttimeoutlen = 50 --in milliseconds
    

    vim

    :set ttimeoutlen=50 " in milliseconds
    

    Consider seeing :h ttimeoutlen & :h timeoutlen

    Additionally, if you're using tmux then you can add this line in your .tmux.conf

    set -g escape-time 0