Adding parenthesis around highlighted text in Vim

Lovely, lovely vim

The command

c()<Esc>P

Explanation

If you want to put the word under the cursor in to brackets this is viwc()<Esc>P.

viw will visually select all charactrs in a word.

c() will cchange the selection and drops you into insert mode, where you type the literal characters ( ). Also, c automatically copies the original content to your yank buffer (clip board).

With <Esc>P you return Escback from insert to normal mode and Paste the previous content.

Source: Adding parenthesis around highlighted text in Vim

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.