0

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?

chutsu
  • 13,612
  • 19
  • 65
  • 86
  • fow answered your "bug" question. Still, I'd advice you against using the banged (!) version of the mapping (as it won't work at all in COMMAND-mode). And on that balanced-pairs topic, I suggest you have a look at http://stackoverflow.com/questions/4521818/getting-automatic-matching-brace-in-vim – Luc Hermitte Jan 12 '11 at 10:13

1 Answers1

6

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.

fow
  • 556
  • 3
  • 6