Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change HTML tag in vim, but keeping the attributes (surround)

Tags:

html

vim

surround

Let's say I have a tag (and cursor at *):

<h1 class="blah" id="moo">H*ello!</h1> 

I want to change it to:

*<h2 class="blah" id="moo">Hello</h2> 

i.e. Change the type of tag, but keep all the elements.

Using surround.vim, I could do:

cst<h2> 

but that changes the HTML to:

*<h2>Hello</h2> 

Is just changing the tag possible, but keeping all the attributes? Surround documentation doesn't seem to contain anything like this...

like image 459
cazgp Avatar asked May 02 '13 13:05

cazgp


1 Answers

Replacing tag while keeping attributes has been added to Surround.vim

cst<p> replaces whole tag, while cst<p (without closing bracket) keeps attributes.

like image 151
Wojtek Kruszewski Avatar answered Sep 19 '22 05:09

Wojtek Kruszewski