Thursday, March 25, 2021

Visual Studio : Search Uncommented Code only

Visual Studio : Search Uncommented Code only

🔥 Save unlimited web pages along with a full PDF snapshot of each page.
Unlock Premium →

Asked

Viewed 2k times

This question shows research effort; it is useful and clear

9

This question does not show any research effort; it is unclear or not useful

Show activity on this post.

Is there any way to restrict the Find/Search to uncommented lines only ?
(Maybe using regex would be a good lead)

Follow this question to receive notifications

5

  • regex will definitely work for lines starting with // but it's going to be some crazy regex to skip those contained in /**/ – stijn Sep 23 '11 at 11:16

  • Is there a solution for VS 2015? I tried the only given answer but it didn't seem to work and instead would never find anything.. – Alox Oct 11 '18 at 13:40

4

This answer is not useful

Show activity on this post.

Lets say, if you need to search all occurrences of an uncommented text "VPEntity" then try using the following regular expression in Find in files after selecting the Use RegEx option

^((?!//|/\*).)*VPEntity  

Hope it works for you

Follow this answer to receive notifications

2

  • or use this ^((?!//|/*).)*VPEntity*$ or you can tweak it as per your need using any RegEx Builder tool – Azfar Apr 25 '12 at 8:09

  • and for VB.Net code it is ^((?!').)*VPEntity.*$ The .+ at the end is important, otherwise it won't match unless VPEntity is at the end of the line. This could be more robust I'm sure since a ' anywhere before the term in the line will prevent a match, not just the beginning. – MHollis Jul 10 '13 at 18:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.

Source: https://stackoverflow.com/questions/7527468/visual-studio-search-uncommented-code-only
This web page was saved on Thursday, Mar 25 2021.

Upgrade to Premium Plan

✔ Save unlimited bookmarks.

✔ Get a complete PDF copy of each web page

✔ Save PDFs, DOCX files, images and Excel sheets as email attachments.

✔ Get priority support and access to latest features.

Upgrade now →

No comments: