Limit search to specified Folders or File Types in Visual Studio?

Viewed 40569

Is there a way to limit a search (via the "Find and Replace" dialog) in Visual Studio to specified folders or file types?

6 Answers

Yes, in the find/replace window you can:

  • specify the file types in the "Look at these file types" option
  • and choose the folders in the ... button of the "Look in" option.

Find and Replace Window

Fastest folder search in VS:

As said in other answers, there is no immediate way to limit your search to a given folder within the current solution. (There are at least 3 feature requests for this in visualstudio.uservoice.com that have all been closed for lack of upvotes.)

But here is the fastest workaround that I could find.
Works without leaving VS and with keystrokes only (no mouse action required):

  • 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".
  • Enter your search term, then press Tab to forward the cursor to the "Look in" field.
  • Press Ctrl-V to paste in the folder path from clipboard.

2020-Update: Actually you can select the folder (also the current directory with two clicks) and define file types in Microsoft Visual Studio Professional 2019, Version 16.7.5

Select current directory in find and replace dialog

Related