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

Find File in Solution

By , 28 Mar 2010
 

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)

About the Author

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

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 5memberluongnghithaicuc3 Dec '12 - 19:21 
GeneralMultiple tab searchmemberLeonardoX223 May '11 - 23:36 
GeneralRe: Multiple tab searchmemberAlex Blekhman4 May '11 - 7:54 
GeneralMy vote of 5memberLeonardoX223 May '11 - 23:27 
QuestionCool tool, but can we add more columns to it?memberBill David26 Aug '10 - 19:58 
AnswerRe: Cool tool, but can we add more columns to it?memberAlex Blekhman27 Aug '10 - 3:11 
GeneralMy vote of 5memberDouble Dose8 Jul '10 - 10:06 
QuestionKeyboard shortcut for closing Find File-toolmemberSnakefoot5 Apr '10 - 23:32 
AnswerRe: Keyboard shortcut for closing Find File-toolmemberAlex Blekhman5 Apr '10 - 23:53 
GeneralRe: Keyboard shortcut for closing Find File-toolmemberRolf Kristensen5 Apr '10 - 23:54 
GeneralRe: Keyboard shortcut for closing Find File-toolmemberAlex Blekhman6 Apr '10 - 0:05 
GeneralCrash with VS2005memberKyleK15 Mar '10 - 21:38 
GeneralRe: Crash with VS2005memberAlex Blekhman15 Mar '10 - 22:35 
GeneralRe: Crash with VS2005memberKyleK16 Mar '10 - 3:30 
GeneralRe: Crash with VS2005memberAlex Blekhman16 Mar '10 - 3:37 
GeneralRe: Crash with VS2005memberKyleK24 Mar '10 - 1:32 
GeneralRe: Crash with VS2005memberAlex Blekhman24 Mar '10 - 2:13 
GeneralRe: Crash with VS2005memberAlex Blekhman27 Mar '10 - 6:40 
GeneralRe: Crash with VS2005memberFrank Aurich28 Mar '10 - 20:39 
GeneralRe: Crash with VS2005memberAlex Blekhman28 Mar '10 - 21:26 
GeneralOpending a file by pressing "Enter" or double clicking on a file closes the addin [modified]memberDavid Lind2 Dec '09 - 6:33 
GeneralRe: Opending a file by pressing "Enter" or double clicking on a file closes the addinmemberAlex Blekhman2 Dec '09 - 7:09 
GeneralRe: Opending a file by pressing "Enter" or double clicking on a file closes the addinmemberDavid Lind2 Dec '09 - 7:17 
GeneralRe: Opending a file by pressing "Enter" or double clicking on a file closes the addinmemberAlex Blekhman6 Dec '09 - 10:38 
GeneralRe: Opending a file by pressing "Enter" or double clicking on a file closes the addinmemberDavid Lind7 Dec '09 - 5:33 
GeneralRe: Opending a file by pressing "Enter" or double clicking on a file closes the addinmemberSergey Rybalkin10 Jan '10 - 5:47 
GeneralRe: Opending a file by pressing "Enter" or double clicking on a file closes the addinmemberAlex Blekhman10 Jan '10 - 20:37 
GeneralTool crashes oftenmemberaliascodeproject5 Oct '09 - 21:49 
GeneralRe: Tool crashes oftenmemberAlex Blekhman5 Oct '09 - 23:56 
GeneralRe: Tool crashes oftenmemberaliascodeproject6 Oct '09 - 1:55 
GeneralRe: Tool crashes oftenmemberAlex Blekhman6 Oct '09 - 3:06 
GeneralRe: Tool crashes oftenmemberaliascodeproject6 Oct '09 - 21:17 
GeneralRe: Tool crashes oftenmemberAlex Blekhman6 Oct '09 - 21:37 
GeneralRe: Tool crashes oftenmemberaliascodeproject7 Oct '09 - 2:46 
GeneralRe: Tool crashes oftenmemberAlex Blekhman7 Oct '09 - 3:21 
GeneralNice...memberPaul Selormey3 Oct '09 - 2:12 
GeneralRe: Nice... [modified]memberAlex Blekhman3 Oct '09 - 2:36 
GeneralRe: Nice...memberPaul Selormey3 Oct '09 - 3:54 
GeneralRe: Nice...memberAlex Blekhman3 Oct '09 - 4:18 
GeneralRe: Nice...memberPaul Selormey3 Oct '09 - 4:37 
GeneralRe: Nice...memberAlex Blekhman3 Oct '09 - 5:28 
GeneralRe: Nice...memberPaul Selormey3 Oct '09 - 5:42 
GeneralRe: Nice...memberAlex Blekhman3 Oct '09 - 6:00 

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

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