47

I come from a Java background and have spent many years using Eclipse. One feature that I miss when using Visual Studio (2008) is that the class view does not automatically refresh when I change class. In Eclipse it has a (class) 'Outline' window which represents the current class and shows methods/properties etc, this always updates to the class one is using.

The equivalent 'Class View' in VS does not automatically refresh according to the current class I am visiting. I wondered if anyone knew a way to make this happen?

Ideally I'd like the VS view to be as similar to Eclipse as I could get it, but this one feature would be great.

Thanks in advance, Will

2
  • Eclipse is not alone, Netbeans does the same. Apr 28, 2015 at 16:29
  • old question, but important! The proposal to bind to a key using Tools->Options->Environment->Keyboard and see if you can find "View.SynchronizeClassView". is useful however, it is broken in many versions of Visual Studio including VS 2019 16.4.3. As a workaround if you are using Resharper (and most people do) you can use the file structure window which autosyncs and pretty much provides the same info if you have 1 file per class. Jan 30, 2020 at 14:32

14 Answers 14

50

After reading kingmaxxx's reply, I went to Tools->Options->Environment->Keyboard and bound Ctrl+Shift+C to View.SynchronizeClassView in Text Editor view. This seems to supplant and supplement the original behavior (View.ClassView), as it will display ClassView if it wasn't visible and focus on the current class.

(Visual Studio 2008)

8
  • Broken in VS2012 for MFC Projects - Not to be fixed connect.microsoft.com/VisualStudio/feedback/details/780808/… Nov 12, 2014 at 13:04
  • 1
    In VS2013 what I get is that what is selected is the project, not the class.
    – Avi
    Dec 26, 2014 at 13:02
  • 2
    All I get in VS2013 is the 'Class View' focused or opened.
    – AMissico
    Mar 16, 2015 at 22:20
  • 4
    @Avi - an additional click is required to scope the class view to a specific member - click on the name of any class, property or method in the Text Editor view before synchronizing. The Class View will then highlight the correct member.
    – rmirabelle
    Aug 27, 2015 at 15:05
  • 2
    I was using this alot , but it is broken again in VS 2019 16.4.3 Jan 30, 2020 at 15:13
21

For Visual Studio 2005

I found a solution that does not update the view automatically, but at least you get a context entry that helps:

http://blogs.msdn.com/ansonh/archive/2005/12/09/502020.aspx

You can also define a shortcut key:

Tools->Options->Environment->Keyboard and see if you can find "View.SynchronizeClassView".


Oh, just for laughs - here is the answer of Microsoft: http://msdn.microsoft.com/en-us/library/2dae8h2s.aspx

...you can select any symbol in the Code Editor and locate it instantly...

After 7 Steps...

"Class View automatically scrolls to the location of the selected symbol in its hierarchy. "

4
  • 1
    For clarification, the View.SynchronizeClassView keyboard shortcut DOES work with VS2010 RC.
    – Jaxidian
    Mar 26, 2010 at 17:31
  • 6
    The Microsoft doc really is (presumably unintentionally) funny. How they consider such a slow and manual process to be 'instant and automatic' beggers belief.
    – Sam
    Apr 18, 2011 at 16:45
  • 2
    Sam, I agree. Synchronizing Class View is a natural need. If they would really use their own compilers and tools (which they don't) such questions wouldn't have to be asked. And the documentation would be better. Mar 12, 2013 at 10:12
  • I was using this alot , but it is broken again in VS 2019 16.4.3 Jan 30, 2020 at 14:28
14

The best way is to create a context menu when you right-click on a type in code editor. Tools->Customize Click on 'Commands' tab. Select Context Menu radio button, and select "Editor Context Menus | Code Window". Then "Add Command" and select View->Synchronize Class View.

Now whenever you right-click on a type, you can select "Synchronize Class View". It's the very top context-menu item. Looks like this: Context-menu

10

I can't help you with the class view, but maybe you want to give the solution explorer a try? You can synchronize this one via:

tools -> options -> projects and solutions -> general
enable "track active item in solution explorer"
1
  • This is what I used! The class view synchronise keyboard shortcut would not work with various bindings.
    – Chucky
    Aug 6, 2015 at 8:29
3

The problem with View.SynchronizeClassView is that is doesn't work when a class is being viewed from a virtual folder.

2

based on kingmaxxx's response I found that you can add a button to your toolbar to do the same:

Tools|Customize -> Commands[tab] -> View[Categories]

Grab the Synchronize Class View button and drag it to one of your toolbars.

1

I haven't had time to get this to work yet, but there is code for a VS2003/2005 add-in to auto-sync here (see the post marked "answer").

Incidentally, this question seems to be a duplicate of this one.

1

For Visual Studio 2017, CodeMaid Spade comes to the rescue quite perfectly.

Codemaid VS Extension

At first, I couldn't find the equivalent to 'Class View'. It's called Spade.

It auto-syncs to the currently open class.

0

I don't know of any ways to do this but I agree that it would be a nice feature.

You can track items in Solution Explorer though (Options->Project and Solutions->General->Track Active Item in Solution Explorer).

0

Also coming from java (Eclipse), I missed the outline (Class viewer). I have tried many solutions and the best I found is to use the CODEMAID extension.

It also provides a lot of other tool but you are free not to use it!

0

It looks like this small CodeNav extension does this work too: https://marketplace.visualstudio.com/items?itemName=SamirBoulema.CodeNav

Yes, "Codemaid -> Spade" looks greater, but it's not just viewer - it has IMHO rather dangerous code drag feature, which could not be disabled unfortunatelly.

P.S. I wonder MS staff themselves doesn't need this feature?!

0
-2

Coming from Eclipse you will miss a lot of such features. What I miss most for navigation is an easy go to type, go to inheritor and so forth. Other features, such as nUnit support are not part of the vanilla Visual Studio, too. Here is a list of Add-Ins that bridge the gap:

But here comes the drawback: They all charge you money (TestDriven.net only for commercial use). However, they all offer free trials.

2
  • IIRC you can /go to type/ with shift-F12.
    – Justin R.
    Jul 12, 2009 at 16:39
  • Ctrl+F12, Shift+F12, or make your custom shortcuts
    – tatigo
    Oct 4, 2017 at 16:29
-3

Tools Menu -> Options

Then, in the "Project And Solutions" area, you can select to track the active item.

2
  • Verified on Visual Studio 2008 (w/ Resharper 4.1)
    – dance2die
    Feb 13, 2009 at 17:48
  • 3
    This works for Solution Explorer, but not Class View, which is what the OP is looking for.
    – Justin R.
    Jan 22, 2010 at 22:53
-5

With Resharper, ALT+SHIFT+L goes to the current file in Solution Explorer.

1
  • 1
    It works only for Resharper so I don't consider this to be an answer although it works with my visual studio + resharper 4.1
    – dance2die
    Feb 13, 2009 at 17:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.