If I press ESC to exit Visual Mode after I select some text, there's a noticeable delay before the text gets unselected and I'm returned to Normal Mode (even if I only select 1-2 characters). Can this delay be avoided?
3 Answers
This can be caused by being mapped to some additional functionality. For example, I use the tabbar plugin and it maps 0-9 to switch to the number buffer. Whenever a key is mapped to additional functionality like this, vim waits a few seconds after it is pressed to see if you're going to press any additional keys.
To see if has any additional mappings, run :map and look for <Esc> in the first column. When ran without any parameters, :map will list all the custom mappings. If you want to list only the mappings while in visual mode, run :vmap.
If does have additional mappings, I do not know of a way to remove the pause, besides removing the mappings. The pause is necessary for vim to unambiguously know what action you intend it to take.
- 179
- 1
- 6
I have no mapping bound to <ESC> globally or for Visual mode (calling :verbose vmap <ESC> gives no results) but there is still a significant delay when exiting Visual mode. Even on fresh installs with no vimrc the delay is present. Using <C-c> does exit visual mode without delay.
Since I don't like pressing <C-c> to exit any mode, I currently map <ESC> to <C-c> in visual mode. This exits visual mode using <ESC> without any delay.
:vmap <ESC> <C-c>
Or put the following line in your vimrc
vnoremap <ESC> <C-c>
This will not work if you do have global or visual mode mappings bound to <ESC>.
- 111
What you can do still, is using CTRL+C to exit Visual mode, That should avoid the delay.
- 4,324
- 101