Vim Surround + Repeat,用^ M包裹我的文字 [英] Vim Surround + Repeat, wraps my text with ^M

查看:100
本文介绍了Vim Surround + Repeat,用^ M包裹我的文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Vim的环绕和重复插件来用html标签包装文本行.

I'm using Vim's surround and repeat plugins to wrap lines of text with html tags.

我将使用"yse< p>"和"ys $< p>",它们都可以正常工作.

I'll use "yse<p>" and "ys$<p>", they both work fine.

我尝试用."重复命令,它显示< p>.在终端中,但是每当我按Enter键执行命令时,环绕声都会替换为< p>和</p>与^ M.

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.

我的台词看起来像是^ Mtext here ^ M

My line looks like ^Mtext here^M

我将字符识别为行尾,但是我不明白为什么Surround不会用终端中显示的代码来包裹我的行(这是正确的),而是用DOS行尾来包裹我的行.

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.

如果这有什么区别,我正在Windows XP上使用gVIM.

I'm using gVIM on windows XP, if that makes any difference.

推荐答案

实际上是因为当您用.

尝试以下操作:在用.重复命令之前,请先按o清空任何文本的命令行区域,然后按.

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.

要正确重复换行,您每次必须输入<p>或记录一个快速宏.

To repeat the wrapping properly, you'll either have to type in <p> every time or record a quick macro.

宏: ys$<p>

将其粘贴到vim中,突出显示它,然后键入"py

Paste that into vim, highlight it, and type "py

现在您可以使用@p

这篇关于Vim Surround + Repeat,用^ M包裹我的文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆