Vim delete blank lines

后端 未结 14 2580
情歌与酒
情歌与酒 2020-12-02 03:33

What command can I run to remove blank lines in Vim?

14条回答
  •  醉梦人生
    2020-12-02 03:44

    Found it, it's:

    g/^\s*$/d
    

    Source: Power of g at vim wikia

    Brief explanation of :g

    :[range]g/pattern/cmd
    

    This acts on the specified [range] (default whole file), by executing the Ex command cmd for each line matching pattern (an Ex command is one starting with a colon such as :d for delete). Before executing cmd, "." is set to the current line.

提交回复
热议问题