Earlier I was in a situation where I wanted to delete 3 words, with the cursor inside of the first one. For example
Vim is the best text editor
with the cursor on the h in the. I wanted to end up at
Vim is editor
I tried using 3diw to get rid of them, but that left me with
Vim is text editor
with 2 spaces between is and text. 3daw worked fine, leaving me with what I wanted, but I'm confused about why 3diw didn't work. I would have expected 3diw and 3daw to delete the same number of words, and have the only difference be diw leave two spaces and daw leave one.
So why does 3diw have this behavior?
you didn't understand the difference between iw and aw. with [count]diw (inner words), spaces between words would be counted as well. but they won't be counted with aw
iw "inner word", select [count] words (see |word|).
White space between words is counted too.
When used in Visual linewise mode "iw" switches to
Visual characterwise mode.
*v_aW* *aW*
aW "a WORD", select [count] WORDs (see |WORD|).
Leading or trailing white space is included, but not
counted.
so if you want to do with iw with your example, you need press 6diw:
1 the
2 " "
3 best
4 " "
5 text
6 " "
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With