Wednesday, August 17, 2011

Remove empty lines in Visual Studio in CS file

Just another use of regular expression. I had a situation where a developer has checked in file with lot of white spaces in between methods and I want cs file to look clean so here is the solution:

Visual Studio has ability to delete empty lines in replace operation using regular expressions.

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.

No comments:

Post a Comment