Visual Studio Code - delete all blank lines - regex

后端 未结 15 1241
心在旅途
心在旅途 2021-01-29 18:36

I spent some time trying to figure out how to delete all blank lines in Visual Studio Code and I can\'t get it working. Anybody knows how to do it please?

If I search fo

15条回答
  •  攒了一身酷
    2021-01-29 18:55

    What also works is this regex pattern:

    ^\s*$\n
    

    Then CTRL+Enter to replace all lines.

    Explanation of the above pattern:

    -----------------------------------------------
    |  ^ | beginning of string anchor             |
    -----------------------------------------------
    | \s | any whitespace character               |
    -----------------------------------------------
    | '*'| zero or more repetitions               |
    -----------------------------------------------
    |  $ | end of string anchor                   |
    -----------------------------------------------
    | \n | new line                               |
    -----------------------------------------------
    

提交回复
热议问题