Loading...

Delete lines in vi

vi or vim (vi improved) has powerful ways to delete line. This post gives some examples.

The command for delete is :d. Delete current line

dd

Delete line 10

:10d

Delete from start to line 30

:0,30d

Delete from line 50 to end ($)

:50,$d

Delete blank line (:g will execute a command on lines which match a regex. The regex is ‘blank line’)

:g/^$/d
vi