Search code examples
visual-studio-codekeyboard-shortcuts

How to undo split screen and show just current file?


VS Code provides shortcuts for manipulating (splitting and rearranging) screens:

  1. Press Ctrl + \ to split your screen in two.
  2. Press Ctrl + Number to focus on one of the screeens
  3. Press Ctrl + Shift + 0 to change vertical/horizontal split

However, how do I remove all the split screens and just show the currently focused one?

Example: say I press Ctrl + \ twice (gives me three vertical screens), then press Ctrl + 2 to select middle screen. What should I press now to make left and right screen disappear and middle screen occupy the whole space?


Solution

  • See if this keybinding does what you want:

    {
      "key": "alt+q",
      "command": "workbench.action.closeEditorsInOtherGroups"
    }
    

    There is no default keybinding for the command workbench.action.closeEditorsInOtherGroups so I made up that one. I think it accomplishes what you want. It will close the other editor groups and keep you at the focused group.

    Alternatively you can set a shortcut such as:

    {
      "key": "alt+q",
      "command": "workbench.action.joinAllGroups"
    }
    

    This merges all open Groups into one window instead of closing all the unfocused ones.

    Both shortcuts can also be set in the GUI by "Ctrl + Shift + P" -> Preferences: Open Keyboard Shortcuts.