1

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)

Eric Hu
  • 18,048
  • 9
  • 51
  • 67

1 Answers1

5

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.

kev
  • 155,172
  • 47
  • 273
  • 272
  • 1
    When built with the `+termresponse` feature, *Vim* sends a special control sequence (see `:set t_RV?`) to the terminal. When your terminal emulator see this sequence it responds with the sequence ESC `]>1;3201;0c`. The ESC is mapped to `:noh` and you get the rest of the sequence on the command line. With the OP’s mapping the rest of the sequence is taken as normal commands, thus the last `c` starts a change command. So, this ESC mapping is interfering with a query response that *xterm* (or whatever) is giving to *Vim*. – Chris Johnsen Feb 22 '13 at 10:50
  • @ChrisJohnsen Thanks for providing the final link. The explanation of the three numbers is given in `:h v:termresponse`. It's too bad I don't understand what termresponse is for even after reading the help files. – Eric Hu Feb 22 '13 at 22:48
  • I can't thank you enough for this answer. It led me to find a solution that solves this once and for all. For others, I've posted [the answer](http://stackoverflow.com/a/16027716/640517) on another question – Eric Hu Apr 17 '13 at 00:16