Vim Scoops / Lessons / Delete a line
How to delete a line in Vim
Press dd in Normal mode to delete the line the cursor is on. Put a number first to delete more: 3dd deletes three lines.
The keys
| Keys | What they do |
|---|---|
dd | Delete the current line |
3dd | Delete three lines, starting with this one |
| D | Delete from the cursor to the end of the line |
dj / dk | Delete this line and the one below / above |
:5d | Delete line 5 without moving there |
Deleted lines aren't gone. Vim keeps the last one like a cut, so p puts it back below the cursor. That's also the quickest way to move a line.
Deleted the wrong one? u undoes it.
Related
Want all of Vim, in order? Vim Scoops is a free game that starts at h j k l and builds up to macros.
Play the full game