When I leave insert mode by pressing Esc, there is a half-second pause before Vim actually returns to normal mode.
Normally this wouldn’t be an issue, since pressing a normal mode command like j after pressing Esc executes the normal-mode command immediately (without the above-mentioned wait), but I have the mapping inoremap <Esc> <Esc>:w<CR>, so that every time I leave insert mode the file is written. I would like the write to occur immediately when I press Esc, but instead there is that half-second pause.
I’m assuming that the pause is because Vim is waiting for more input before it decides that I just meant to type a single, simple Esc. This must be because there is a mapping somewhere who’s first character is <Esc>, but I’ve looked in my .vimrc and there is no such mapping.
Furthermore, I even ran :map <Esc>, and it returned No such mapping. So, if there is no such mapping, why does Vim appear to be waiting for more input, and how can I avoid that behavior?
Extra Information
It appears that this is not reproduceable, so here is some more information in case anyone really wants to get to the bottom of this:
I am using Steve Francia’s spf13 distribution of Vim, with my own .vimrc.local on top of it. I have also installed several additional plugins using Vundle.
Notes: .vimrc.local is sourced last in .vimrc.
UPDATE (3/19/2014)
I found a far better solution than trying to hunt down all the mappings that start with
<Esc>, courtesy of Powerline, from the Tips & Tricks section of the docs. Put this somewhere in your.vimrc:Note that this will make it impossible to use mappings that start with
<Esc>while in insert mode, but there shouldn’t be any of those anyway, because of the problem this solves.I found the lines in spf13’s
.vimrcthat were causing the problem:The reason I couldn’t find them before is because they weren’t mapped using
<Esc>, but^[instead. Very irritating! Hope this helps some equally disgruntled spf13 user 🙂UPDATE:
If removing those mappings doesn’t work, then it’s probably a mapping from a plugin.
Type
:verbose map <Esc>to get a list of all mappings involving Esc. Theverbosepart instructs Vim to print where the mapping was set. That should help find out what’s causing the problem.Also, the command
unmap <Esc>might be useful—it removes any mappings for the Esc key.Note that
unmapdoes not remove mappings in all modes; type:h unmapfor more info.