我在打开的文件中有以下代码Vim
:
<p>Hello stackoverflow!</p>
如何删除<p>
和</p>
标记,但保持它们之间的内容?也就是说,我应该按什么结尾:
Hello stackoverflow!
我知道按d i t会相反。
我正在使用Janus。
Answers:
随着surround.vim插件安装,按d s t到d elete小号urrounding牛逼股份公司。
类似的快捷方式:
()
""
''
等等...
di…
,da…
但是我才知道ds…
。太有用了!
一个简单的解决方案是(将光标放在标签内的任意位置):
yitvatp
这是什么:
y
-拉 it
-标签内部vat
-选择整个标签p
-将先前选中的文本粘贴到其上爱兰迪(+1)的答案,我刚刚了解了标签块!这只是一个补充答案。
所以YIT手段“猛拉内标签块”和增值税的手段“去可视化模式并选择一个(整体)标签块”。
这仅适用于那些懒于阅读帮助文件的人:
Tag blocks *tag-blocks*
For the "it" and "at" text objects an attempt is done to select blocks between
matching tags for HTML and XML. But since these are not completely compatible
there are a few restrictions.
The normal method is to select a <tag> until the matching </tag>. For "at"
the tags are included, for "it" they are excluded. But when "it" is repeated
the tags will be included (otherwise nothing would change). Also, "it" used
on a tag block with no contents will select the leading tag.
"<aaa/>" items are skipped. Case is ignored, also for XML where case does
matter.
In HTML it is possible to have a tag like <br> or <meta ...> without a
matching end tag. These are ignored.
The text objects are tolerant about mistakes. Stray end tags are ignored.