I want to set up some hotkeys in Visual Studio to control the window layout.
For example, F10 would collapse all windows (such as the command from the windows main menu called - Auto Hide All) and then F11 which would dock and position certain windows of my choice at certain positions. This would be so I can jump to specific layouts quickly.
So how to control window layout from visual studio macros?
Probably not optimized but couldn't you consider using vssettings and Import/Export Settings to achieve your goal? (I know this isn't exactly the answer to your question...)
****Update****
You can check out my blog post which provides the ability to list and switch window layouts in Vs2008 and Vs2010: http://www.brianschmitt.com/2010/09/save-and-change-tool-layout-in-visual.html
****Old Answer Below****
If you are looking for a repeatable setup, then a Macro may be your best option. AutoHideAll may already be bound to CTRL+Shift+~ - I cannot remember if that is the default. If not, you can bind it in your Tools-->Options-->Keyboard dialog. In there you can also bind the Macro below to your F11.
Here is a Macro that will accomplish the layout for you:
Public Sub SetupMyPersonalLayout()
DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Visible = True
DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).AutoHides = False
DTE.Windows.Item(Constants.vsWindowKindTaskList).Visible = True
DTE.Windows.Item(Constants.vsWindowKindTaskList).AutoHides = False
End Sub
This will show the window and then "pin" it.
Another option that comes to mind is to take advantage of the different views that Visual Studio offers (Standard, Full Screen, Debug, and some others).
Lastly, if you are on 2005 or earlier (or if you want to update the code) there is an add-in that will do it for you: http://www.codeplex.com/VSWindowManager
Related
How can I assign a hotkey to maximize the edit window?
Basically I want the equivalent of:
switch to edit window + minimize all side panes
or at least just minimize all side panes (and leaving the menu and toolbar as is)
NOTE: this is different than full screen, I do not want to change the size of the VS window itself.
I need this on Visual Studio 2017 / 2019.
Short of some sort of macro I thing the best way is probably like this:-
Setup the windows in VS as you want them to look
Save that as a layout.
Assign a hotkey to the Switch to layout command.
Hot Windows extension provides shortcuts to hide and show all tool windows (e.g. Shift+Alt+Ins).
On my laptop I try to maximize workspace within Visual Studio. If I'm just dealing with code, I keep all of my panels on the left and right hidden via auto-hide.
However, if I'm working in Design mode I pin the toolbox, properties, etc so they're always visible. I was hoping to find a way to actually hide the panels when I tab to a file only dealing with text (not in Design mode), and regain the panel when I return to a tab in Design mode, no manual pinning/unpinning required. I'm not fond of just mousing over the panel tab so it pops into view. I like to keep them permanently there while in Design mode.
Going from http://i.stack.imgur.com/yYmHu.png to http://i.stack.imgur.com/AQLGP.png is basically what I'm referring to.
Thanks!
Im not sure if there's a better way but I was able to create a macro to do this. Open Macro IDE in Tools -> Macros -> Macros IDE. Open EnvironmentEvents under MyMacros. Add the following code:
Private Sub WindowEvents_WindowActivated(ByVal GotFocus As EnvDTE.Window, ByVal LostFocus As EnvDTE.Window) Handles WindowEvents.WindowActivated
If GotFocus.Caption.EndsWith(" [Design]") Then
DTE.Windows.Item(Constants.vsWindowKindProperties).AutoHides = False
Else
DTE.Windows.Item(Constants.vsWindowKindProperties).AutoHides = True
End If
End Sub
If the properties panel is not already opened, you add this code to open:
DTE.ExecuteCommand("View.PropertiesWindow")
Try to use Perspectives extension. After installing you can save your current layout as perspective (just like in Eclipse) in Visual Studio 2010 and then switch between them. The only bad thing is what you can't switch between them automatically. I don't know maybe we can modify sources of extension(if it's available).
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
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
I want to be able to modify a certain setting of Visual Studio right from the toolbar.
Specifically, the number of parallel builds (Tools | Options | Projects and Solutions | Build and Run | maximum number of parallel project builds).
It can be either an edit box right on the toolbar or two buttons setting it to certain values.
I use Visual Studio 2005.
Any suggestions?
Write macros which will modify the two settings, then put macro on toolbar using "Cusomtize"
(almost) any VS command or property has a corresponding scriptable object that you can call in macros.
Do Alt-F11, go into the macro editor, open the object model window and start sniffing around. You can use search to look for the relevant class/function for a given property (e.g. the number of builds). Once you find it, it's just a matter of writing a few VBA lines that change it and, as Ilya suggested, put that macro in your toolbar.
Btw, it should be possible to put an edit box in the toolbar to get the value; but it would probably be much easier just to call InputBox or something to ask the user for the input.