Peter Morlion logo


Seeing more code in Visual Studio and adding a Command to a Menu in a Toolbar

I spend most of my time in Visual Studio. My work time, that is, although it probably takes up a big portion of my overall life too… ouch!

I like to have a clean Visual Studio, void of toolbars, icons, panels,…. I’ll summon them when I need them, but most of them I rarely need. I keep a strip at the bottom (collapsed) with things like Output, Error List, Unit Tests, etc. This is the one on my work-PC (not my personal PC, I wouldn’t choose to work with TFS 🙂

To the right, I have my Solution Explorer and Properties (and at work, Team Explorer). At the top, only the main menu, no toolbars:

This allows for a clean working space, maximizing your view on what you actually work on most: the code. It reduces noise, reduces the need for splitting lines of code over multiple lines, and it pushes you to learn keyboard shortcuts, by which you increase your productivity/speed.

There’s one toolbar that I’ve added to the right, with some things I need now and then. It’s a customized toolbar so it only has the commands I need. And it’s to the right, because my screen is wider than it is high, and I want to be able to see as much code as possible. Putting it to the right is less "invasive" than if I were to put it at the top.

For the buttons, I’ve even declared my own shortcuts (i.e. Source Control Explorer maps to ctrl+alt+shift+S). You can do this via Tools > Customize > Keyboard… Search for "View.TfsSourceControlExplorer".

It’s a little harder to add a command to a menu. You can see there’s a Configuration item, where I can change the active Configuration of the solution:

(To my knowledge, there’s no shortcut for this, and even if there was, you need some way of seeing the active configuration)

So, adding this to such a toolbar is not that intuitive. What’s more, you want to add this Command ("Solution Configurations") to a Menu inside your Toolbar. Just adding it to the Toolbar will hide it when docked left or right.

To add a Command to a Menu inside a Toolbar, first create a new Toolbar. Go to Tools > Customize and click "New…". Give it a name and then go to the Commands tab.

In the Commands tab, select the "Toolbar" radio button and select your new Toolbar from the list. Add a new menu and click the "Modify Selection" button to give it a name. The Menu inside your new Toolbar actually is a new Toolbar in itself. So select that one:

Now click "Add Command" and select (in my case) Build > Solution Configurations:
Now, dock the Toolbar to the right, and you have the result:
It’s not very intuitive that the Menu inside your Toolbar lists as a new Toolbar. But once you learn to customize your Visual Studio for your needs, and for maximizing screen real estate for code, you can begin working more efficiëntly.

Leave a Reply

Your email address will not be published. Required fields are marked *