Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Surround two words with quotes in Vim

Tags:

vim

surround

I am working with vim-surround and the following text. (* is the place of the cursor)

This is a lo*ng line and I want to highlight two words

I want to surround both the words long and line within quotes, so that it becomes

This is a "long line" and I want to highlight two words

Is it possible to do it without getting into visual mode?

like image 486
Sudar Avatar asked Apr 21 '12 10:04

Sudar


People also ask

How do you surround words with a quote in Vim?

press q and q for recording into q register (we use "q" as shortcut to remember "quotes"). press a then press ' again to surround the word with quotes.


2 Answers

Try: ys2w" (ys takes a motion or text object, and then the character with which you want to surround).

like image 56
Benoit Avatar answered Sep 28 '22 01:09

Benoit


Press b first and then ys2w"

like image 34
Anji Avatar answered Sep 28 '22 02:09

Anji