tags:

views:

144

answers:

4

I am working in VIM and I just want to know is it possible to delete a word when the cursor is in the middle of that word (or some where it is other than the beginning or end).

Thanks in Advance :-)

+4  A: 

bdw should do it.

back to the beginning of the word, delete to the next word

mpez0
This looks very work around , I want to do this more specific than this
abubacker
+1, this is the shortest answer I know of. If it's still too long, @abubacker, see `map` on how to assign to a single keystroke (http://how-to.wikia.com/wiki/How_to_map_keys_in_vim).
paxdiablo
This does not work on single-character words.
Luc Hermitte
+9  A: 

what you need is the following keystrokes in normal mode (without quotes):

"daw" delete a word

:help daw

for more related commands.

Zhaojun
Thanks , it looks really useful to me
abubacker
Unlike diw, this solution also deletes all the spaces after the current word.
Luc Hermitte
Agreed, `daw` is best for deleting a word (Delete All of Word). The `iw` motion is more suitable if you want to type another word in its place, using `ciw` (Change Inner Word).
nelstrom
+7  A: 

I found that "diw" ( delete inner word ) is the straight forward way to delete a word!

abubacker
A: 

In Escape mode, use dw even when the cursor is underneath the middle of the word

tommieb75
This does not delete the beginning of the word.
Luc Hermitte
@Luc: Oh...who said it was beginning of the word.. the OP was asking for to delete in the middle of the word with the cursor underneath it... not at the beginning...
tommieb75
The OP wants to delete the word wherever the cursor is within the word. dw does not fulfil that requirement as it lets the beginning of the word untouched. Only diw, and to some extend daw, does.
Luc Hermitte