开发者

Why does the vim key map "map! " ""<ESC>ha" cause strange behaviour?

I'm trying to create a set of simple key maps in my vimrc, and wrote the following in my vimrc:

map! " ""ha

the above key map works 开发者_如何转开发in insert mode and when you type " vim would simply type in another " and then place the cursor in between both quotation marks.

However the strangest thing happens, it seems as though vim can't stop producing double qutation marks and continues, it only stops when once presses <CTRL-C>.

Is this a bug on my part, or is this a vim bug?


This isn't a bug. The problem is that your map is recursing. The solution is to use noremap!, which doesn't allow maps in the rhs:

noremap! " ""ha

Personally I tend to use the noremap commands unless I know I need maps in the rhs to be expanded.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜