Home > OS >  Remove empty lines in file with VSCode but only at the start and end of file
Remove empty lines in file with VSCode but only at the start and end of file

Time:05-30

Here is my text :

     <---- empty line to delete
     <---- empty line to delete
Lorem ipsum
Lorem ipsum
     <---- empty line to keep
Lorem ipsum
     <---- empty line to delete

Here's what I would like to have using VSCode regex, or any extension you might know about.

Lorem ipsum
Lorem ipsum

Lorem ipsum

Any idea ? Thanks!

EDIT: I might need to precise that I want to achieve this on more than 12000 files. So can't imagine doing this manually.. And I haven't found any extensions yet, neither answers about this subject.

CodePudding user response:

The second empty line you can remove with \n $(?![\r\n])

For the first couple of empty lines the following fits your example (?<!([a-z]|\n))\n but probably there are cases where this fails.

  • Related