I'm wondering why in Vim the w key affects an inconsistent amount of text when preceded by d vs v. For example, suppose my cursor is over the "t
" of "two
" in this text:
one two three
Now dw produces:
one three
But vwd produces:
one hree
Is there some setting to make this more consistent, or do I need to write my own custom definition to fix it?
Also, the capital W selector is similarly inconsistent, and I'm wondering if there's a key for visually selecting the same portion that dW would have deleted? Best I can come up with is vfspace which is OK but wondered if there's anything shorter I'm missing that's built in.
The command to delete a line in Vim is dd . Below are step-by-step instructions to delete a line: Press the Esc key to go to normal mode. Place the cursor on the line you want to delete.
yes there is one option: selection
which default is inclusive
. it makes v
to select the last char.
:h 'selection'
to check detail.
w
is exclusive motion. but if in visual mode, it depends on the selection
setting.
you could set selection
to exclusive
to make vwd
and dw
to behave identical.
The w
key does the same in both cases, it puts the cursor in the begining of the next word.
What is "inconsistent" is the v
command.
In the first case dw
means, delete up to, but not including, the cursor.
In the second case vwd
deletes the selection, however the selection includes the cursor. You can clearly see this when you do vw
.
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