Use Tim Pope vim-surround , you can use: ysw' to enclose the word with "` ", ysw( to surround the word" If you want to surround the word with an actual tag, such as an HTML <code> , you can use yswt , and then enter your tag at the csw you want to modify existing surround elements, use csw , enter the surround element that you want to replace, and press <CR> (enter) and enter a new surround element.
Note that for the above commands, you must place the cursor at the beginning of the word that you want to surround.
From the official page:
Press cs"' (this is c, s, double quote, single quote) inside
"Hello World!"
to change it to
"Hello World!"
Now press cs'<q> to change it to
Hello World!
To go full circle, click cat" to get
"Hello World!"
To completely remove the delimiters, press ds" .
Hello World!
Now, using the cursor on βHi,β press ysiw] ( iw is a text object).
[Hello] world!
Let it do the brackets and add some space (use "}" instead of "{" for space): cs]{
{Hello} world!
Now wrap the entire line in parentheses with yssb or yes) .
({Hello} world!)
Return the source: ds{ds)
Hello World!
ysiw<em> hi: ysiw<em>
Hello World!
Finally, try the visual mode. Press capital city V (for visual line mode) and then S<p class="important"> .
Hello World!
For more detailed usage information, install vim-surround , and then use :help surround to call up documents.