Visual Studio uses "find and replace" to delete pure comments and blank lines of all // methods in the source code

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.