0

With other editors we can select vertical-blocks where each line has the same start column but not the same end-column.

For example:

print("", s.field1);
print("", s.field_long);
print("", s.f);

Is there a way in Vim (with a plugin or not) to select the block from the snippet above:

field1
field_long
f

Can we tell vim to select everything up to a certain character?

A more powerful variant could be to tell Vim select everything between two characters going left and right from the currently selected column.

EDIT: Doing tricks with CTRL-v does not work as it always selected a rectangle. Here I vertically selected the fs and then did w for word-skip.

  • 3
    This is not an exact duplicate, but you might be interested by my answer to this question: There are plugins which allows you to do what you want and there is probably a built-in feature which will allow you to do what you want but we would need more details on your final goal to help you efficiently. There is also <C-v>$y that you could use to yank the text you want to use followed by s:/);// to remove the unwanted characters. – statox Jun 3 at 15:20
1

Go to the first letter of the word, and press

<C-v>w

that selects the word. You may use

<C-v>5w

to select e.g. 5 words. Then you do whatever you want, e.g. to copy to clipboard you do

" * y
  • Doesn't work unfortunately. C-v is selecting a rectangle. – Patrick B. Jul 5 at 9:53
0

If memory serves:

/field1<CR><C-v>2jf)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.