using vim surround plug-in

Installation:

I prefer using pathogen to manage my plug-ins all you have to do is clone the repo in the ~/.vim/bundle directory and you are good to go.

git clone https://github.com/tpope/vim-surround.git

workflow:

There are different types of surrounding tags

Surrounding words

Place the cursor within that word and type ysiw followed by the desired container eg ysiw<em> Yank(copy) surround to inner word Using opening brackets adds spacing before and after word, while the closing ones don’t. Try ysiw{ vs ysiw}

Removing surrounds

To remove them ds+ surround depending on which type of quotes you used. e.g ds" or ds{

Interchanging surrounds :

You can change ‘hello’ to “hello” by placing the cursor inside the word and typing cs'" Which read change surround single-quotes to double-quotes you can interchange them.
That works for all other surrounds except tags e.g. <em> For those you have to change them to another surround then back to your desired tag. So cst' Change surround to single-quote then cs'<p>

Surrounding a selection in Visual mode.

Highlight the text you want to surround and type S plus the desired end. e.g. S<em on Hello world will result in <em>Hello world</em> The closing end will be placed on the next line.

End of story