Clean code (edit)
It's very useful especially if you want to arrange or compare codes, thanks for the people who answer this question, I've got the answer from here and would like to share it with Stackoverflow:
Visual Studio has ability to delete empty lines in replace operation using regular expressions.
-
Click Ctrl-H (quick replace)
-
Tick "Use Regular Expressions"
-
In Find specify ^$\n
-
In Replace box delete everything.
-
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
Note that normally in Windows an end of line indicated by 2 characters crlf - Carriage Return (CR, ASCII 13, \r) Line Feed (LF, ASCII 10, \n).
A regex to remove blank lines that are/aren't really blank (i.e. they do/don't have spaces): ^:b*$\n
To remove double lines: ^:b*\n:b*\n replace with: \n
* for Visual Studio 2013 and above:*
^\s*$\n
and for double lines:
^(?([^\r\n])\s)*\r?\n(?([^\r\n])\s)*\r?\n
How to Remove "debugger;" in Visual Studio
Nhìn hình dưới: debugger;\r OR \\debugger;\r OR \\debugger;\n \\debugger;\n
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:
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).