如何删除HTML标签,而不是Vim中的内容

我在Vim打开的文件中有以下代码片段:

 <p>Hello stackoverflow!</p> 

我如何删除<p></p>标签,但保持它们之间的内容? 也就是说,我应该按什么来结束:

 Hello stackoverflow! 

我知道, 会做相反的事。

我正在使用Janus 。

在安装了surround.vim插件后,请按d来取消环绕标记。

类似的捷径:

  • d s – 删除周围的圆括号()
  • d s – 删除周围的双引号""
  • d s ' – 删除周围的单引号''

等等…

一个简单的解决scheme是(光标在标签内的任何地方):

 yitvatp 

这是做什么的:

  • y – yanks
  • it – 标签的内部
  • vat – select整个标签
  • p – 将之前抽取的文本粘贴在上面

爱兰迪(+1)的答案,我刚刚了解到标签块! 这只是一个补充答案。

所以yit的意思是“内藏标签块”,大桶的意思是“转到视觉模式,select一个 (整体)标签块”。

这仅仅是那些懒得阅读帮助文件的人:

 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. 

将其映射到您select的密钥:

 vat<Esc>da>`<da> 

摘自http://vim.wikia.com/wiki/Delete_a_pair_of_XML/HTML_tags