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. You're already on the duplicate — delete it with dw.

The quick quick brown fox
jumps over the lazy dog.

Canonical solution: dw · target: 2 keystrokes — the fewest that solve it (every keypress counts).

Why it works

dw = operator (d) + motion (w): delete from the cursor to the start of the next word. w hops forward a word at a time, b hops back. This operator + motion 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
▶ live vim buffertarget 2 keystrokes
“quick” appears twice in a row. You're already on the duplicate — delete it with dw.

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

Sign in free to practice →

Keep going