Visual Studio Code - delete all blank lines - regex

后端 未结 15 1222
心在旅途
心在旅途 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 19:15

    Here's my regex, it catches all extra new lines and empty lines that contain only space,tabs etc

    \n\s*\n
    

    And I replace all matches with \n

    Explanation

    \n       : New Line
    \s*      : Zero or more consecutive white space characters or new lines
    \n       : Another New Line
    

    P.S :Remember to choose the regex option in the search window!!

提交回复
热议问题