Synchronize Class View


A week or so ago a developer who was starting to use VS 2005 mentioned that he was a big fan of the Class View and was disappointed to see that it was no longer possible to synchronize the Class View with the editor.  In VS 2003 this was possible via a command called ‘View.SynchronizeClassView’ that appeared on the editor context menu.  This command was removed in VS 2005 based off of the command usage data collected during the Beta and CTP releases, in an effort to reduce clutter. 

The good news is that the command was only removed from the menu, not the product.  The better news is that Visual Studio actually has an extensive mechanism for customizing layout, including the names, order, icons, etc. of commands that appear on menus.

In order to move the command back onto the editor context menu, follow these steps:

1. Select Tools | Customize…
2. In the tabbed dialog that appears, search through the checked list box list, on the “Toolbars” page, for an item called “Context Menus”.  Check it.

This causes a new toolbar to appear at the top of the screen underneath the toolbars that are already showing.  This toolbar is only visible when the Customize dialog is showing.

3. Change the active page from “Toolbars” to “Commands” (on the Customize dialog)
4.
In the Categories list box, select View
5. The right-hand pane, “Commands”, will be updated to show all of the commands prefixed with “View.”  Scroll through that list and find SyncrhonizeClassView (the list is alphabetically ordered).

6. Drag that command from the “Commands” list on to the Editor Context Menu | Code Window item in the toolbar that appeared when we selected “Context Menus.”  You can put it wherever seems appropriate on the menu.

7. Close the Customize dialog

The editor context menu now contains the command, and whenever you’re in source you can right-click and select Synchronize Class View, just as in VS 2003.  This same process can be used to change the order of commands that appear on the menus, their names, the icons associated with them, their accelerator keys.  You can even delete commands that are cluttering the menu that you never use.  These customizations can even be preserved into a .vssettings file and shared on multiple machines or with coworkers.

The question got me thinking about Class View and how people are currently using it.  I’m curious:

  • Do you use Class View? (If not, do you use any tool that works like Class View, the Navigation Bar, or maybe an addin?)
  • If you use Class View, do you tend to use it for navigation, browsing, or both?
  • Class View used to provide a set of ‘Add’ commands for adding new methods and classes.  Did you use those?  Do you miss them in 2005?
  • Do you like the split screen view of the Class View vs. how it appeared in VS 2003?
  • What requests do you have for Class View in the future?

Comments (30)

  1. LMcCoy says:

    WOW! This ability to customize context menus is very useful. I use them extensively in the code window and the solution explorer, and didn’t know it was so easy to add my own commands. I’ve long wanted a context menu to make a source code file writable to make quick changes without checking the file out.

  2. Joku says:

    I do not use it currently, however in a future where files would not be utilized in the manner of class.cs or such and one class could contain multiple languages along with good editor support for that, I would be willing to move from the current file/directory oriented view to a view based more on assemblies and types/classes perhaps. One xml based file could contain multiple source languages and represent one assembly for instance.

  3. NigelN says:

    Thank you!!!

    I was about to throw my keyboard through the window – I use Synchronize Class View a lot when browsing a large body of new code. What made it more frustrating was that the documentation still insists the command is there.

    The cusomization mechanism is neat once you find it – I feel in control again.

  4. Jeroen says:

    This is nice… but I cannot get it to work for projects in solution folders… Any ideas?

  5. Phillip from Russia says:

    I was disappointed. But now i am glade to see this menu item again.

  6. Andeezle says:

    Dude, I love you. ;-))

  7. hhowe says:

    Jeroen, I can’t get the View.SynchronizeClassView to work with solution folders either. It doesn’t seem to matter whether I invoke the command via a shortcut or from the command window. The command works if I promote a nested project from the solution folder up to the root solution. Guess I will give up on solution folders for now. /SHRUG

    Response

    You’re both right. I’ve filed a bug that this isn’t working with solution folders.

  8. Bodo says:

    Hi Anson, I just found this page through Google. Awesome. The lack of “synchronize class view” has kept me from switching to VS2005. That and the split class view. On a small monitor (i.e. Laptop) I find the split class view nearly unusable. If you have any influence on this, please please please bring the merged class view from VS2003 back as a configurable option.

    Response

    I’ll forward this feedback to the folks responsible for Class View in the next version of Visual Studio. I doubt it’ll be something that can be uniformly reverted, since there are bound to be people that have exactly the opposite opinion (it’s too hard to navigate when it’s got only a single pane). It’s possibly a place that deserves a configuration option.

  9. These transcripts will eventually be published here , but while we’re waiting for that to occur, I’ll

  10. Drakkhen says:

    I cannot understand how people cannot use the classview intensively when navigating through any code whether simple or complex. It is the only place where you see in one glance everything about a class.

    Not being able to synchronize was a real pain for me and your post is going to save me a lot of pain!

    thanks!!!

  11. Alex says:

    Great! This is very helpful reminder because I keep forgetting this from one VS2005 reinstallation to another ­čÖé Thanks!

  12. Kevin Baroni says:

    Thank you very much Anson. This was excellent information and your instructions were easy to follow. I heavily use and rely on the ClassView. I work on large projects that have large collections of classes and source files.  Having a macro-view of the class makes it so much easier to find what I’m looking for since people rarely if ever take the time to manually alphabetize the location of their functions.

    Again Thanks Much !!!

  13. David Pritchard says:

    I second that. I HATE the split class view. I can’t see how it’s any kind of gain. The bottom part of the view occupies space all the time, mostly to no purpose. And then, when you’ve managed to find the class you want, in your reduced class view area, you have to scroll in that tiny bottom part to find the method you want. I believe this kind of UI problem is addressed by a neat innovation known as the TREE VIEW.

    BTW, I have a 21" monitor, and it’s still terribly uncomfortable to work with. It’s clearly a massive productivity hit.

  14. Nathan says:

    "Class View used to provide a set of ÔÇśAddÔÇÖ commands for adding new methods and classes.  Did you use those?  Do you miss them in 2005?"

    yeah, I miss them!  are they gone, or just removed from the menu by default.  I tried adding them back with the technique described above, but it didn’t seem to work (the menu items were greyed out).

    is this yet another regression we have to trade for all the "improvements"?

  15. Nick says:

    Fantastic. You’ve saved my life as well. Thanks.

    If only there was an equivalent Synchronise Solution Explorer option!!

  16. Bob says:

    very helpful for guys come from IntelliJ

  17. Patrik says:

    It would be useful if the class view would be permanently synchronized, i.e. if you change the file in the editor window, the correct class should be highlighted.

    Patrik

  18. SandroG says:

    Hi Anson,

    fortunately I found your link on Google: recently I changed the PC and didn’t remind how to configure this option on VS2005. Thanks!

    I use Class view sometimes, but would like to use it more often.

    For me, it would be great if there were a way to synchronize the Class View with the Code Editor: when writing code I like to think about classes and methods, not about files (like in Solution Explorer). And also I want to see different views of my class, for example only the public interface. The "split view" is very usefull for this purpose.

    Instead of the "Track Item in Solution Explorer" option, I will find more usefull a new option: "Track Item in Class View".

    Look at Eclipse IDE for Java, for example.

  19. Val says:

    Excellent, NOW I’m going to use the class view again.

    Many thanks to the author for sharing. This should be at least a configuration tickbox!

  20. Val says:

    you’re a lifesaver!

    When switching between eclipse and VS this was severely lacking

  21. Én ritkán, olyannyira – elöljáróban, VS 2005-r┼Ĺl van szó, némi VS 2003-ra emlékezéssel -, hogy most jutottam

  22. TommyJamaica says:

    class view is very useful.  I use it for visualizing and navigating.  All major java ide’s can synchronize to class view automatically as you move through your code.    It would be nice if  Visual Studio didn’t make you go through a context menu.  A keyboard shortcut would be better and automatic would be best.  Does anyone know how to configure VS to do that?

  23. mihhon says:

    will be great to show inner classes in class members view

  24. Marcel Sorger says:

    Finaly the class view gets usefull again.

    Without sync it’s a pain in a large project.

    thanks 1000*

  25. David says:

    Class view on KDevelop works soooo much better.   Why dont you guys steal that IDE’s design.

  26. Kevin Baroni says:

    Thank you AnsonH, thank you, and did I mention THANK YOU?

    Although this is a beautiful nugget of information and the MSDN site is full of them…it would be nice if the MS engineers would simply add this back to the VS code popup menus rather then making us developers lose valuable time in scouring MSDN for useful features we had previously grown quite accustomed to using.

  27. David Pritchard says:

    The split class view seems appallingly bone-headed. Surely, the genius of the tree view (introduced in Windows 3.0, I believe) is that it allows you to dynamically allocate screen real estate to different groups of elements by opening and closing branches. The split view takes away that flexibility, and forces you to keep moving the splitter up and down, depending on whether you want to see methods or classes. Surely, this is exactly the problem that the tree view was designed to solve?