如何拆分一个编辑器,从2个代码视图返回到1,终端也一样

如何拆分一个编辑器,从2个代码视图返回到1,终端也一样。

33680 次浏览

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

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)

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

ctrl+\ to split ctrl+w to unsplit

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.

  1. Command Palette

  2. Preferences: Open Keyboard Shortcuts (JSON)

  3. Paste the following object in the array:

    { "key": "ctrl+oem_5", "command": "-workbench.action.splitEditor" }