Eric Hu
Eric Hu

Reputation: 18218

Why is vim starting in delete mode?

As stated in the question, my vim starts out in delete mode. If I open a file and hit j to start navigating, that'll delete the first line.

I've isolated the problem down to this line in my .vimrc:

nnoremap <silent> <esc> :noh<return><esc>

I don't understand why this would even trigger delete mode. On top of that, I believe I added <silent> to instruct vim to make this binding without executing it, which doesn't seem to be the case.

What's the explanation for why this is happening?

(side note, this mapping is to tell vim to clear search highlights when I hit esc)

Upvotes: 2

Views: 1045

Answers (1)

kev
kev

Reputation: 161914

If you run this command in terminal:

$ vim file.txt -c 'nnoremap <silent> <esc> :noh'

It'll show this at the bottom:

:noh[>1;3201;0c

vim enters change-mode somehow.


You can change <esc> to <F5>(or other keys). If you use gvim, there's no problem. It's caused by terminal special key escaping.

Upvotes: 6

Related Questions