在 VIM 中使用 VISUAL MODE 替换 HTML 标签

发布于 2025-01-17 21:53:53 字数 363 浏览 2 评论 0原文

所以我可以替换“<” -VIM 中的方括号使用 ":s/

如何替换 VISUAL MODE 中标记的所有方括号?假设我想将所有标记的括号 " 替换

为屏幕截图中的 "&lt",因此它将在 HTML 中显示为代码 在此处输入图像描述我只想替换它们,而不是其他的,你知道什么是 抱歉初学者的问题

,但我很想知道。

so I can replace "<" -square brackets in VIM using ":s/</</g" and thats great, but It does not replace the ending bracket, thats problem number one. But the main issue is:

How do I replace all square brackets marked in VISUAL MODE? Say I want to replace all marked brackets "

just as on the screenshot with "<", so It will be displayed in HTML as codeenter image description here. I want to replace only them, not the others, do you know what is the pattern?

Sorry for beginners question, but I would like to know.

Thank you so much

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

网白 2025-01-24 21:53:53
  1. 这些是尖括号,而不是“方括号”。
  2. :s/ 没有任何用处。您的意思是 :s/ 吗?
  3. 您已经知道如何更改左括号,因此您只需对右括号执行相同的操作,但使用适当的模式和替换。
  1. Those are angle brackets, not "square brackets".
  2. :s/</</g does nothing useful. Did you mean :s/</\</g?
  3. You already know how to change the opening bracket so you only need to do the same thing for the closing bracket but with the appropriate pattern and replacement.
别在捏我脸啦 2025-01-24 21:53:53

如果我正确解释了您的问题和屏幕截图,您希望用红色标记的 > 替换为 > - 是吗?如果是这样,那么我认为 @romainl 提出了一个很好的答案:

:s/>/>/g

If I correctly interpret your question and screenshot, you want the > marked in red to be replaced with > -- yes? If so, then I think @romainl suggested a good answer:

:s/>/>/g

赤濁 2025-01-24 21:53:53

:s/&gt;/&gt;/g工作正常,谢谢。

基本上,我还想知道我是否可以为多行进行此操作。您需要做的就是选择或标记特定的“角括号”,因此,要归功于Romainnl和M_MLVX。

:s/>/>/g is working fine, thank you.

Basically, I also wanted to know if I can do this for multiple lines. Bat all you need to do is to select or mark specific "angle brackets", so again, thanks to romainnl and m_mlvx.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文