Thursday, December 9, 2010

File search: something I discovered in VS2010

Anyone who uses Visual Studio should be familiar with the Find in Files functionality (shortcut: Ctrl-Shift-F ).



Everyone has used it at some point, usually when you need to search all the files in your solution for a particular string. Those of you more adventurous may even have changed the file filter at the bottom, or searched using a regex. Pat yourself on the back, you are awesome.

Today i found a feature of it that has been there for a few years but i had never seen it before. This feature kicks ass. I used it to search specific folders on the file system that were outside of the solution. How many times have you thought to yourself, "hmmm.... where was that bit of code in that other project that did that certain thing...?", so you break out Windows File Explorer to search your base projects folder, only to be returned a bunch of crap? Well, you don't even have to leave your IDE to do it. Start up Find in Files, and on the Look in combo (that is usually set to Entire Solution or Current Document), click the ellipsis to the right of it:



and you will be presented with a dialog you never knew existed.



Just navigate your file system using the Available folders combo and its up-a-level button, and select whichever folders or drives you want to search from the listbox. Hit OK then Find All and Visual Studio will start searching for you.



Super user tips:
  • Don't forget that you can still use the file filter box, if searching large folder structures you may want to limit what files you are checking.
  • If you want to avoid that browse dialog, you can just enter a semi-colon delimited set of paths straight into the Look in combo
  • You can save a set of folders/paths for later use. In the browse dialog, select your paths, then enter a name for them in the Folder set combo and click Apply. You can then reselect that entry in later searches.

No comments: