Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include only certain file types when searching in Visual Studio

Often when I want to search through my code in Visual Studio, I know the thing I'm looking for is in some C# code. However, as I've used the same variable name in a JavaScript file, I have to wade through all those search results too. This gets even worse when the text I'm looking for is also used in a third-party JavaScript library that we've brought into the project: this can result in hundreds of search results.

To compound things, our designers include HTML mock-ups of the pages in the same project, so I often find I'm hitting loads of search results in there too.

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

Is there any way to do any of the following:

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

I suspect not, in which case is there any crafty way of working around this?

like image 766
teedyay Avatar asked Nov 17 '09 15:11

teedyay


People also ask

How do I search for a specific file type in Visual Studio code?

Click the File Search on the status bar on the bottom of the VSCode IDE. You can also use a keyboard shortcut, Control+Shift+P in Windows or Command+Shift+P on MacOS, to open the command palette and choose Now: Global Search from the list.

How do I search for a specific folder in Visual Studio?

In Solution Explorer select the folder to search within. Press Ctrl-C (copies folder path to clipboard). Press Ctrl-Shift-F to open "Find in Files".

How do I search for a string in all Files in Visual Studio?

The new experience is available by searching for “Find in Files” or “Replace in Files” in Visual Studio search (Ctrl+Q by default). You can also get to these commands with Ctrl+Shift+F and Ctrl+Shift+H respectively.


1 Answers

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

*.cs; *.aspx; *.ascx;  
like image 88
Matthew Jones Avatar answered Sep 26 '22 08:09

Matthew Jones