Include only certain file types when searching in Visual Studio

Often, when I want to search my code in Visual Studio, I know that the thing I'm looking for is in some C # code. However, since I used the same variable name in the JavaScript file, I must skip all these search results. It gets even worse when the text I'm looking for is also used in the third-party JavaScript library that we put into the project: this can lead to hundreds of search results.

To make matters worse, our designers include HTML page layouts in one project, so I often find that I also click on many search results.

I guess I really want to see the results in my .cs, .aspx and .ascx files, but not .js or .htm.

Is there a way to do one of the following:

  • Search only in files of a certain type (search only .cs files).
  • Search only in files of any given set of types (search only .cs, .aspx and .ascx files).
  • Search all file types except for a specific type or type (search all but .js).

I don’t suspect that in this case there is some tricky way around this?

+96
replace find search visual-studio-2008 visual-studio
Nov 17 '09 at 15:56
source share
6 answers

In the Find in Files dialog box (Ctrl + Shift + F) there should be a Search Parameters field. You should be able to enter the extensions of the fields you want to search in the field in this dialog box:

*.cs; *.aspx; *.ascx; 
+86
Nov 17 '09 at 15:59
source share

Instead of Ctrl + F , I think it's Ctrl + Shift + F , which gives you the ability to specify the types of files you want to learn.

+27
Nov 17 '09 at 16:02
source share

enter image description here

You can choose the default file types or enter your own. Regular expressions are available for complex searches.

+9
Aug 26 '13 at 13:22
source share

Another way to limit your file search is to select only specific sets of folders.

Setting folder sets for search

+7
Jun 27 '16 at 0:20
source share

I like to exclude js files using the following search: *.a*;*.cs*;

In most cases, I end up looking for material in aspx, cs, cshtml files, so this is very useful. Notice how I use *.cs* instead of *.c* , as the latter will select custom jquery files such as jquery.custom1234.js (which I usually use in most of my projects), of course, if you haven’t, you could just use *.c* .

+6
Mar 12 '12 at 19:40
source share

In the Find dialog box, go to "find options-> Look at these file types."

Enter your own string, for example *.cs, *.aspx, *.ascx . Click the Find All button.

+1
Nov 17 '09 at 15:59
source share



All Articles