Learn Vim / How to Delete a Word in Vim

How to Delete a Word in Vim

The answerPress daw to delete the word under the cursor (including its space), or dw from the start of the word.

Try it on a real buffer

“quick” appears twice in a row. Put the cursor at the start of the second “quick” and delete the whole word with dw.

The quick quick brown fox
jumps over the lazy dog.

Canonical solution: w w (onto the 2nd quick), then dw · par: 3 keystrokes (vimgolf rules — every keypress counts).

Why it works

w hops forward a word at a time, b hops back. dw deletes from the cursor to the start of the next word — operator (d) + motion (w). This grammar is the heart of vim.

Variations

KeysWhat it does
dawdelete a word plus its surrounding space — works from anywhere in the word
diwdelete the word only, keep the space
dwdelete from the cursor to the start of the next word
d3wdelete three words
dbdelete to the beginning of the word

Reading about keystrokes doesn't build keystrokes. Try this in a real vim buffer right now — the “Double vision” mission takes about a minute.

Practice free — no signup →

Keep going