How to delete HTML tags, not the contents in Vim

retro picture retro · Jun 7, 2011 · Viewed 9.6k times · Source

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.

Answer

Benoit picture Benoit · Jun 7, 2011

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...