76

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 6

90

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

5
  • 6
    Just to be clear, the "Look at these file types" option is hidden behind the "Find options" expander button.
    – itowlson
    Apr 27, 2009 at 23:44
  • 2
    Thank you. My find/replace window defaulted to "Quick Find". When you mentioned these options I realized that there is a drop down to switch to "Find In Files".
    – Bryan
    Apr 27, 2009 at 23:49
  • 5
    [ CTRL ] + [ SHIFT ] + [ F ]
    – Sergey
    Jul 27, 2015 at 19:05
  • 3
    correct, but way unconvenient. selecting directory in a tree and hitting ctrl+f is way comfortable. vs loses to open source again :(
    – sKopheK
    Feb 19, 2016 at 7:02
  • 4
    In VS 2017 you can right click the folder in the solution explorer and left click copy path and the paste it into the Look in text box. Much faster than searching for the folder.
    – devSpeed
    Aug 1, 2017 at 20:48
19

I can't believe this issue still exists in VS2015. We have a solution explorer folder tree. Why is "Current Selected Folder" not an option in the drop down. The "..." doesn't default to starting in the solution folder, I have to browse across the network to t the share, then drill down through all the folders to get at a folder that is ALREADY right there and selected in the solution explorer. Dreamweaver has had this functionality for its search for at least a decade (maybe longer).

5
  • 1
    I think the same. Not only Dreamweaver, almost any other IDE I've used has that option. I got used to it from JetBrains IDEs that I use for other languages, like PhpStorm and PyCharm and now almost can't believe VS being the monster it is doesn't have it.
    – slashCoder
    Sep 1, 2016 at 20:34
  • Yeah, it makes no sense at all. If I want to search the filesystem I just fire up something like TotalCommander which is much faster anyway. VS should allow me to choose directories in the current solution first, and only then offer to navigate beyond those.
    – s.m.
    Sep 29, 2016 at 9:21
  • I totally agree with you on this. There should be a more intuitive process in drilling down to a specific folder that is already within the current solution.
    – klewis
    Apr 6, 2017 at 21:55
  • 100% agreed. I use this all the time in Netbeans. Utterly ridiculous it's not here
    – Manachi
    Sep 4, 2017 at 8:40
  • I agree. I would like a right click menu option when I click in the solution explorer to Search from Here or Search this Folder. Jun 11, 2019 at 19:54
18
  1. Click Find in Files
  2. Choose search folders three dots button "..."
  3. Choose desired folder
  4. Verify folder name and click desired action

Click Find in Files

Choose search folders

Choose desired folder Verify folder name and click desired action

10

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.
4

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

0

While the Choose Search Folders works, it could be much better. I would really like to choose folders to exclude as well as include because sometimes folders are nested. You may want a folder but only some of the subfolders.

But by far the worst inconvenience is that it is not stored with the solution. If I go to the trouble of defining a search, and close VS, then reopen, I have to define it all over.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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