Adsense

Monday, August 11, 2008

How to Replace/Remove Blank/Empty Lines in Visual Studio using Regular Expressions

I'm mainly just posting this so that I don't forget it. I find myself needing this every now and again and need an easy place to find it. Hope it helps someone else. =)
If you want to remove or replace the Empty Lines in a Visual Studio file, you can perform the following.
  • Press Control + H on your keyboard to bring up the replace window.
  • In the Find What: field, enter ^$\n
  • In the Replace With: field, enter nothing
  • Check the Use: checkbox and then select Regular Expressions from the drop-down
  • Click Replace All
Note: If you want to remove the blank lines from just a part of your file, select/highlight it prior to performing the step above and make sure Selection is selected in the Look in: field.
Hope this helped. =)

1 comment:

Unknown said...

thanks