Vim delete blank lines

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

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

14条回答
  •  自闭症患者
    2020-12-02 03:46

    :g/^\s*$/d
    ^ begin of a line
    \s* at least 0 spaces and as many as possible (greedy)
    $ end of a line
    

    paste

    :command -range=% DBL :,g/^\s*$/d
    

    in your .vimrc,then restart your vim. if you use command :5,12DBL it will delete all blank lines between 5th row and 12th row. I think my answer is the best answer!

提交回复
热议问题