Kevin Dente's Blog

The Blip in the Noise
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.

 

Published Wednesday, April 30, 2008 3:12 PM by kevindente

Filed under:

Comments

# re: Locating the active item in Solution Explorer@ Wednesday, April 30, 2008 6:25 PM

There appears to be an error in your blog. I see what seems to be a "new update", so I suspect that spambots have somehow infiltrated the system.

Jeff Atwood

# re: Locating the active item in Solution Explorer@ Wednesday, April 30, 2008 6:29 PM

Sorry, sir, I won't let it happen again. ;)

kevindente

# re: Locating the active item in Solution Explorer@ Friday, July 10, 2009 2:33 PM

thanks, this works nicely...

Paul Killick

# re: Locating the active item in Solution Explorer@ Thursday, July 16, 2009 6:45 AM

This is exactly what I needed and works great. I don't like having auto-tracking on, but sometimes get frustrated trying to find a code file in the solution when it's open in a window.

Paradroid

# re: Locating the active item in Solution Explorer@ Sunday, June 13, 2010 6:28 AM

Добавлю в закладки, интеретсно читать

kikus

# re: Locating the active item in Solution Explorer@ Sunday, June 13, 2010 6:24 PM

интеретсно написано

kikus