How to Delete All Lines in Vim
The answerPress gg then dG — jump to the first line, delete to the last. Or run :%d.
All the ways
| Keys | What it does |
|---|
| ggdG | delete every line |
| :%d | same, as an ex command |
| ggVGd | same, via visual mode |
| :2,$d | delete everything except line 1 |
▶ live vim buffertarget 3 keystrokes
Three junk lines sit together. You're on the first one — press 3dd to delete all three (a count multiplies any command).
Reading about keystrokes doesn't build keystrokes. Try this in a real vim buffer right now — the “Triple threat” mission takes about a minute.
Sign in free to practice →
Keep going