Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find lines in Visual Studio which are not comments

How to use Visual Studio "Find in Files" tool window to find ALL lines having a certain phrase in them but filter by NON-comment lines at the same time?

There must be a regular expression? Or a link to the regexp help?

like image 537
user492238 Avatar asked Sep 13 '13 14:09

user492238


People also ask

How do I remove comment line in Visual Studio?

Ctrl+K+U will uncomment the code.

How do you remove commented lines in VSCode?

Once installed, remove comments in your code by opening the command palette ( Ctrl + Shift + P ), entering "Remove all comments" and pressing enter. Voilà, all the comments are gone 🎉 !


1 Answers

Select "Use Regular Expressions" in the "Find in Files" window and enter the following phrase in the search box:

^(?!(\s*/+)).*phrase

If you want the phrase to stay as a single word:

^(?!(\s*/+)).*\s+phrase\s+

Regarding the help: in regexp mode there is a small button next to the search box: [(a)+] It opens a short list with common regexp commands. At the end of that list there is a link to the msdn documentation.

like image 70
Haymo Kutschbach Avatar answered Oct 24 '22 18:10

Haymo Kutschbach