Sudar
Sudar

Reputation: 20000

Surround two words with quotes in Vim

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?

Upvotes: 20

Views: 9052

Answers (3)

Sarah
Sarah

Reputation: 6695

When using surround commands, I find the most logical solution is to sequence the "marking" and the "surrounding" operations.

Thus, with text objects, I use v2aw to visually mark the two words, then s" for the total of

v2aws"

Upvotes: 3

Anji
Anji

Reputation: 723

Press b first and then ys2w"

Upvotes: 6

Benoit
Benoit

Reputation: 79185

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

Upvotes: 42

Related Questions