Locating the active item in Solution Explorer

Scott Hanselman tweeted a link to Daniel Cazzulino's blog post about automatically synchronizing the Visual Studio Solution Explorer with the active item open in the editor. It's a great tip, but I personally have never been a fan of the Track Active Item option - I find that it slows down the IDE, causes distracting visuals, and often just isn't the behavior I want. I do, however, often want a way to manually sync up the Solution Explorer with my currently open item.

Fortunately, it's very easy to accomplish this with a very simple macro. The idea is very simple - just turn on the Track Active Item option that Daniel mentions, and turn it off again. It's a two-liner:

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

You can wire up that macro to a toolbar button and/or a keyboard hotkey, and (as ScottHa would say) bam, you're golden.

 

6 Comments

Comments have been disabled for this content.