delete word after or around cursor in VIM
Normal mode:
daw : delete the word under the cursor
caw : delete the word under the cursor and put you in insert mode
I think it's just daw
daw - delete a word
What you should do is create an imap of a certain key to a series of commands, in this case the commands will drop you into normal mode, delete the current word and then put you back in insert:
:imap <C-d> <C-[>diwi
The below works for Normal mode: I agree with Dan Olson's answer that you should probably be in normal mode for most deletions. More details below.
If the cursor is inside the word:
diw
to delete in the word (doesn't include spaces)
daw
to delete around the word (includes spaces before the next word).
If the cursor is at the start of the word, just press dw
.
This can be multiplied by adding the usual numbers for movement, e.g. 2w to move forward 2 words, so d2w deletes two words.
Insert Mode ^w
The idea of using hjkl for movement in Vim is that it's more productive to keep your hands on the home row. At the end of a word ^w works great to quickly delete the word. If you've gone into insert mode, entered some text and used the arrow keys to end up in the middle of the word you've gone against the home-row philosophy.
If you're in normal mode and want to change the word you can simply use the c
(change) rather than d
(delete) if you'd like to completely change the word, and re-enter insert mode without having to press i
to get back to typing.