I'm struggling to delete words in Vim

My cursor is on the final character of a word in Vim. Without moving the cursor, is there any succinct way to delete the current word and the word before it?

As far as I can tell, the only way to delete the current word is to use diw. Using db leaves the character under the cursor (which happens to be the last character).


Solution 1:

I would do either 2dbx or vbbd. Or v5bd if there were 5 words to delete.

I prefer vbbd as I like to have some visual clue of what I'm going to do and it feels a bit cleaner.

Solution 2:

Backward moving actions, (like db) take effect from the boundary in front of the cursor.

Probably your easiest way to do this is something like xd2b - that takes care of the character under the cursor first.

Generally I prefer to use Bdw (or wdB) when deleting whole words, as this doesn't leave you with a double space where the word was. Obviously this depends on the context of your actions, and what else you're trying to achieve.