The following is a sample of text opening in vim/neovim with line numbers:

1 What would be the command to delete one word backwards? 2 I know we can use ‘db’ to delete backword, and it would work 3 as what I wanted if the cursor is on the last character.

Assuming that my cursor is under letter ‘a’ of the word ‘command’ in line 1, and I want to delete the whole word ‘command’. How could this be done?

Well, up until now, I would do the following:

bdw

Essentially, bdw does the following: go back to the beginning of the word, delete (1) word. It kinda works, but I think there must be something more easier or more elegant that I’ve been missing. So, I did what most people will do - go ask a vim user… Well, just kidding. I googled.

Here are some interesting vim commands that could be used:

  1. dvb : delete, v - toggles the ‘inclusiveness’, b - backward

  2. diw : delete a word under the cursor but leaving a space in place of it.

  3. daw : delete a word under the cursor and the space after and before it.

  4. daW : delete a WORD.

What are the difference between word and WORD?

:h word

A word consists of a sequence of letters, digits and underscores, or a
sequence of other non-blank characters, separated with white space (spaces,
tabs, ). This can be changed with the 'iskeyword' option. An empty line
is also considered to be a word.

:h WORD

A WORD consists of a sequence of non-blank characters, separated with white
space. An empty line is also considered to be a WORD.

I think the 4 commands above are good enough for me for now. And, if I were to pick one, I probably will use daw.

References: