Lovely, lovely vim
Source: Adding parenthesis around highlighted text in VimThe command
c()<Esc>P
Explanation
If you want to put the word under the cursor in to brackets this is
viwc()<Esc>P
.
viw
willv
isually select all charactrsi
n aw
ord.
c()
willc
change the selection and drops you into insert mode, where you type the literal characters(
)
. Also,c
automatically copies the original content to youryank
buffer (clip board).With
<Esc>P
you returnEsc
back from insert to normal mode andP
aste the previous content.