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?
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?
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)
vf3
selects only the first character of the first word for me. Sure, I can use multiple ee
after this, but then why not use vf0
or vf1
instead?
Commented
Aug 17, 2022 at 11:47
f
is a motion "until the next occurence of the target" and here 3
is the target. So if vf3
doesn't select until the 3
in word3
for you it might means that you have remapped f
to do something else or that you have something weird in your config.
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>
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)