From the course: Visual Studio Developer Tips
Customize context menu - Visual Studio Tutorial
From the course: Visual Studio Developer Tips
Customize context menu
- [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.
Contents
-
-
-
Brace matching in C#4m 57s
-
(Locked)
Select vertical sections of code with Box Selection5m 50s
-
(Locked)
Move code with keyboard shortcuts2m 49s
-
(Locked)
Find duplicate code with the code clone analysis tool4m 8s
-
(Locked)
Paste JSON/XML as class3m 42s
-
(Locked)
Colorize output in the build window4m 37s
-
(Locked)
A better way to redock a tool window3m 57s
-
(Locked)
The Open Command Line extension3m 39s
-
Get consistent editor settings with EditorConfig3m 46s
-
(Locked)
Git at a glance: Updates to the Visual Studio status bar4m 1s
-
(Locked)
Surround a block of code with a code snippet2m 5s
-
(Locked)
Understand the document tab features3m 35s
-
(Locked)
Clipping to a border using an opacity mask5m 53s
-
(Locked)
Insert Line with Ctrl Enter2m 21s
-
(Locked)
Use the File Tab channel3m 31s
-
(Locked)
Use the Add New File extension4m 27s
-
(Locked)
Keyboard access for CodeLens4m 32s
-
(Locked)
Use the Clipboard Ring2m 56s
-
(Locked)
Use the GlyphFriend extension5m 41s
-
(Locked)
Activate Open File in Solution Explorer3m 14s
-
(Locked)
Use the enhanced scrollbar41s
-
(Locked)
Drag and drop in Solution Explorer5m 20s
-
(Locked)
Keyboard shortcuts for MVC views and controllers4m 17s
-
(Locked)
Pin data tips in debug window6m 6s
-
(Locked)
The Trailing Whitespace Visualizer extension4m 19s
-
(Locked)
Date rounding and other helpers5m 21s
-
(Locked)
Memorize window layout (Reuse)4m 26s
-
Use DialogResult6m 48s
-
(Locked)
Label a breakpoint2m 31s
-
(Locked)
The Image Optimizer extension2m 35s
-
(Locked)
Use Ctrl+Spacebar to fix case of variable names3m 40s
-
(Locked)
Use the nameof operator6m 21s
-
Discover untested code with code coverage7m 36s
-
(Locked)
Use the Hand tool in XAML designer2m 16s
-
(Locked)
Array Visualizer extension2m 35s
-
(Locked)
Use Ctrl+Tab to cycle through windows3m 18s
-
(Locked)
Understand line stroke patterns4m 37s
-
(Locked)
The Comment Remover extension3m 41s
-
(Locked)
Toolbox tip shortcuts6m 1s
-
(Locked)
Randomize data with LINQ4m 13s
-
Customize context menu4m
-
(Locked)
Get the file path1m 25s
-
(Locked)
Convert lists4m 34s
-
(Locked)
Enum flags5m 19s
-
(Locked)
Reference highlighting2m 4s
-
(Locked)
Evaluate performance with PerfTips4m 50s
-
(Locked)
Null propagation4m
-
(Locked)
Multiple editor views of same file2m 17s
-
(Locked)
Customize the output window7m 37s
-
(Locked)
Colored braces with the Viasfora extension4m 15s
-
(Locked)
Use the C# interactive window10m 47s
-
(Locked)
The Smart Semicolon extension3m 29s
-
(Locked)
Reference Highlighting1m 35s
-
(Locked)
IEnumerable Extension Methods4m 58s
-
Compare LiNQ sequences6m
-
(Locked)
The Clear Recent Project List extension3m 34s
-