20

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?

Sudar
  • 18,954
  • 30
  • 85
  • 131

3 Answers3

41

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

Benoit
  • 76,634
  • 23
  • 210
  • 236
6

Press b first and then ys2w"

Anji
  • 725
  • 1
  • 9
  • 27
3

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"
Sarah
  • 6,565
  • 1
  • 33
  • 44
  • I have tied it. Seem like it is surrounding only for the first word – Anji Apr 21 '12 at 12:25
  • Huh? v2iw will visually mark two inner words. s" will surround the visual selection with "". Can you give a sample text and cursor location where it does not work? – Sarah Apr 21 '12 at 12:54
  • Actually, I have the same problem that you describe on my Mac version of Vim. I wonder if there's some incompatibility... I'll look into it. – Sarah Apr 21 '12 at 12:57
  • Cool. Please do comment when you figure it out. It will be helpful. – Anji Apr 21 '12 at 12:58
  • It works with "a" word instead of "inner" word. I will update my answer. – Sarah Apr 21 '12 at 12:59