Click here to Skip to main content
Click here to Skip to main content

Find File in Solution

, 28 Mar 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
Find any file in solution using incremental search and advanced filtering

Main Window

Find File in Solution main window

Contents

Introduction

Finding a file in a big solution may be a hard and daunting task. It is especially true when the solution contains tens of projects organized in complex hierarchy. Unfortunately, Visual Studio IDE doesn't provide a convenient way to find an arbitrary file in the solution. Find File in Solution AddIn solves this annoying problem.

Installation

Installation of Find File in Solution AddIn is very simple: just copy the binary files in one of the predefined folders where Visual Studio looks for add-ins. This article explains the matter in great details: INFO: Default .AddIn file locations for Visual Studio add-ins. I personally prefer the following path:

  • Windows XP: "C:\Documents and Settings\<username>\<mydocuments>\Visual Studio 2005\AddIns" (2008 for Visual Studio 2008)
  • Windows Vista/7: "C:\Users\<username>\Documents\Visual Studio 2005\AddIns" (2008 for Visual Studio 2008)

Note for Visual Studio 2005 users: Open SlnFileFind.AddIn file with Notepad and change HostApplication/Version nodes value to 8.0:

<Extensibility xmlns="http://schemas.microsoft.com/AutomationExtensibility">
    <HostApplication>
        <Name>Microsoft Visual Studio</Name>
        <Version>8.0</Version>
    </HostApplication>
    ...
</Extensibility>

When the files are copied to a folder, restart Visual Studio to reload its add-ins.

Visual Studio Command "open (of)" - Almost Right

Actually, VS IDE allows to open an arbitrary file without spelunking into solution projects. It is done with wonderful "Find" combo box located on the Standard toolbar. Ctrl+D shortcut brings keyboard focus to the combo. Then, just type '>' symbol (without quotes) to enter the universe of VS IDE internal commands. The command that opens a file is, well, open (or short alias: of). After the command name, you just start typing a filename and drop-down list will show the available files:

VS IDE `of' command

VS IDE `of' command in action

Unfortunately, there is one fundamental flaw in this feature: you must know the filename beforehand and you must type it exactly how it starts. Otherwise, of command won't find anything. This limitation makes the of command practically useless.

Using Find File in Solution

Well, usage is very straightforward and simple. Open the Find File in Solution main window either from main menu or by hitting Ctrl+Alt+Y shortcut and start typing a filename.

Find File in Solution menu

Find File in Solution menu

When you are satisfied with the search result, then press TAB or DOWN ARROW key to select files. You may select several files by holding SHIFT key or using CTRL key and mouse. File selection works exactly as in a regular Windows Explorer window. Press ENTER to open selected files or ESC to dismiss the dialog.

The Find File in Solution main window is a regular Visual Studio tool window. It means that it can be floating, docked to either side or autohidden as any other IDE window. Using Ctrl+Alt+Y shortcut or selecting Find File in Solution item from the main menu will always bring keyboard focus to the search box.

Note: Upon solution opening Find File in Solution starts scanning solution tree for files. It happens in a separate worker thread rather than in the main IDE thread in order to preserve IDE responsiveness. That's why if the solution is very big, then Find File in Solution may show empty window for several seconds immediately after the solution is opened. It is normal behavior. Regardless of that, you can start typing the search string right away. When all files are fully loaded, Find File in Solution main window will be populated with correct results. It takes a huge solution to see this effect, though.

Following are the examples of possible search patterns.

Simple Search

Simple Search

Typing a string in the search box brings all files that contain this string in their filename.

Multiple Search

Multiple Search

Typing multiple substrings brings all files that contain all of the substrings in their filename.

Excluding Files From Search

Negative Match

Prepend substrings with hyphen to exclude matching files from search results.

Searching by Full Path

By default Find File in Solution searches by filename. You may search by full path by starting search string with backslash. It may be useful for finding only those files that belong to a certain directory.

Search by path

Sorting Results

Sorting Results

Search results can be sorted by clicking on column header.

Tweaking Find File in Solution

Tweaking is not recommended for ordinary users but sometimes it may be useful for a user with special needs or extremely fast/slow typing person. The secret of Find File in Solution responsiveness and smooth unstrained work is that the search is not performed immediately as user types a search string. There is a small delay before the search kicks in. It is indistinguishable for humans but significant for a machine, so it can spare redundant CPU load.

In order to show tweak settings, type "settings" string (without quotes) in search box and press Ctrl+Enter.

Settings

Default delay value is 300 msec. Minimal value is 0 msec, maximal is 1000 msec.

History

  • 3rd October, 2009
    • Initial version
  • 12th October, 2009
    • Bug fix: If user tries to open a file that exists in a project but is deleted from disk, then FileNotFound exception is not caught and IDE crashes.
  • 24th October, 2009
    • Rare crash that happens during file search has been fixed
    • Performance has been improved
    • Files that belong to multiple projects will have "(Multiple projects)" string in Project column in the file list. Also, file's tool-tip for such items will list all projects that the file belongs to.
  • 5th December, 2009
    • After user opens selected files add-in's window closes only if it is in floating mode. For all other modes "Find File in Solution" window will stay opened.
    • When "Find File in Solution" is invoked, its search box is initialized with currently selected text in VSE IDE from document windows, Output pane, etc.
    • "Find File in Solution" monitors solution changes (add/remove/rename files and projects).
    • Tweak dialog has additional option - rescanning solution files on demand. Some users reported that occasionally "Find File in Solution" loses its file list. This option should remedy the problem until proper fix is found.
  • 9th December, 2009
    • Bug fix: No files are listed in add-in's window when some of the projects in solution failed to load
  • 27th February, 2010
    • Bug fix: If a file appears directly under solution folder, i.e. doesn't belong to any project, then this file is not listed in search results
  • 27th March, 2010
    • Bug fixed: Sometimes internal list of files gets out of sync with GUI. It may lead to an unhandled exception in VS IDE
    • Improved: On solution/project events only relevant cases are handled

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Alex Blekhman
Software Developer
Australia Australia
More than ten years of C++ native development, and counting.
 
Smile | :)

Comments and Discussions

 
Generalis there any C# version of this tool? PinmemberSouthmountain19-Jul-14 10:51 
Questionvisual studio 2010? PinmemberTittle Joseph1-May-14 1:59 
GeneralMy vote of 5 Pinmemberluongnghithaicuc3-Dec-12 20:21 
GeneralMultiple tab search PinmemberLeonardoX224-May-11 0:36 
GeneralRe: Multiple tab search PinmemberAlex Blekhman4-May-11 8:54 
GeneralMy vote of 5 PinmemberLeonardoX224-May-11 0:27 
QuestionCool tool, but can we add more columns to it? PinmemberBill David26-Aug-10 20:58 
AnswerRe: Cool tool, but can we add more columns to it? PinmemberAlex Blekhman27-Aug-10 4:11 
GeneralMy vote of 5 PinmemberDouble Dose8-Jul-10 11:06 
QuestionKeyboard shortcut for closing Find File-tool PinmemberSnakefoot6-Apr-10 0:32 
AnswerRe: Keyboard shortcut for closing Find File-tool PinmemberAlex Blekhman6-Apr-10 0:53 
GeneralRe: Keyboard shortcut for closing Find File-tool PinmemberRolf Kristensen6-Apr-10 0:54 
GeneralRe: Keyboard shortcut for closing Find File-tool PinmemberAlex Blekhman6-Apr-10 1:05 
GeneralCrash with VS2005 PinmemberKyleK15-Mar-10 22:38 
GeneralRe: Crash with VS2005 PinmemberAlex Blekhman15-Mar-10 23:35 
GeneralRe: Crash with VS2005 PinmemberKyleK16-Mar-10 4:30 
GeneralRe: Crash with VS2005 PinmemberAlex Blekhman16-Mar-10 4:37 
GeneralRe: Crash with VS2005 PinmemberKyleK24-Mar-10 2:32 
GeneralRe: Crash with VS2005 PinmemberAlex Blekhman24-Mar-10 3:13 
GeneralRe: Crash with VS2005 PinmemberAlex Blekhman27-Mar-10 7:40 
GeneralRe: Crash with VS2005 PinmemberFrank Aurich28-Mar-10 21:39 
GeneralRe: Crash with VS2005 PinmemberAlex Blekhman28-Mar-10 22:26 
GeneralOpending a file by pressing "Enter" or double clicking on a file closes the addin [modified] PinmemberDavid Lind2-Dec-09 7:33 
GeneralRe: Opending a file by pressing "Enter" or double clicking on a file closes the addin PinmemberAlex Blekhman2-Dec-09 8:09 
GeneralRe: Opending a file by pressing "Enter" or double clicking on a file closes the addin PinmemberDavid Lind2-Dec-09 8:17 
Cool, thanks.
 
BTW, great addin

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141220.1 | Last Updated 28 Mar 2010
Article Copyright 2009 by Alex Blekhman
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid