Wednesday, September 18, 2013
In this example you will see how to remove empty line from text in Visual Studio 2012/Visual Studio 2013. By using Regular expression in Search box you can remove empty line from text in Visual Studio 2012/Visual Studio 2013 In Visual Studio 2012/Visual Studio 2013 regular expression syntax has been changed. In Windows Operating system lines end with “\r\n”. You cannot see these characters. The following regular expression are used for this example
1.Beginning of line ^
2.End of line $
3.Line break \n
The following regular expression to remove multiple lines from code in Visual Studio 2012/Visual Studio 2013
Step 1: Press CLTR +F on keyboard
Step 2: Tick Regular Expression icon
Step 3: In Find text box copy ^(?([^\r\n])\s)*\r?$\r?\n expression. For multiple lines only you can copy the following above regular expression two times. It will not remove single line as shown in below figure
Step 4: Delete all characters from Replace text box
Step 5: Click on Replace button.
Now, you will see all bank line will be deleted from code page.
The following links shows all list of regular expression that are valid in Find and Replace
Note: Regular expression has been changed for newer version of Visual Studio