1

If I have the cursor placed on "word1" and wanted to select "word1 word2 word3" (i.e. with no trailing space after "word3") what is the easiest command?

word1 word2 word3 word4

I am currently using v5iw. Is this easiest command?

  • 2
    Easiest is highly subjective. (It proably would mean using the mouse, as you get direct feedback on the selection, but this is very far from what typically Vim users would do.) Do you mean shortest? What makes you think you could beat 4 (unshifted) key presses? – Ingo Karkat Nov 20 '18 at 12:59
2

I would go with vf3 (with the cursor at the beginning of the first word) because it doesn't require you to count anything you just have to think "I want to put my cursor in this character".

Anyway I think what you should really read is :h motion.txt to understand which motion exist and for which range they are useful.

Also asking for the best way to visually select these word might be a XY Problem: There is a good chance that what you want to do would be more efficient without a visual selection (for example df3 would deleted the words in only 3 keystrokes)

1

You want 3 words, and this key combination uses number 5, so not so straight-forward in my opinion. I would possition cursor on the start of word1 if needed - with b - and then used v3e (or even v3E - if the words would include for example - in them)

1

For me personally, counting stuff and apply counts is not the easiest thing to do.

I prefer to do several repeats like with viwee.

Or if the ending word is quite away from the cursor position I would go with v/3/e<CR>

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.