How to Remove Blank Lines in Visual Studio

We can use regular expressions to find blank lines and replace them with white spaces.

Following steps are to find blank lines and replace:

In visual studio 2012.

1. Press “ Ctrl+ Shift + H “.

And window shown like:

replace

2. Write regular expression For (vs2012) "^(?([^\r\n])\s)*\r?$\r?\n" or for vs 2010 (^$\n or ^&\n)in find what box.

3. Leave Replace with box as empty.

4. In find check Use Regular Expressions.

Then Replace or Replace all as you want.

These steps will remove all blank spaces from current document or whole project as you choose Look in box.

Other regular expressions are predefined by visual studio as in below image.(or can see by (a)+ button on find what box).

expressions