问题
I'm using Vim's surround and repeat plugins to wrap lines of text with html tags.
I'll use "yse<p>" and "ys$<p>", they both work fine.
I try to repeat the command with ".", and it shows <p> in the terminal, but whenever I press enter to execute the command, surround replaces what should be <p> and </p> with ^M.
My line looks like ^Mtext here^M
I recognize the character as a line ending, but I don't understand why surround won't wrap my line with the code it shows in the terminal (which is correct), but instead wraps my line with DOS line endings.
I'm using gVIM on windows XP, if that makes any difference.
回答1:
It's actually because <p>
isn't really there when you repeat the command with .
Try this: Before you repeat the command with .
first hit o
to empty the command line area of any text, then hit .
You'll see that it is actually blank, which is why the cursor is on the first character.
To repeat the wrapping properly, you'll either have to type in <p>
every time or record a quick macro.
Macro: ys$<p>
Paste that into vim, highlight it, and type "py
Now you can run the macro with @p
回答2:
surround.vim
's documentation says:
The "." command will work with ds, cs, and yss if you install repeat.vim, vimscript #2136.
So if you are using yss
it should work, but apparently other versions of "ys
" aren't supported. Sounds like a good feature require to submit to the repeat.vim
owner.
来源:https://stackoverflow.com/questions/4629090/vim-surround-repeat-wraps-my-text-with-m