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

KeysWhat they do
ddDelete the current line
3ddDelete three lines, starting with this one
DDelete from the cursor to the end of the line
dj / dkDelete this line and the one below / above
:5dDelete 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