cdxf
cdxf

Reputation: 5648

how to delete tag pair without content inside it in VIM

Assume I have this block:

<div>
<|p>
   <b>text</b>
</p>
</div>

So how to delete the p tag pair without the content inside it so It would become:

<div>
   <b>text</b>
</div>

Upvotes: 1

Views: 575

Answers (2)

Peter Rincker
Peter Rincker

Reputation: 45147

You can do this with Tim Pope's surround.vim plugin.

dst

With plain Vim you can do:

yitcat<c-r>0

For more help see:

:h it
:h at
:h i_CTRL-R
:h "0

Upvotes: 6

Kent
Kent

Reputation: 195169

I have othree/xml.vim plugin installed. Move your cursor on the element you want to delete, then Leader + d will do what you want, leader + D will remove the tag with content. There are some more features, you can check the doc.

Upvotes: 1

Related Questions