Vim editor: how to delete lines in files

1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 5.00 out of 5)

There is a command d to delete lines, words and characters from the file.

The dd command deletes the one current line on which the cursor is located.

Using the command Nd and pressing the arrow removes N characters (lines) depending on the arrow pressed.

The commands +d and d+$ delete the whole line, starting with the current position of the cursor.

It can be useful to delete all lines from the current one to the end of the file. To do this, use the commands :d+g or :.,$d

Leave a Reply

Your email address will not be published. Required fields are marked *