In vim, if you set incsearch then it will scroll to the next match of your current search term without moving the cursor. I often use this to read a section of code without moving the cursor there, because I can then hit <ESC> and the screen will return back to wherever my cursor was when I started searching.
However, vim has a pause after you hit <ESC>, and before it scrolls back to the cursor. I find this pause very irritating. What is the purpose behind this pause, and/or is this pause configurable?
I’m assuming you’re running Vim in a terminal.
<Esc>is the beginning character of many terminal escape sequences, such as cursor movement or Alt/Meta + other keys. If you’ve defined some alt/meta key mappings somewhere in your config, Vim waits a bit after you hit Esc to make sure the<Esc>character isn’t the start of a longer sequence.You’ll probably want to check
:help 'timeout'and adjust settings accordingly. You can settimeoutlento a shorter duration if desired (ttimeoutlenis by default set to -1, so it isn’t used).EDIT: If you’re running Vim in tmux or GNU screen, this probably won’t be enough to prevent the pause. If using tmux, try adding
set -s escape-time 0to your .tmux.conf, as suggested by Vicent Marti here. If using GNU screen, you may have success with addingto your .screenrc, as suggested by brian_ruiz here.