Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete HTML tags, not the contents in Vim

I have the following piece of code in a file that I opened in Vim:

<p>Hello stackoverflow!</p> 

How can I delete <p> and </p> tags but keep the contents between them? That is, what should I press to end with:

Hello stackoverflow! 

I know pressing d i t will do opposite.

I'm using Janus.

like image 837
retro Avatar asked Jun 07 '11 10:06

retro


People also ask

How do I delete a tag in Vim?

press d ("d") to delete it.

How do I autocomplete HTML tags in Vim?

For example, you may type <li>example</ then press Ctrl-x Ctrl-o to automatically finish typing the tag so the text reads <li>example</li> . With this abbreviation, you can simply type </ then press Space to automatically complete the tag.


1 Answers

With the surround.vim plugin installed, press d s t to delete surrounding tag.

Similar shortcuts:

  • d s ( - delete surrounding parentheses ()
  • d s " - delete surrounding double quotes ""
  • d s ' - delete surrounding single quotes ''

and so on...

like image 133
Benoit Avatar answered Sep 21 '22 13:09

Benoit