Visual Studio Code: How to split the editor vertically - visual-studio-code

In Visual Studio Code, a while ago, when I used menu View → Split Editor, it would split vertically. (One file on the left and one file on the right.)
I updated Visual Studio Code and when when I do menu View → Split Editor, it always splits horizontally. (One file on the top and one file on the bottom.)
How can I split vertically?

Change editor split layout from horizontal to vertical
In 1.20
ALT+SHIFT+0 PC (Windows, Linux)
⌘+⌥+0 Mac
Pre-1.20
ALT+SHIFT+1 PC (Windows, Linux)
⌘+⌥+1 Mac
In 1.25
You can split editor into Grid layout. Check View=>Editor Layout
It is nicely presented in Release notes v1.25: VS Code grid editor layout
In 1.58.2 **
** Someone update this with the lowest version where this became true.
The menu entry with the shortcut given above is View=>Editor Layout=>Flip Layout
The Command Palette entry is labeled "Toggle Vertical/Horizontal Editor Layout"
The settings entry is
{
"key": "alt+cmd+0",
"command": "workbench.action.toggleEditorGroupLayout"
}

If you're looking for a way to change this through the GUI, at least in the current version 1.10.1 if you hover over the OPEN EDITORS group in the EXPLORER pane a button appears that toggles the editor group layout between horizontal and vertical.

To split vertically:
⌘+\ Mac
command: workbench.action.splitEditor
To split orthogonal (ie. horizontally in this case):
⌘+k+⌘+\ Mac
command: workbench.action.splitEditorOrthogonal

Method 1
Method2
View -> Command palette -> type 'split'
Method3
Method4
Tip
Add a Keyboard Shortcut for split Editor

Press CMD + SHIFT + P (MAC) and search for Toggle Editor Group

In version 1.23.1, it is Ctrl+Shift+P and Split Editor
This will divide the screens vertically and you can move through them using Ctrl+K+LeftArrow

By default, editor groups are laid out in vertical columns (e.g. when you split an editor to open it to the side). You can easily arrange editor groups in any layout you like, both vertically and horizontally:
To support flexible layouts, you can create empty editor groups. By default, closing the last editor of an editor group will also close the group itself, but you can change this behavior with the new setting workbench.editor.closeEmptyGroups: false:
There are a predefined set of editor layouts in the new View > Editor Layout menu:
Editors that open to the side (for example by clicking the editor toolbar Split Editor action) will by default open to the right hand side of the active editor. If you prefer to open editors below the active one, configure the new setting workbench.editor.openSideBySideDirection: down.
There are many keyboard commands for adjusting the editor layout with the keyboard alone, but if you prefer to use the mouse, drag and drop is a fast way to split the editor into any direction:
Keyboard shortcuts#
Here are some handy keyboard shortcuts to quickly navigate between editors and editor groups.
If you'd like to modify the default keyboard shortcuts, see Key Bindings for details.
⌥⌘→ go to the right editor.
⌥⌘← go to the left editor.
⌃Tab open the next editor in the editor group MRU list.
⌃⇧Tab open the previous editor in the editor group MRU list.
⌘1 go to the leftmost editor group.
⌘2 go to the center editor group.
⌘3 go to the rightmost editor group.
unassigned go to the previous editor group.
unassigned go to the next editor group.
⌘W close the active editor.
⌘K W close all editors in the editor group.
⌘K ⌘W close all editors.

Simply in windows
ctrl + # (the button 2 in the upper horizontal row of numbers in keyboard)

The key bindings has been changed with version 1.20:
SHIFT+ALT+0 for Linux.
Presumably the same works for Windows also and CMD+OPT+0 for Mac.

Use Move editor into Next Group shortcut:
Mac: ^ + ⌘ + Right/Left arrow
If you want to change shortcut:
Open Command Pallette (macOS keyboard shortcut: ⌘ + Shift + p)
Select Preferences: Open Keyboard Shortcuts
Search View: Move editor into Next Group

To change the editor in Landscape and Vertical mode, follow the steps below.
For example, open two files that you have in your left or right side bar, depending on where you are placed. By default it is always on the left.
Now that you have both windows open, you have to use the key combination for PC (Alt + Shift + 1) for (Windows and Linux Operating Systems) or for MAC (Cmd + Option + 1), as commented here v-andrew.

I just found a simple solution. You can drag an opened file and move towards the four sides of the Editor, it will show a highlighted area that you can drop to. It will split the view automatically, either horizontally, vertically, or even into three rows.
VSCode v1.30.2
Update: you can also drag a file from the Explorer to split the Editor in the same way above.

Right-click on the tab that you want to split it into another screen.
Then choose whether you want to split it (up-down | right-left).
I find this is the quickest way, and You can split it to as many screens as you want.

The best way is to configure the VSCode settings to make the default behavior the way you want:
Split Editor (to a new editor group)
"workbench.editor.openSideBySideDirection": "right" // left/right (default)
"workbench.editor.openSideBySideDirection": "down" // up/down
Split Editor in Group (does not create new editor group)
"workbench.editor.splitInGroupLayout": "horizontal" // left/right (default)
"workbench.editor.splitInGroupLayout": "vertical" // up/down

Related

How do you unsplit an editor, go back from 2 code views to 1, same with terminal

How do you unsplit an editor, go back from 2 code views to 1, same with terminal.
Editor Groups
To "unsplit" editor groups without closing any open files, use the menu-bars: View > Editor Layout > Single (or, while in the editor, press and release ALT and then type vls).
Editor groups are also closed by default when they become empty. You can empty an editor group by closing tabs/files or by dragging all of the tabs from that group to another.
Hints:
Grabbing the area to the right of the tabs allows you to drag/drop all tabs in a group at once.
The "Open Editors" section of the "Explorer" panel lets you use CTRL and SHIFT to select and drag/close multiple editors at once. (If you don't have an "Open Editors" section, use the "..." menu of the Explorer panel to enable it.)
Terminal Groups
Terminals work differently than editor groups and are more limited:
You can open new terminal groups by pressing the '+' icon in the terminal tab of the panel.
"Splitting" a terminal (done by clicking the split icon in the terminal tab of the panel) really just opens an additional terminal in the same group and displays it side-by-side with the others in the group.
So, two ways to "unsplit" terminals:
Kill terminals (e.g. with the trashcan icon) until there is only one left in the group.
Switch to a new terminal group with only a single terminal in it.
(as of Visual Studio Code version 1.29.1)
By mouse
To close or unsplit a split Editor you need to
either close all the tabs in the split side you want to close
or right-click on one of the tabs in the section you want to close and select Close All.
By keyboard
To close or unsplit split Terminals:
type exit in the terminal you want to close.
Note
The split Editors will not close when you close the tabs if you have in your settings "workbench.editor.closeEmptyGroup" : false
Editors:
View: Join Editor Group with Next Group workbench.action.joinTwoGroups
View: Join All Editor Groups workbench.action.joinAllGroups
Terminal:
Terminal: Kill the Active Terminal Instance workbench.action.terminal.kill
ctrl+\ to split
ctrl+w to unsplit
F1 > View: Join Editors of Two Groups
Default keybindungs for join/split editor (macOS)
join current view/group with next group (just press multiple times if you have multiple groups):
alt+cmd+1
split current view/group:
alt+cmd+2
To avoid this "VSCode irritation no. 1", you also have, beside "View: Join Editor Group with Next Group", a way to avoid the issue entirely, with VSCode 1.52 (Nov. 2020)
New setting to disable editor group splitting on drag & drop
A new setting workbench.editor.splitOnDragAndDrop allows to disable editor group splitting when using drag & drop of editors.
There is also a way to toggle this conditionally during the drag and drop operation when you press and hold Shift key (macOS) or Alt key (Windows, Linux).
Split current file (Ctrl+\) is a combination I can constantly hitting by mistake so I just removed the shortcut.
Command Palette
Preferences: Open Keyboard Shortcuts (JSON)
Paste the following object in the array:
{
"key": "ctrl+oem_5",
"command": "-workbench.action.splitEditor"
}

Is there a shortcut to switch panel instead of switching tab?

I'm working on VSCode (last version) and sometimes I work with splitted panels.
I can't find a way to achieve same behavior than a Ctrl + Tab but for panels.
It currently sends me to another tab in the current panel.
In vscode these are referred to as editor groups and can be switched between using either:
CTRL+K, CTRL+LeftArrow/RightArrow
to move focus through the editor groups. If you only have two active groups then this is equivalent to what you describe. This is the under Focus Next Group/Focus Previous Group in the keyboard shortcut settings so you could remap this to something else if you prefer.
or
CTRL+1/2/3
To specify focus in editor group 1/2/3

How do I open the same file side by side in a single Visual Studio Code session?

Say I'm reading file xyz.py. And I want to see both func_x and class_y at the same time, so that I don't have to keep on scrolling up and down to go back and forth.
How would I open file xyz.py side-by-side so that I can read both at the same time?
Note: This is different from the question Visual Studio Code: How to split the editor vertically, as it doesn't explain how to have the same window side by side.
In the top right of your screen there should be a split editor button that looks like this:
That should do the trick.
The default keyboard shortcut (on windows) is Ctrl+\
In Command Palette
(Ctrl or ⌘+Shift+P)
Type split e Enter
(Select View: Split Editor)
In sidebar
Alt+Left-click the file
In editor
Click the Split Editor button () in the upper right corner.
None of the above worked for me
but ⌘ + \ worked.

How do I move the panel in Visual Studio Code to the right side?

It's at the bottom by default.
For example in the following image ,panel(Section D) is at the bottom, instead I want it to move to the rightside i.e., in the area where README.md editior shown in Editor Groups(Section C).
Image Credits: (https://code.visualstudio.com/images/codebasics_hero.png)
As of October 2018 (version 1.29) the button in #mvvijesh's answer no longer exists.
You now have 2 options.
Right click the panel's toolbar (nowhere else on the panel will work) and choose "move panel right/bottom":
Or choose "View: Toggle Panel Position" from the command palette.
Source: VSCode update notes: https://code.visualstudio.com/updates/v1_29#_panel-position-button-to-context-menu
For people looking for an answer (on how to move the side panel):
You can press
ctrl + , (Or cmd + , on OSX)
and add the following option to your user settings JSON file:
"workbench.sideBar.location": "right"
I'm using Visual Studio Code v1.24.0 on a Mac.
By default, the Panel will appear on the bottom (You can change the default as well. Please refer to #Forres' answer: Moving Panel in Visual Studio Code to right side)
Here's the bottom/right toggle button for VS Code Panel:
Once I click on this button, the Panel moves to the right.
Moving it back is a little tricky though. As you can see, some of the buttons are hidden. This is because the width of the panel when it's aligned right is too small. We need to expand the column to see all the buttons.
This is how it'll look upon expansion:
Now, if you want to move the Panel back to the bottom, click on the toggle bottom/top button again.
Click menu option View > Appearance > Move Side Bar Right or in settings.json:
"workbench.panel.defaultLocation": "right"
In version 1.55.2.
Go to View --> Appearance --> Move Panel Right
Click menu option View > Appearance > Move to Side Bar Right. Once side bar moves to right, option "Move Side Bar Right" changes to "Move to Side Bar Left".
As of June 2019 this setting can be found through searching 'Panel' - if you want to change the default there is an option for it as shown in the screenshot:
For Visual Studio Code v1.31.1, you can toggle the panel session via the View menu.
Go to the View Menu.
Via the Appearance option, click on Toggle Panel Position
Hope this will help someone.
-> open to keyboard shortcut
-> search for "workbench.action.togglePanelPosition"
-> assign your desired shortcut
I've assigned keybinding "cmd+`"
{
"key": "cmd+`",
"command": "workbench.action.togglePanelPosition"
}
now I can toggle the terminal by pressing "cmd + `"
VSCode 1.42 (January 2020) introduces:
Panel on the left/right
The panel can now be moved to the left side of the editor with the setting:
"workbench.panel.defaultLocation": "left"
This removes the command View: Toggle Panel Position (workbench.action.togglePanelPosition) in favor of the following new commands:
View: Move Panel Left (workbench.action.positionPanelLeft)
View: Move Panel Right (workbench.action.positionPanelRight)
View: Move Panel To Bottom (workbench.action.positionPanelBottom)
You can do the same in insider's edition, There is an option on right top corner to switch to the panel to sidebar https://code.visualstudio.com/insiders/
terminal at the bottom side
terminal at the right side
With v1.64.2 they have brought back the command View: Move Panel Right (or Left). You can put the Panel (which typically has the Terminal/Output/etc. in it) as a vertical column on the left or right side - next to the Side Bar or Side Panel if you wish.
They are working on a fix for the change wrought by v1.64, should be in Insiders v1.65 02/08/2022.
Just use the View: Move Panel Right/Left/Bottom command from the Command Palette.
[Outdated answer, see above.]
As of Stable v1.64 the setting "Wokbench.panel.defaultLocation": "right" will no longer work.
Replacing Panel Location
As mentioned above, the new Side Panel provides similar functionality
as moving the Panel to the left or right, yet improves on this by not
forcing the move of the original panel. Along with view drag and drop
between panels, the new Side Panel is replacing the option to move the
bottom Panel.
In light of that, we have deprecated the
workbench.panel.defaultLocation setting as well as the Move Panel...
commands in favor of similar commands Move Views From Panel To Side
Panel (workbench.action.movePanelToSidePanel) and Move Views From
Side Panel To Panel (workbench.action.moveSidePanelToPanel). The old
commands will remap to the appropriate new command providing the
similiar behavior. Though, we recommend updating your keybindings to
the new commands.
from https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_64.md#replacing-panel-location
This is in favor of using the new Side Panel, which can be in addition to the previous Side Bar (where the Explorer, SCM views traditionally are) and the Panel (where Terminal, Output, etc. traditionally are). So you can have 3 panel-types of views. See more at the v1.64 Release Notes: https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_64.md#new-side-panel
This answer is for people that just want their terminal on the right side (shown above), and don't care about the panel.
Show vscode's Command Palette with keyboard shortcut command + shift + p or ctrl + shift + p
Type in "terminal editor"
Choose option that says Terminal: Create New Terminal in Editor Area to the Side
I don't know since which version it change but the 1.11.2 has an option in View tab which can change the left bar to the right and vice versa
"Wokbench.panel.defaultLocation": "right"
Open settings using CTRL+., search for terminal and you should see this setting at the top. From the drop down below the settings explanation, choose right. See the screenshot below.
As sample as this from the GUI. View->Appearance->Move Side Bar Right
"workbench.panel.defaultLocation": "right",
Go to Command Palette from the wheel icon on the bottom left --> search and enter "settings" menu --> search "panel" in the search bar --> Select Default location as "right" instead of the "bottom".
Reload VS Code, and you're good to go.
By default, ⌘J toggles the (bottom) panel. If all your views are on the side panel, make ⌘J toggle the side panel by doing:
Code > Preferences > Keyboard Shortcuts > "Command+J" > Right-click > Remove Keybinding
Code > Preferences > Keyboard Shortcuts > View: Toggle Side Panel > Add Keybinding > ⌘J
Go to view, then appearence. Then select move panel bottom.
The panel opens on the right by default.
Note that this setting needs to be in a new folder to take effect.
If VSCode has opened the folder before, the panel will still use the old location.
"workbench.panel.defaultLocation": "right",

How do you split and unsplit a window/view in Eclipse IDE?

How do you split a window/view in Eclipse IDE? I want to edit code while viewing the different code in the same file.
If there is a trick to open the same file twice, this might do, but I would rather just split the one current view instead of having two of the same which might get confusing.
This is possible with the menu items Window>Editor>Toggle Split Editor.
Current shortcut for splitting is:
Azerty keyboard:
Ctrl + _ for split horizontally, and
Ctrl + { for split vertically.
Qwerty US keyboard:
Ctrl + Shift + - (accessing _) for split horizontally, and
Ctrl + Shift + [ (accessing {) for split vertically.
MacOS - Qwerty US keyboard:
⌘ + Shift + - (accessing _) for split horizontally, and
⌘ + Shift + [ (accessing {) for split vertically.
On any other keyboard if a required key is unavailable (like { on a german Qwertz keyboard), the following generic approach may work:
Alt + ASCII code + Ctrl then release Alt
Example: ASCII for '{' = 123, so press 'Alt', '1', '2', '3', 'Ctrl' and release 'Alt', effectively typing '{' while 'Ctrl' is pressed, to split vertically.
Example of vertical split:
PS:
The menu items Window>Editor>Toggle Split Editor were added with Eclipse Luna 4.4 M4, as mentioned by Lars Vogel in "Split editor implemented in Eclipse M4 Luna"
The split editor is one of the oldest and most upvoted Eclipse bug! Bug 8009
The split editor functionality has been developed in Bug 378298, and will be available as of Eclipse Luna M4. The Note & Newsworthy of Eclipse Luna M4 will contain the announcement.
You can open a new editor from the Window menu.
This will give you your current editor once again.
If you right click on one of the tabs, one of the options should be New Editor (for me, it's at the bottom). Select that, and then drag the new tab onto the bottom scroll bar of the code editor, which will split the editor panel in two.
Just click and drag editor title to left, right, top or bottom
I tried the above solutions in Eclipse Luna 4.4.1 but couldn't open two (or multiple editor windows for different files side by side).
Simplest Solution:
Open all files you want in a single window.
Drag the tab of each of the files to right or to the left, eclipse will automatically display a split screen display and will split the editor into two windows once you leave the mouse button.
repeat for each file/tab.
Happy Coding!
Side by side editors in single Eclipse window.
You have an Eclipse window showing a single editor.
Window -> new editor. You now have two editor tabs.
Click and drag one tab towards the right and a green outline of a vertical screen appears (drag tag towards the bottom and an outline of a horizontal screen outline appears). You can let go as soon as the outline appears.
Open file of choice in 2nd editor (recent files show up at bottom of file menu).
ADT/Eclipse:Build: v22.3.0-887826
You might want to check an eclipse plugin called HandySplit
It allows to split an editor into two and move tabs from one editors stack to another with keyboard shortcuts only.
That works on Eclipse Juno or higher.
For the previous Eclipse versions check this out
Simply go to Window > New Window
This will open up a new window of the same Workspace in eclipse.
You can open up separate files in each Window.
Below are the steps to split editor horizontally or vertically
go to:
Window -> Editor -> Toggle Split Editor (Horizontal)
to split editor horizontally or
Window -> Editor -> Toggle Split Editor (vertical)
to split editor vertically.
It will open two editors side by side or will pileup tow.
If you want to see two different files in same eclipse you can,
Right-click a tab -> Detach
Now you can see both files at the same time without opening new eclipse and you can drag and reatach to tabs again.
On Mac OS, the key combination to toggle spit/unsplit for horizontal split is ⌘ ⇧ - ("cmd"+"shift"+"-"), whereas for vertical split, it is ⌘ ⇧ [ ("cmd"+"shift"+"[")