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
install extention "Remove Blank Lines" in vscode
For those who might be interested - what worked for me in version 1.3.1 (and still works in 1.33.1) to delete blank lines I used ctrl+h (find and replace) alt+r (Use regular expression)
In find box then:
\n\n
In replace box:
\n
This should make two consecutive end of line signs into one.
edited:
If you need to replace more empty lines (more than two) at once, you can use following regular expression in find box:
\n+
If you need to replace also empty lines with whitespaces, then you need to use following regular expression in find box:
\n+\s*\n
VS code is using javascript regular expressions
I don't know about yout, but memorize a lot of commands for me seams a waste of time!
Use the extension "Blank Line Organizer", here's the description:
This extension will help you organize blank lines in the code by removing multiple blank lines. The extension removes blank lines only from the selected lines if any, otherwise from the entire file
How to use it: check the description of extension, but it really seams nice!
blankLine.triggerOnSave boolean true If set to true, the command will be triggered on save.
In other words, after save the file, it automatically cleans up!
One or more line breaks (\n)+ and replace by \n
Windows 10,Visual Studio 2015
Ctrl + H
Find... -> ^\s*
Replace all
Ctrl + A
Ctrl + K + F
Thank you for your question, I learned something new.
no, you're doing it right.
I get the same behaviour here.
I also tried another regex: (\r?\n){2,}
but it seems that it only works for single lines.
maybe there is a preference to change the default regexp behaviour, or maybe VS is just built in such a way (line based)
ofcourse it's not a big deal to cut-paste and back from another text editor.