Delete lines in vi

:heavy_exclamation_mark: This post is older than a year. Consider some information might not be accurate anymore. :heavy_exclamation_mark:

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


Delete line 10


Delete from start to line 30


Delete from line 50 to end ($)


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

Please remember the terms for blog comments.