How to locate a file in Solution Explorer in Visual Studio 2010?

Visual StudioVisual Studio-2010Keyboard Shortcuts

Visual Studio Problem Overview


I have a huge solution with multiple projects. Sometime I need to navigate to a file in Solution Explorer. Using the VS 2010 'Navigate To' feature I can open any file by name in Visual Studio 2010 but I want to be able to select the file in Solution Explorer as well?

Visual Studio Solutions


Solution 1 - Visual Studio

There's an option to track the active (open and viewed) item in the solution explorer. If the file is in view, the file in the solution explorer will be selected.

Tools->Options->Projects and Solutions->Track Active Item in Solution Explorer

Solution 2 - Visual Studio

VS2012 added a new command called SolutionExplorer.SyncWithActiveDocument. The default shortcut for c# is Ctrl+[,S

This command will navigate to the active file in the Solution Explorer.

Also, it seems that you need to have the "Track Active Item in Solution Explorer" option turned off.

Solution 3 - Visual Studio

With ReSharper installed Shift+Alt+L will find the current file in Solution Explorer in Visual Studio 2008+.

Solution 4 - Visual Studio

I found the track option to be a little annoying.

I prefer to use DPack. It contain "Locate In Solution Explorer" operation, plus many other features (some are less powerful in VS2010, like their browsers), and it's free.

Note that ReSharper also have the locate feature that works batter than DPack's (in some cases, DPack's locate won't work if the file is collapsed behind folders), but you don't want to [buy ReSharper][rsprice] only for this [feature][rsfeat].

[rsprice]: http://www.jetbrains.com/resharper/buy/index.jsp "ReSharper license prices" [rsfeat]: http://www.jetbrains.com/resharper/features/index.html "ReSharper features"

Solution 5 - Visual Studio

Brian Schmitt has a great Locate File in Solution Explorer – Visual Studio Macro post for this. The macro is extremely simple and quick. Basically it toggles the setting

Tools->Options->Projects and Solutions->Track Active Item in Solution Explorer

so that the current file ends up selected in the Solution Explorer but, because it is not left on, you don't get irritated by Solution Explorer nodes being expanded for all the files you access.

Public Sub LocateFileInSolutionExplorer()
    DTE.ExecuteCommand("View.TrackActivityinSolutionExplorer")
    DTE.ExecuteCommand("View.TrackActivityinSolutionExplorer")
    DTE.ExecuteCommand("View.SolutionExplorer")
End Sub

Bind a Keyboard ShortCut to this custom macro to effectively create what should be a built-in Visual Studio feature.

Solution 6 - Visual Studio

Visual Studio 2012 has a new shortcut Ctrl [, S. Yes you have to type Ctrl [ and then release and then immediately type S (or click the little sync icon at the top of Solution Explored). It will synchronize to the item.

Of course you can change the shortcut. I think I'll try Alt+L for locate.

If you want to change the shortcut, it's command name under Options\Environment\Keyboard is SolutionExplorer.SyncWithActiveDocument.

Usually this is more useful than always tracking, which in older versions always was a disaster because it would track 100 items in a row and then be jumping all over the place...

Solution 7 - Visual Studio

If you have ReSharper and want to add "Locate in Solution Explorer" to the tab's context menu:

  1. Go to Tools -> Customize -> Commands -> Context Menu
  2. Select "Other Context Menus | Easy MDI Document Window".
  3. Click "Add Command".
  4. Choose "Resharper" -> "ReSharper_LocateInSolutionOrAssemblyExplorer" (in VS2019, the category name was changed to "Extensions")
  5. "OK" -> "Close"

Now, when right click on any tab and you'll see a new option: Locate in Solution Explorer.

UPDATE:

Following the comment from @jeremy-paskali, you can set a keyboard shortcut for this command:

  1. Go to Tools -> Customize -> "Keyboard..."
  2. Search for "ReSharper.ReSharper_LocateInSolutionOrAssemblyExplorer" in the "Show commands containing" field and select it.
  3. Review the currently assigned shortcuts in the drop down below.
  4. Make any changes, if needed.
  5. "OK" -> "Close"

Solution 8 - Visual Studio

I know its little too late, but hope it helps someone else. The best option now is to install Microsoft Visual Studio add on called - Productivity Power Tools.

http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef

With this comes "Solution Navigator" (alternative to Solution Explorer, with a lot of benefits) - which then you can use to filter the files to only show "Open". You can even filter files to show "Edited" and "Unsaved".

Solution 9 - Visual Studio

> In the event you want to only track the current file through a > keyboard shortcut - the activity is > "View.TrackActivityinSolutionExplorer" (assign keys here -> Tools - > Options - Environment - Keyboard)

Credit (James' comment)

This worked for me

Solution 10 - Visual Studio

There are several build-in ways you can accomplish this nowadays:

  1. Configure VS to track the active item in Solution Explorer: This can be accomplished by selecting "Track active item in Solution Explorer" at

> Tools > Settings > Projects and Solutions > General

enter image description here


  1. Use "Sync with active document": This can be accomplished in 2 ways.

    • Firing the SolutionExplorer.SyncWithActiveDocument command by using the default key combination CTRL+]+S

      CTRL+)+S if you happen to be using an AZERTY keyboard like me.

    • By using the "Sync with active document" button on top of the Solution Explorer. The button looks like 2 apposing arrows on top of each other.

      If you're version is older then VS2019 Version 16.10.2 then this button looks like this:
      enter image description here

      From VS2019 Version 16.10.2 onwards this button will look like this:
      enter image description here

Solution 11 - Visual Studio

In Visual Studio 2010 you can turn on the "Track Active Item in Solution Explorer" option. This will mean whenever you switch between documents the new document gets selected in Solution Explorer. This can be irritating if your solution has lots of folders, because as you move around files in your solution all the folders will be left open.

Visual Studio 2012 introduced the new "Sync with Active Document" feature. Three is a button for it at the top of Solution Explorer, or you can use the shortcut Ctrl + [, S.

screenshot of sync with active document button

Solution 12 - Visual Studio

This is actually built in to visual studio without the need for ReSharper (which I love BTW).

http://blogs.msdn.com/b/zainnab/archive/2010/03/29/track-active-item-in-solution-explorer-vstipproj0011.aspx

Solution 13 - Visual Studio

If you want to select the file in the solution explorer on command and don't want to install anything then I would recommend this macro.

I've tested it, setting the shortcut to Alt+T, and I can confirm that it works with VS 2010.

Thanks to Dan Vanderboom for writing it.

Solution 14 - Visual Studio

For Visual Studio 2017 using a French AZERTY keyboard the command is the same as stated by Aaron Carlson but the keyboard shortcut is different.

The AZERTY keyboard shortcut to navigate to the active file for c# is Ctrl+),Ctrl+S

I checked the shortcut hadn't changed for QWERTY users in VS2017 on this page http://visualstudioshortcuts.com/2017/

Solution 15 - Visual Studio

Visual Studio doesn’t offer an easy way to locate the current file you’re editing in the Solution Explorer on demand. You can set the solution explorer to always stay in sync with this simple setting:

Tools > Options > Projects and Solutions > General. Check “Track active item in Solution Explorer”.

Thanks to Cory House

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAmitabhView Question on Stackoverflow
Solution 1 - Visual StudioJeff MercadoView Answer on Stackoverflow
Solution 2 - Visual StudioAaron CarlsonView Answer on Stackoverflow
Solution 3 - Visual StudioRob WillisView Answer on Stackoverflow
Solution 4 - Visual StudioHuBeZaView Answer on Stackoverflow
Solution 5 - Visual StudioMartin HollingsworthView Answer on Stackoverflow
Solution 6 - Visual StudioSimon_WeaverView Answer on Stackoverflow
Solution 7 - Visual StudioShayView Answer on Stackoverflow
Solution 8 - Visual StudiofriendView Answer on Stackoverflow
Solution 9 - Visual StudiopingoView Answer on Stackoverflow
Solution 10 - Visual Studiokristofvdj88View Answer on Stackoverflow
Solution 11 - Visual StudiothelemView Answer on Stackoverflow
Solution 12 - Visual StudioRazorView Answer on Stackoverflow
Solution 13 - Visual StudioRobert WhitleyView Answer on Stackoverflow
Solution 14 - Visual StudioPhilGView Answer on Stackoverflow
Solution 15 - Visual StudioMohamedHarmoushView Answer on Stackoverflow