I read that b is like the reverse of e i.e. b does what e does but backwards.
So if I hit de on a word and the cursor is on the first letter of the word, it deletes the whole word. That's great!
But if I hit db on a word and the cursor is on the last letter of the word, it deletes the whole word except for the letter that the cursor was on!
I know I could just move over one character when using b but I would like to keep things consistent. And perhaps someone could enlighten me as to why b behaves like this.
the vim cursor is a pretty disgusting thing and poorly designed, to mimic the block cursor of terminals. the cursor position is actually at the start / left hand side of the block, so if the block is "on" k
in bark
and you db you're actually deleting from r
to b
.
fortunately, you can change the cursor to something reasonable
b is not the opposite of e, as b is an exclusive motion, while e is inclusive. From :help e
& :help b
:
e
Forward to the end of word[count]
inclusive. Does not stop in an empty line.
b
[count]
words backward. exclusive motion.
And from :help exclusive
:
A character motion is either inclusive or exclusive. When inclusive, the start and end position of the motion are included in the operation. When exclusive, the last character towards the end of the buffer is not included. Linewise motions always include the start and end position.
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