node ninja
node ninja

Reputation: 33056

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: 10057

Answers (2)

Prince Goulash
Prince Goulash

Reputation: 15735

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: 301527

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

Upvotes: 9

Related Questions