5/17/2012

Remove blank lines in Visual studio


Steps to remove empty lines using Visual Studio in .cs or .vb file



Start Visual Studio and follow these steps.
1.Click Ctrl-H (quick replace)
2. Tick "Use Regular Expressions"
3. In Find specify ^$\n
4. In Replace box delete everything.
5 Click "Replace All"All empty lines will be deleted.

Regular expression for empty line consist of  

Beginning of line
End of line $
Line break \n

A regex to remove blank lines that are/aren't *really* blank (i.e. they do/don't have spaces):   ^:b*$\n