vim

What is wrong with this mapping? Vim starts in -- REPLACE -- mode


I am having a weird bug in my .vimrc since I last updated it.

Every time I start vim it starts in -- REPLACE -- mode which is really annoying.

I managed to find out that it is this line in my .vimrc that is causing the problem.

" Disable search highlighting temporally
nnoremap <esc> :nohl<cr>

The problem goes away when I comment this line out.

I am really confused about what is wrong with the mapping. It works as it should but causes vim to enter -- REPLACE -- mode on startup.

I currently have no plugins enabled at all.


Solution

  • It is better to avoid mapping the Esc key, as it is known to cause strange behavior:

    I have been using <leader><space> for disabling the highlighting, as suggested by "Coming Home to Vim", maybe you could get used to it too.