node ninja
node ninja

Reputation: 32986

Deleting HTML tags with vim

How can I easily delete blocks of text surrounded by HTML tags?

Say I come across a block of text that is surrounded by <div> tags. How can I easily delete everything within the tags, and the tags themselves, all at once?

Upvotes: 32

Views: 9997

Answers (2)

Prince Goulash
Prince Goulash

Reputation: 15715

Text objects are your friends...

  • dat : "delete around tag"
  • dit : "delete inside tag"

There are also similar operations for changing the text (cat and cit) and selecting it visually (vat and vit).

Have fun!

Upvotes: 84

manojlds
manojlds

Reputation: 301147

When in the <div>, say, you can do dat

Upvotes: 9

Related Questions