Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Find File in Solution

0.00/5 (No votes)
28 Mar 2010 1  
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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here