Why is vim starting in delete mode?

折月煮酒 提交于 2019-12-29 09:23:23

问题


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)


回答1:


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.



来源:https://stackoverflow.com/questions/15014923/why-is-vim-starting-in-delete-mode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!