Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting HTML tags with vim

Tags:

html

vim

vi

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?

like image 504
node ninja Avatar asked Sep 01 '25 18:09

node ninja


2 Answers

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!

like image 72
Prince Goulash Avatar answered Sep 04 '25 08:09

Prince Goulash


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

like image 28
manojlds Avatar answered Sep 04 '25 07:09

manojlds