The Visual Studio IDE is very customizable. One customization that you might be familiar with is the ability to modify the menu and toolbars to add or remove items. In this tip, look at a feature that is not as well known, which is the ability to create c
- [Instructor] The Visual Studio IDE is very customizable. One customization that you might be familiar with is the ability to modify the menu and add or remove items. It's the same for the toolbars. You can remove items that are not necessary for your daily workflow. In this tip, we'll look at a feature that is not as well known, at least it wasn't for me. That's the ability to customize context menus. Of course, a context menu is when you right-click in a portion of the IDE, and you get this menu. So this is things that I can do in the Code Editor, whereas if I go over to Solution Explorer, and I right-click, I get a context menu with actions that I can take that make sense in the Solution Explorer.
I'm going to show you two customizations. One is for the Code Editor, and one is for the Class View. If you don't see the Class View, go to View - Class View. What I'd like to have happen here is when I right-click on the top node here, I'd like to be able to open the Object Browser. Now the Object Browser usually is over here in the View menu, right there. I'd like to add it to the context menu. And the other action I'd like to take is, when I'm in the Code Editor, I'd like to use the Format Document command.
Let me show you how that works. Make some changes to my code, and then I go to Edit - Advanced - Format Document, and you see that Visual Studio modifies my code. It's using a set of rules I've defined in Visual Studio to modify the layout of the code. Let's add both of these to the context menu. I'll start with the Code Editor. Go to the Tools menu, choose Customize, and switch over to Commands, and here's where you can modify the menu bar, the toolbar, and this last one is where we modify the context menu.
I'll choose this one, and then I'll go to this dropdown, and it shows all of the available context menus that are part of Visual Studio. And what we're looking for is this one here, the Editor Context Menus - Code Window. Choose that, and then I'll choose to add a command. Remember that that command was in the Edit menu, so I'll go here. It was called Format Document on the main menu that was up here. When I first attempted to do this on my computer, I went to look for Format, and it didn't find it.
You'll see it's not here. Well. It turns out it's called Document Format when you're looking at it in here. Press the D key. There's the one we're looking for, Document Format. So I'll click on OK. Now that I've got it on the menu, I can choose to move it up or down in the order of the menu. I'll leave it at the top so it's easy to find. Then I'll click on Close. Now I'll make a change to my code, like that, and then go right-click.
There's my new menu item. Now let's do the same thing, but this time for the Object Browser in the Class View. I'll go to Tools - Customize, just like I did before. Here's a number of Class Views. The one I'm looking for is when I right-click on the Projects, so I choose this one, Add A Command, go to View, press the O key to move to that section on the list, and then click OK and Close.
Now we'll go over to the Class View, right click up here, there's the Object Browser. There are hundreds of commands available in Visual Studio. I'm sure you have some that you'd like to use with this simple tip. One caveat before I close. It is possible to add items to the context menu that don't make sense for the tasks available in that area of the IDE. You can add it to the context menu, but it might be disabled when you attempt to use it.
Skill Level Intermediate
Q: Why can't I earn a Certificate of Completion for this course?
A: We publish a new tutorial or tutorials for this course on a regular basis. We are unable to offer a Certificate of Completion because it is an ever-evolving course that is not designed to be completed. Check back often for new movies.