Track Active Item in Solution Explorer

Tips Search

Track Active Item in Solution Explorer

  • Comments 16

Menu:  Tools -> Options -> Projects and Solutions –> General
Commands:  View.TrackActivityinSolutionExplorer
Versions:  2005,2008, 2010
Published:  3/29/2010
Code:  vstipProj0011

 

Note: Several people have asked if you can turn this feature on and off at will. You can if you bind the View.TrackActivityinSolutionExplorer command to a keyboard shortcut.

 

By default, VS2010 will track the current file you are editing in Solution Explorer.  It looks like this:

image

 

 

Notice that the current file being edited is also selected in Solution Explorer automatically.  This is a great way to keep track of where you are in the solution when you are working with a lot of files.  You can turn it off if you want.  Just go to Tools -> Options -> Projects and Solutions -> General -> "Track Active Item in Solution Explorer" and uncheck the option to turn this feature off.

image

  • I've missed that feature since VS 2008, even though it was sometimes annoying. Good to have the choice.

  • Although this sounds great in theory, it is almost completely useless in practice, so I quickly turn it off again.

    For example: I have a bunch of files open. I decide to close some of the files, since I do not need them open anymore. I click on one of the files (solution explorer jumps to the file), close it (solution explorer jumps to whatever file is next in the open-files-list), etc. Annoying.

    Even more problematic: I am looking for a file. I navigate to where I believe the file is located and open it. After opening it I see it is the wrong file (or alternatively after a small edit I want to change another file where I currently am). I close the file. Solution explorer jumps to the next file in the open-files-list, which can often be in a completely different location in the solution. So I have to find where I was before, etc.

    Eclipse solves this in a much better way, by having a toggle button for tracking the file on/off directly on the solution explorer.

    Luckily, there is also Resharper, which solves this problem by having a key binding for locating the current file in the solution explorer.

  • Hey Daniel :)

    I think you are getting the tracking in Solution Explorer confused with the File Tab Channel actions.  The tracking in Solution Explorer isn't proactive it only reacts to where you are at at any given time.  Kind of like a GPS that updates when you move.  The GPS can't move you it just shows you where you currently are.

    When you close a file on the File Tab Channel in VS2008 it will jump to the far left-most tab in the list.  VS2010 will do this as well UNLESS you turn on the ability to insert documents to the right of existing tabs in Tools -> Options -> Environment -> Documents.  With this setting on it will jump to the far-right tab instead.

    Is that what you are referring to?

  • I also turn this off because it leaves my Solution expanded all over the place as I open and close files from lots of projects throughout the day. Once there's a right-click "Collapse everything below this project or folder", then this option becomes more useful. But I still haven't found that command in VS 2010.

  • ohh nice one MarcT.  There definitely SHOULD be something like that in Solution Explorer.  I'll forward this feedback to the team.

  • Hi Zain,

    No, I'm getting nothing confused. I was trying to explain why the option which seems nice in theory fails in practice with any non-trivial solution size. Apparently my relatively short descriptions of why it doesn't work weren't enough.

    The problem is precisely this interaction between the file tab channel and the solution explorer when closing a file tab.

    When I close a file, Visual Studio automatically switches to some different file. If I have this option on, the solution explorer then jumps to this file. Most of the time (but not always), this isn't where I want the solution explorer to be.

    So with Visual Studio, either I never close files, or I turn the option off. Luckily there's Resharper, which fixes this by having the "Locate current file in Solution Explorer" shortcut.

    As an alternative, there's also http://dvanderboom.wordpress.com/2008/03/21/visual-studio-macro-track-item-in-solution-explorer-on-demand/ or http://www.brianschmitt.com/2010/01/locate-file-in-solution-explorer-visual.html

  • Hey Daniel,

    Ahh.  I see what you are saying now.  Makes sense.

    Z

  • hejdig.

    @FrankDeGroot: I have this in my VS2008.  IIRC it was there in 2005 too.

    @ MarcT: Install DPack from http://www.usysware.com/dpack/.  It gives you a shortcut for collapsing the whole solution tree.  One has to stand at the root though.  The whole shortcut then goes ctrl-alt-L home propertieskey E.  Probably mappable to a faster key if you want.  Dpack also gives you some other functionality which are a must-have IMHO.

    @zainab: The trackactiveitem sometimes stops working in my 2010.  It works for a while and then just quits.  Turning the feature off and on again doesn't help.  It looks like it has something to do with how the file was opened, through Gototdefinition or opening from Solutionexplorer or through Find.  Opening the already opened file in Solution explorer seems to do the trick.

    /OF

  • Is there any way to make it actually visible in the Solution Explorer?

    I only see a very subtle shade of grey if I look at the monitor from just the right angle.  Cool colours, but useless.  Cannot see a way to change.

  • Hello, i missed this feature in VS 2008, thank you for solution.

  • Is there a shortcut key / macro / right click option to collaspe the expanded list in  Solution explorer  in VS2010

  • Tragically, no.  But the power tools do have this ability with Solution Navigator:

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

  • "Daniel Rose" has spoken exactly my mind. This feature is actually annoying for me too most of the time...so I don't want to enable/disable the global vs settings, but just like in resharper(I guess), I'd like to track/locate JUST the current file in the solution-explorer, through a shortcut. Is there a way to do that or any alternate tweak or something??? It would really help, and ofcourse save a lot of time too!!!

  • Great, by default it should be checked, its pretty much annoying otherwise.................

    As far as i remember, by default it was checked in VS 2005..........

  • Well, it turns out you CAN bind this feature to a keyboard shortcut via the View.TrackActivityinSolutionExplorer command.  I've updated the post with the command in it for reference.

Page 1 of 2 (16 items) 12
Leave a Comment
  • Please add 2 and 6 and type the answer here:
  • Post