Search code examples
htmlvimemmetabbreviation

Emmet Vim wrap a specific tag around


This is very basic but I just could not find an easier way of doing it.

I have an html file and I want to wrap <strong></strong> around some part.

So, I go to visual mode. Select the text. Do Control Y - ,. It asks for Tag. I enter strong and it wraps the tags as expected.

But this is way too long for vim IMHO.

Is not there a quicker/ easier way to get this done? May be an abbreviation attached to a keystroke?

So, I select the text in visual mode, press a key and there --- <strong> </strong> appear around it?


Solution

  • With the surround plugin it's select the text in visual mode, press S<, tag name, <cr>.

    Or ys, motion or text object, <, tag name, <cr>.

    < can be replaced by t, attributes can be appended to the tag name, and <cr> can be replaced by >.