You can surround the word currently under the cursor in quotes with the following normal mode commands:
ciw""EscP
Replace iw
with any other Vim motion/text object to surround other things with quotes*. Or ""
with any other pair of characters to surround the object with different things.
* Or use c
from visual mode to surround text that is hard to describe with a single motion.
If you want to surround the object with a longer piece of text, such as an HTML <p>
tag, you can use Ctrl-R instead of the P
put command:
ciw<p>Ctrl-R"</p>Esc
See :help i_CTRL-R
for more details.
Objects smaller than a line can also be surrounded using the small delete register, and as of Vim 8.2.2189, this is repeatable via the dot command, making it easy to apply the edit quickly in several different places.
So e.g. to go from this:
one two three four
to this:
(one two) (three four)
type:
c2w(Ctrl-R-)Escw.
Thanks to Christian Brabandt for letting us know about the fix, and for implementing it!
However, as dicussed in the comments, if you attempt to use Ctrl-R to surround an object larger than a single line (or prior to v8.2.2189), when you repeat this with the dot command, it will enter the text from the original change command. As @user938271 explains, you can workaround this by using Ctrl-RCtrl-O or Ctrl-RCtrl-P instead of a plain Ctrl-R when inserting the contents of the register.
So to go from:
<li>one
<li>two
<li>three
<li>four
to:
<ul>
<li>one
<li>two
</ul>
<ul>
<li>three
<li>four
</ul>
You can type:
c2c<ul>ReturnCtrl-RCtrl-O"</ul>Escjj.