I'm experiencing a weird problem with a normal mode mapping of Esc.
If you create the file escmapvimrc
with the contents:
set nocompatible
set showcmd " Doesn't affect the problem: just makes it easier to see
nnoremap <Esc> :noh<CR><esc>
And then start vim using this vimrc:
vim --noplugin -u escmapvimrc
Then vim will start in operator-pending mode with a c
command waiting for further input, displaying an empty file, and with the command-line displaying :noh
.
If you remove the nnoremap
line, then the problem goes away.
If you debug and step through everything you get the following output:
Entering Debug mode. Type "cont" to continue.
/[...]/escmapvimrc
line 1: set nocompatible
>s
/[...]/escmapvimrc
line 2: set showcmd " Doesn't affect the problem: just makes it easier to see
>s
/[...]/escmapvimrc
line 3: nnoremap <Esc> :noh<CR><esc>
>s
/[...]/escmapvimrc
line 4: End of sourced file
>s
Press ENTER or type command to continue
After you press enter, the Vim startup screen is displayed, and underneath:
Entering Debug mode. Type "cont" to continue.
cmd: noh
>s
The Vim startup screen then disappears, and you're in operator-pending mode, as described above.
What's going on?
EDIT: Behaviour is as described in Vim 7.3. In Vim 7.4.52, the nmap
causes Vim to start up in Replace mode when starting Vim without a file. (If Vim 7.4.52 is started with a file, however, it also starts up with a c-command underway.) Either way, the problem goes away when the nmap is removed.
:noh
for me. Doing the same with gvim did not show this behavior.nnoremap <c-l> :noh<cr><c-l>
/alksdjflaskj
to clear up search highlight which is quite fast as well.