Visual Studio uses "find and replace" to delete pure comments and blank lines of all // methods in the source code
Note: XML annotations including // <summary> are also deleted.
Step 1/2 (Delete comment): Use the CTRL + H quick replacement function to find the following content:
^ [\ T] * // [^ \ n] * \ n
If the content to be replaced is blank (nothing is written), you can set the search range (I like to select the entire solution). The search option should be selected using a regular expression. Click replace all.
This will delete the comments of the original line/And leave no blank lines.
Step 2/2 (delete empty rows): then set the search content
^: B * $ \ n
Then replace all the empty rows.
-----------------------------------------------
The reason is that only comment lines are removed because
Int A = 0; // interger with initial value 0.
The mixed comments are too complicated for me to handle. I have to make plans later.
How complicated is it? Here are a few examples.
1 var str1 = "hello"; // var str1 = Hello "; think this is easy, ha? 2 var str2 = "Bye \" "; // bye "\". so, bite me3 var str3 = @ "this is called 4 multiple line string. "; // kiss my ass," Regular Expression"
What should we do in these cases? Let's discuss it again.