Select Current Item in Visual Studio Solution Explorer

UPDATE: BAH! I was sort of wrong about this. Turns out, as noted in comments, that if you use the solution I outline, then when you hit the key combo, it re-enables the "Track Active Item in Solution Explorer" option that you want disabled. So if you do this, you need to hit the key TWICE - once to select the current item, once to turn the setting back off. If I find a better solution to the problem I'll update this post.


When I'm working in Visual Studio, I generally turn off the option to automatically track the curent item in the Solution Explorer. I don't like the Solution Explorer hopping about as I switch from file to file. Sometimes I do like to find whatever I'm working on, though, and that can be painful if you do it manually.

Fortunately, Visual Studio has a command you can bind to a keystroke to do exactly that: View.TrackActivityinSolutionExplorer

It's not bound to a key by default, but you can go to Tools -> Options and bind it yourself. I've got mine bound to Ctrl+Shift+Alt+T. ('T' for 'Track' but you might want something more memorable for you.)

View.TrackActivityinSolutionExplorer key binding

posted on Wednesday, August 12, 2009 8:19 AM | Filed Under [ Visual Studio ]

Comments

Gravatar # re: Select Current Item in Visual Studio Solution Explorer
by Matt at 8/12/2009 11:14 PM
Another option is to use CTRL + ALT + L - that will highlight the current file you're editing in the solution explorer.
Gravatar # re: Select Current Item in Visual Studio Solution Explorer
by Justin at 8/13/2009 8:13 AM
The CTRL+ALT+L is the command to bring up the solution explorer but it only selects the current file if you don't turn off the tracking of the active file in solution explorer.
Gravatar # re: Select Current Item in Visual Studio Solution Explorer
by PHenry at 8/13/2009 11:00 AM
I do the same like you, turn off that blasted setting. However, something you might not know about, that setting you are putting a keystroke too (I did the samething) is a toggle-like switch. Meaning, you have to remember to turn it off AFTER you turn it on. What do I mean? Goto Tools, Options, Projects and Solutions, then look at the "Track Active Item in Solution Explorer", exit out of there, then click your hotkey....now go BACK to the tools, options, etc. You'll be surprised to see the option is opposite of what you were just looking at before the keystroke.

So this is a great keystroke, when used times 2. I found this one out the frustrating way.
Gravatar # re: Select Current Item in Visual Studio Solution Explorer
by Travis Illig at 8/13/2009 11:06 AM
@PHenry - ARGH! You're right. It does toggle that thing. I've updated the blog post accordingly. LAME!
Gravatar # re: Select Current Item in Visual Studio Solution Explorer
by PHenry at 8/13/2009 11:52 AM
re ARGH & LAME!
Yup, I agree! But at least we now know! :> haha In the beginning I couldn't figure out why VS wasn't "remembering" my settings or why it kept "restoring" it? Then somehow/someway I figured out it was a toggle switch. The keystroke you suggest is awesome cause now you can easily flip it on, set the focus to what you want, then flip it off again to reset it back to normal.

The main point of your blog remains, use the keystroke, that's an awesome suggestion IMHO! :>
Gravatar # re: Select Current Item in Visual Studio Solution Explorer
by online backup at 9/2/2009 12:25 AM
Another option is CTRL + ALT + L,as it will highlight the file of siteexplorer you are working .
Gravatar # re: Select Current Item in Visual Studio Solution Explorer
by Travis Illig at 9/2/2009 7:41 AM
As mentioned in an earlier comment, CTRL + ALT + L only displays the Solution Explorer, and that only highlights the file if you've not turned off the active file tracking... so, unfortunately, that's not a solution for the problem here.
Gravatar # re: Select Current Item in Visual Studio Solution Explorer
by Stefanus Du Toit at 9/4/2009 8:58 AM
You can easily avoid the double-tapping by defining a macro to run the command twice, e.g.:

Sub FindInSolutionExplorer()
DTE.ExecuteCommand ("View.TrackActivityinSolutionExplorer")
DTE.ExecuteCommand ("View.TrackActivityinSolutionExplorer")
End Sub

Then you can bind that macro to a keybinding.
Comments have been closed on this topic.