How to remove empty lines in Visual Studio?
Since Visual Studio 2012 changed its regex syntax, the original answers by Ala translate into the following in VS 2012:
Remove single blank lines
Old:
^:b*$\n
New:
^(?([^\r\n])\s)*\r?$\r?\n
Visual Studio 2013 (thanks to BozoJoe and Joe Johnston):
^\s*$\n
Remove double blank lines
Old:
^:b*\n:b*\n
New:
^(?([^\r\n])\s)*\r?\n(?([^\r\n])\s)*\r?\n
Rolls right off your tongue.
Here is the conversion sheet from MSDN.
Ctrl + K, Ctrl+D auto formats the current document and that removes unnecessary space in your code. It helps keep your code readable if that what you were looking for.
In Visual Studio 2013 (Version 12.0.20623.01) i removed empty lines with this regular expression ^\r\n
In the screen you can see the matched lines indicated by the brown squares.
Tested in VS 2012 to allow for pure line feeds.
^\s*$\n
hth
Using Visual Studio 2017 and above
in Current Document
use shortcut
Edit.DeleteBlankLines
select all text and hit the shortcut