Multiple windows in Visual Studio - visual-studio

I've just come to Visual Studio 2008 from a UNIX / Java background.
In Visual Studio, how can I have multiple overlapping editor windows? In Eclipse, I can open a new Window, add an editor to each of them, then Alt-Tab between them, overlap them, select them in the Taskbar, etc. Similarly, I'd like to put 'Output' in it's own 'first class' window so I can easily Alt-Tab between that and an editor when on a laptop.
Studio tools lets me 'tear off' and editor window, but the 'torn off' window doesn't respect Alt-Tab rules, and always hides the main Visual Studio pane.
Update: By way of example, In 'Word' I can have two documents open. I can Alt-Tab between them. I can Alt-Tab between either document, or Alt-Tab from either one to Outlook if I wish. I can overlap the documents, or place them side-by-side. I can place one document on one monitor, and one document on the other. I can have have Outlook open on one screen, overlapping one of the Word documents, while I edit the other. This is the kind of thing I would like to do with my source files!

You can change the window layout in the Tools menu under Options. The very first item is Environment\General. You can choose Multiple Documents (versus Tabbed Documents). That may give you the "look" you are describing.
However, I don't think it is possible to use alt+tab to change windows since those windows still belong to the single instance of VS2008. You can change windows with ctrl+F6. In addition, a nice trick when using Tabbed Documents is to press ctrl+alt+down arrow. That brings up a list of all open editor windows.

Alt+Tab is for switching between applications on Windows.
To switch between windows within Visual Studio use Ctrl+Tab.
This should work on any mutli-windowed application.

You can click on the tab of the window and drag outside making it a standalone window.

If you are a vim user, and install VsVim, you have an effective work around for dealing the quirky behaviour Visual studio has for moving between file editing windows.
You can easily make vertical and horizontal split windows within the "main" file editing window, just as you would in vim, using the regular vim keys. e.g. with any of the regular vim commands :vs, <C-w>s, <C-w>v, ...
If you tear off a second editing window (e.g. with the mouse) and put it on a separate monitor, you can use Vim's global marks, or <C-w>w (and similar commands for navigating between panes in vim) to jump between file editing windows across different monitors/screens with just a few keys.

Related

Visual Studio: assign a key to maximize edit window

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).

Arrange tabs in Visual Studio without mouse

I use Visual Studio 2015 on dual monitor configuration, having main window with code on primary monitor, and other window with code on secondary monitor. Is there a command that can be be used with keyboard shortcut so that i move .cs file opened in one window to the other. I know that i can drag and drop tabs with mouse, but that is too slow and clumsy.
I used my tool FeinCtrl and found the following commands related to document arrangement:
Window.MoveToMainDocumentGroup
Window.MovetoNextTabGroup
Window.MovetoPreviousTabGroup
Unfortunately, dragged-out documents create separate top-level windows that appear to be non-addressable (you can move them back home).
Of course, you can bind those commands to some keyboard shortcuts, but that's not exactly what you were asking.

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

How do I get a code window to split vertically in Visual Studio 2008? (not HTML mode)

In Visual Studio 2008, it seems that Window -> Split only gives me a horizontal split, and Window -> New horizontal tab group does not allow me to edit the same file in both panes.
Note that I am talking about C# code windows, not HTML editing mode.
I want to edit the same file in two horizontally arranged panes.
Is this possible? Free add-ons are fine.
Edit: I have CodeRush Express installed, and it seems to have done something to my code window borders.
Edit #2: It's not CodeRush. I tried on VM with no CodeRush, and I have exactly the same issue.
Ok, I found the solution here.
The answer is:
Window -> New Window
Window -> New Vertical Tab Group
This duplicates the current tab so you'll get [Form1.cs:1] and [Form1.cs:2] tabs; and then you can use a vertical tab group to view them side by side.
I believe that it's not CodeRush's fault. A vanilla 2008 install only lets you do the split view with one file on the top and one file on the bottom. The only side-by side option is the horizontal tab-group feature (with the problem of only having a file open in one of them, as you mentioned.)
The obvious workarounds would be to either make a read-only copy of the file elsewhere and use that in one tab-group, or open up a second instance of VS. It does have decent handling of files that get changed in other apps, so having the same file open in two instances isn't a problem.
In VS2010 I couldn't find the Vertical Tab group button. The workaround is:
1. Open Fullscreen mode
2. Click and drag the window to the far right (or left) and it should give
you an option to view both windows side by side.
3. Exit full screen mode and you should now have the ability to click and
drag windows between vertical tab groups, and it even now allows you to
drag to a new vertical tab group.
No idea why you have to jump into fullscreen first, and i seem to remember not having to do that before.
As a one-time developer on CodeRush, I doubt that this would be caused by CodeRush Xpress. I'm currently running the latest beta of CodeRush 9.1.0 on Visual Studio 2008, and splits are working fine. However, you could certainly try uninstalling CodeRush Xpress to see if that clears up the problem. If it does, I would recommend posting in DevExpress' peer-to-peer forums.
alt text http://diditwith.net/content_images/CRXSplits.png
I like the vertical tab group option. The only thing that bothers me about it is that I cannot put the solution explorer on both windows (Or properties for that matter). I have to navigate all on one side and move screens around.
I found this nifty add on tool for VS 2012 that allows you to compare two files at the same time and make changes.
Check this out:

Multiple Monitors with Visual Studio 2008

I've got 2 monitors, and most of the time I've got some reference material open on one screen, and Visual Studio on the other. To really get in the zone, though, I need my code to be the only thing I see. Does anyone know if it's possible to have multiple code windows in Visual Studio? So far the best I can do is put debugger output and the solution explorer on my left monitor, and the rest of VS on the right. I would love to have code on both windows, however.
If you right click on the file tabs, there's an option for "New Vertical Tab group" Just maximize across both monitors and put the divider on the monitor divide and I think that's what you're after.
See also the "Visual Studio and dual/multiple monitors: how do I get optimized use out of my monitors?" question.
Though I use StudioTools for other purposes, it has a "Tear off Editor" option, with which you can "tear off" the file to a window and resize the window. Find it quite helpful
Instead of enlarging the VS2008 window to span the two monitors, you can display the 'Code Definition Window' on another monitor: just drag it outside the main window! I find this very handy to avoid switching between code windows: it is very often that one is interested in the definition of the symbol under the cursor...
The same is true for other windows like the 'Class View', the 'Call Browser', etc. You can choose to keep them grouped in the same group with tabs, or drag each of them separately (click on the label of the tab to start the drag).

Resources