How to quickly switch between layouts in Visual Studio? - visual-studio

I use different window-setups for Visual Studio depending on whether I'm at work, and have three monitors available, or e.g. at home, where I typically only have my laptop.
I've found a setup I like for each situation, and saved these using the export wizard, as shown below; for those who might not be aware, this can be done with the opton Tools -> Import and Export Settings.
I like the ability to do this, but I'd like it even more if I could do it without having to click a whoping 9 (!!) times to switch from one mode to the other. Ideally, I'd like to be able to "quick-switch" between home- and office-mode with just one or two clicks, but any improvement would help.
I know this might sound like an insignificant issue (which I suppose is true), but it's been bugging me for a while, and the only "improvement" I've been able to come up with so far is to add a button to the toolbar, as shown below. All this does though, is let me start the wizard without opening the Tools menu.
I can't possibly be the only one using this, so I'd like to know if there are any better ideas or solutions out there?

Visual Studio 2015 and 2017 support Loading and Saving different Window Layouts without using the Import/Export settings feature.
https://msdn.microsoft.com/en-us/library/4k7zyeba.aspx
Switch between the layouts
To switch between layouts, use the Keyboard shortcuts, or from the main menu choose Window > Apply Window Layout.
You can also create toolbar buttons that switch directly to a layout:

Related

How can I make Visual Studio open tabs always in its main window?

I have a multi-monitor system, and Visual Studio set up like this:
The main windows on the left, stuff like Solution Explorer, Output and Error windows on the right. When I want to open any file from the second monitor, the new tab also gets opened there. However, I rather want new tabs to appear in the tab well on my main monitor. Is there any setting (or extension) that can achieve that?
It is difficult to tell what causing it. Resharper and Productivity Power Tools both have an influence on how your document windows are managed.
A few options:
Try dragging the new window that is opening on the wrong screen and dock it; VS might remember this.
Check/review all the options for Resharper and the Productivity Power Tools.
Check that you don't have any additional R# extensions installed.
Export your current settings and reset your environment.
Disable extensions one at a time. A common approach to solving a problem by stripping things back until it works again.
I remember having some problems years ago when I ran a multi-monitor setup (at one stage 3+ screens), however now I do all development on a Surface Pro 3.

Single layout for 'edit' and 'debug' in Visual Studio

In Visual Studio 2008, 'Start Debugging' switches Visual Studio to a different layout. How can I force Visual Studio to use a single layout at all times?
I could attempt to lay out my windows in both normal and 'Debug' modes as similarly as possible. However, i) Visual Studio will still do a visible redraw, and ii) I have to keep the layouts in sync manually.
Update: It seems the correct terms are 'Design View' and 'Debugging View'. According to Window Layouts: The Four Modes 'There is no way to tell Visual Studio to use one state for all modes at this time.' Is this really true?
As others have pointed out, you can't use one settings group to control both design and debug views. Visual Studio doesn't make it easy to get the most out of window placement settings, but the approach I use to manage layouts might help.
Instead of frequently adjusting window placements by hand, try to think of a fixed number of different views you want to work with. Eclipse has perspectives, window layouts you can switch between. Think of Visual Studio this way. For example, I use two layouts in Visual Studio: one to take advantage of two monitors when I'm sitting at my physical workstation, another for one monitor when I'm working remotely. If you can constrain yourself to using a group of layouts that makes sense for you without manually adjusting windows, you can make design and debug window placements the same for each layout.
However, switching between layouts is painful with Visual Studio out of the box. You have to go to Tools->Import and Export Settings and select the layout manually. It takes more than five mouse clicks and sometimes 15 seconds to switch layouts this way on my workstation. We can do much better!
Save the window positions you want for each layout to settings files
Make a macro to load each settings file
Bind the macros to keyboard shortcuts or toolbar buttons
Save window positions to a settings file
Arrange windows the way you want them for a specific layout. Visual Studio saves the location for nearly every window (e.g. Solution Explorer, Output, Find and Replace), so be thorough. Visual Studio saves design and debug layouts in a single file so arrange windows in both views.
Go to Tools->Import and Export Settings. Choose Export selected environment settings and click Next.
The next dialog prompts you to select the settings to export. Uncheck all settings except General Settings/Window Layouts so only window placements are saved, like in these screen shots (I can't expand the window so here are two shots of the same dialog):
Enter a name for this settings file and save it. Repeat until you have a settings file for each layout. There is no limit to how many settings files you may have.
Make a macro to load each settings file
Go to Tools->Macros->Macro Explorer to show your macros. There should already be a macro project named MyMacros. Create an empty macro project if none are visible. Double click any module in any of these projects to open up the macro editor.
Enter this into the editor. You want one main sub that takes a path to a settings file and loads the file, and one sub for each individual file that calls the main sub. If you save your settings files to the same folder you can have the per-file subs pass just the file name instead of the whole path.
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module Module1
Private RootFolder As String = "C:\Path\To\Folder\With\Settings\Files\"
Private Sub ImportSettingsFile(ByVal FileName As String)
FileName = IO.Path.Combine(RootFolder, FileName & ".vssettings")
DTE.ExecuteCommand("Tools.ImportandExportSettings", "-import:""" & FileName & """")
End Sub
'Corresponds to file layoutA.settings
Public Sub ImportLayoutA()
ImportSettingsFile("layoutA")
End Sub
'Corresponds to file layoutB.settings
Public Sub ImportLayoutB()
ImportSettingsFile("layoutB")
End Sub
'Repeat for each settings file
End Module
Close the macro editor and go back to Visual Studio. You're done! Running any of these macros will load the settings files automatically. You can double click any of the subs in Macro Explorer to run them. If you display Macro Explorer at all times this might be sufficient, but if you don't or would rather not have to click the macros to run them we can do even better ...
Bind the macros to keyboard shortcuts or toolbar buttons
Go to Tools->Options->Environment->Keyboard. This window allows you to change any keyboard bindings. Type "Macro" without quotes into the Show commands containing text box. This will show the macros you created. Select any macro, click in the text box titled Press shortcut keys, and enter the keyboard shortcut you want to use to run the macro. Hit Assign, then OK. You can now use this keyboard command to load the settings file.
Alternately, you can use a toolbar button instead of or in addition to a keyboard binding. Go to Tools->Customize. Select the Commands tab, select Toolbar, and select the toolbar you want to add the button to (Standard is the main toolbar). Click Add Command, select the Macros category, select the macro you want to add a button for, and click OK. You will have a new button on the toolbar that loads the window layout from that macro.
Keep in mind that keyboard shortcuts and toolbar buttons are themselves settings. If you import a settings file that overwrites either of them you will have to redo this last step. The window placement settings files won't overwrite these values because you only exported window locations. It's a good idea to periodically export and back up all settings, not just window settings, in case something like this happens and you want to recover non-window settings.
No, this is not possible. The website you found is indeed accurate:
There are four different window layout modes in Visual Studio:
Design View - this is the one you see when you start up Visual Studio. It's what most people refer to as the "normal" view.
Debugging View - this is the view that you get when you enter Debug Mode like when you are stepping through your code
Full Screen - the view you get when you go to View -> Full Screen (Shift + Alt + Enter).
File View - the lesser known view you can get when you open up a file in DevEnv.eve
The thing to remember here is that, both, your tool windows and your command bar customizations are saved separately for each state. There is no way to tell Visual Studio to use one state for all modes at this time. Additionally, when you shut down Visual Studio in any state, all four states are saved.
It's very strange that you would want to use the same window layout for all four modes. The same windows that are useful at design time are hardly ever useful during debugging, and vice versa.
For example, in Debugging View, I hide the Toolbox, Document Outline, and Property Manager windows. Then, I add the immensely useful Call Stack, Autos, Locals, Processes, Modules, and Breakpoints windows. None of the latter panes would be remotely useful to me in design mode, so I don't want them taking up screen space. But they're invaluable in debug mode, so I want them to show up. I also resize windows in the two different modes, based on their relative importance (such as the Properties window).
If you really still think that the two views should have the same window layout, the best you can do is rearrange the windows manually to achieve the same layout in both modes. I also recommend exporting your Window Layout settings (Tools -> Import and Export Settings) so that you have a fresh copy to revert back to in the case of disaster. I keep settings files containing my preferred window layout settings for single monitor (laptop), dual monitor, and triple monitor configurations.
I think your question was, "How do I use the same settings for both modes?" Am I right? Although #Chris gave an excellent thesis on how to stuff automagically, I wanted to point out, for anyone else that finds this question that there is an easy way to acheive same window settings for both design and debug modes.
Export your settings:
Choose General Settings/Window Layouts (in VS 2013) and save the file.
Open the file in an XML editor (or whatever... it's an XML file)
Find /UserSettings/Category/Design/WindowProfile and copy the entire node.
-- This assumes your Design view is the one you want to use for both modes.
Find /UserSettings/Category/Debug/WindowProfile and replace it with the one you copied from Design.
Save and re-import.
I have one of these settings files for home, remote, and office.
Many people try to turn off this feature because of strange behaviors (glitches) of VS windows on multi-monitor configurations.
In such cases there is another option that can help:
Turn off Environment->General->"Optimize rendering for screens with different pixels densities"
https://developercommunity.visualstudio.com/content/problem/830128/windows-layout-not-restoring-properly-in-multi-mon.html

Lock down placement of panes from Visual Studio

Ok, if you're like me, you've accidentally dragged one of the many, many panes in Visual Studio around and spent some tedious time getting things back in order again.
Is there any way to lock down all the panes in Visual Studio so they cannot be dragged and placed elsewhere ?
When you have your pane layouts (as well as your fonts, toolbars, colour schemes and whatnot) the way you like them, export your settings (Tools, Import and Export Settings) and give the file a sensible name. Then if you have a spot of accidental dragging, just import your saved ones. This is better than Reset Layout if your preferred layout is not the default.
As far as I know, no. But everything for getting for working with tabs and tab groups is inside the "Window" menu item in VS. But if you want to reset everything back to the way it was why not try:
Window -> Reset Windows Layout
You might also want to check out this Arranging and Using Windows in Visual Studio, I think you might be able to create a workspace, save it and if needed reset back to it after you moved windows around.
Export your settings according to Mar's answer and then check out this extension:
http://visualstudiogallery.msdn.microsoft.com/a79072f7-3109-44a0-95c0-9c50e729d6a3
A real lifesaver :)
Feature request on User Voice:
Lock/Unlock Docked Window Layout
You can reset Visual Studio windows back to the default by going to Window->Reset Window Layout (Visual Studio 10). Other versions have something similar. This helps the tedium on dragging the windows back in order.

Customizing toolbar items in VS2010

Has the menu & toolbar customization functionality in VS2010 been reduced?
I can't seem to be able to select an icon for an added command, nor set it to be icon-only. Previous versions of Visual Studio supported this functionality and even allowed the creation/editing of custom icons.
Is this something that has suffered as a result of the move to the WPF-authored UI or am I missing something?
Seems like this functionality was cut from Visual Studio 2010. This post has some info in the comments: Customizing Visual Studio 2010
Specifically - "Unfortunately assigning or editing icons to commands through Customize dialog is not possible in VS2010. It is one of the features got cut for lack of time. This is however something we'll consider adding back in next version."
The reply also has a longer explanation of a workaround.
As noted in the link mentioned in the answer from #Gordon Mackie JoanMiro, the REASON for the reduced functionality is that the VS Shell team migrated the entire UI (shell and command system) from Win32 to one based solely on WPF. This was a gargantuan task, I would imagine. However, a couple workarounds are now available:
You can export previously saved settings from VS 2008 and import them into VS 2010. That includes command bar customizations (as noted by #Don)
A more recent blog-post contains detailed instructions for using a new extension to VS2010 (available on Visual Studio Gallery) that allows users to change the images on the command UI. (Note that the old drag&drop customization interface is still not supported in this new extension.)
If you have custom icons, any attempt to make ANY changes to the tool bar will result in the custom icons disappearing and being replaced by text when you restart VS2010.
The only way I found to get my custom icons without text into VS2010 is to open VS2008, set up all of the tool bars the way I want, including custom icons, then export the settings (Tools| Import and Export Settings). Then open VS2010 and import those settings. Tedious, I know, but it allows me to have a down arrow icon that searches for the next instance of the word my cursor is on.
I have been trying to customize VS2010 toolbars/keyboard and what took a few minutes in previous versions takes hours now. The new system looks real pretty but is useless in practice. Apart from the fact you just can't do (like change the appearance of buttons as mentioned above) the things you can do are extremely time-consuming and annoying.
Why is it every new version of VS loses something really useful? Other examples:
VC++5 introduced a new HTML help system. Pressing F1 on a function name used to immediately show help for that function. After VC++5 getting context help became annoyingly much slower, and is still very slow (and inaccurate).
VS.Net (aka VS2002 or VC++7) had a useless bookmark system compared to VC++6. VS2010 bookmarks are better but not perfect.
VS.Net removed the search state buttons "whole word", "case sensitive" etc. These were possibly the most useful buttons ever as they quickly allowed you to see why a search may have failed.
I found a great extension: CommandingImage
It does not have an icon editor, but you can create your images as 16x16 png format (for transparency) and import it (I recommend Paint.Net)
Dave, here's how to add toolbar buttons:
1) in the IDE, find the down arrow looking thing on the far right of a toolbar and click on Add Remove Buttons, Customize
2) in the Customize window select the Menu Bar radio button then select the appropriate menu bar that you want to add a button to
3) click the "Add Command..." button
4) select the appropriate Category and Command button that you want to add, then click OK.
The command button you selected will be added to the menu bar you selected. You can move the button up or down.
I think this is what you are looking for.
Good luck!

enabling design view in VS 2010

Does anyone know where can I enable the bar that let me switch between different views (Design,split,..) in Visual Studio 2010 ? I can't find it and it is not enables by default
If you go into the Visual Studio Tools -> Options menu, under HTML Designer -> General there is a checkbox to enable or disable the HTML designer. Checking this and restarting VS will do the trick and show the Design/Split/Source options at the bottom again.
I really prefer the Code Optimized setup but do need on occasion to hit the design view, shame it does not seem easier to expose and, when exposed, takes up more UI than it really needs to.
Do you have the Design/source tabs down in the bottom left corner of the window? (just above where your debug & immediate windows appear from in the default view). If you do, look further to the right of them, there is a splitter bar you can drag up to produce the split mode.
It's a corrupt installation, try reintall the VS
I also cannot see the Design/Source tab split. I could have sworn it was in VS2010 RC. Did they take it out of retail?? (I'm working with an Activity xaml file)
go to Tool->Option->General->Enabe Html Designer

Resources