,我有以下的,我在Vim
打開的文件的代碼:如何刪除HTML標籤,而不是內容的Vim
<p>Hello stackoverflow!</p>
如何刪除<p>
和</p>
標籤,但保留的內容他們?也就是說,我應該怎麼按,以結束與:
Hello stackoverflow!
我知道按d我噸會做相反。
我正在使用Janus。
,我有以下的,我在Vim
打開的文件的代碼:如何刪除HTML標籤,而不是內容的Vim
<p>Hello stackoverflow!</p>
如何刪除<p>
和</p>
標籤,但保留的內容他們?也就是說,我應該怎麼按,以結束與:
Hello stackoverflow!
我知道按d我噸會做相反。
我正在使用Janus。
隨着surround.vim插件安裝,按dst to d elete s urrounding t ag。
類似的快捷方式:
()
""
''
等等...
愛蘭迪(+1)的答案,我只是瞭解了標籤塊!這只是一個補充答案。
所以yit的意思是「內藏標籤塊」,而桶意味着「進入視覺模式並選擇a(全部)標籤塊」。
這僅僅是對於那些懶得看幫助文件:
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.
這是我的解決方案。謝謝。 – retro 2011-06-07 11:13:43
這應該是最有價值的答案,因爲每個人都應該使用TPopes真棒插件這些天! :) – walialu 2014-11-14 07:50:05
我知道'di ...'和'da ...',但我剛剛瞭解到'ds ...'。非常有用! – 2017-06-20 16:51:01