aronchick
aronchick

Reputation: 7128

Is there a keycommand to toggle maximal editor space in VSCode

I'm looking for something that basically combines cmd+B (show/hide sidebar) and cmd+J (show/hide terminal).

I've tried searching around but everything seems like there's only one per. Thanks!

Upvotes: 0

Views: 60

Answers (1)

Mark
Mark

Reputation: 180855

[ I assume you know about zen mode but are looking for something different. ]

I think the easiest way to do this is with a macro extension, here using multi-command.

Put this into your keybindings.json:

{
    "key": "alt+u",                // whatever keybinding you want
    "command": "extension.multiCommand.execute",
    "args": {
        "sequence": [
            "workbench.action.maximizeEditor",
            "workbench.action.closePanel"
        ]
    },
    "when": "panelVisible && sideBarVisible"
},
{
    "key": "alt+u",
    "command": "extension.multiCommand.execute",
    "args": {
        "sequence": [
            "workbench.action.toggleSidebarVisibility",
            "workbench.action.togglePanel",
            "workbench.action.focusActiveEditorGroup"
        ]
    },
    "when": "!panelVisible && !sideBarVisible"
},
{
    "key": "alt+u",
    "command": "extension.multiCommand.execute",
    "args": {
        "sequence": [
            "workbench.action.toggleSidebarVisibility",
        ]
    },
    "when": "!panelVisible && sideBarVisible"
},
{
    "key": "alt+u",
    "command": "extension.multiCommand.execute",
    "args": {
        "sequence": [
            "workbench.action.togglePanel",
            "workbench.action.focusActiveEditorGroup"
        ]
    },
    "when": "panelVisible && !sideBarVisible"
}

I made it, by using the when clauses, to be a toggle. So the same keybinding would close both the sideBar and Panel if they are open or open them both if they are both closed.

Then I added the last two cases where one or the other of the sideBar or Panel is closed but not both. You may not care about those two cases.

By the way, this will maximize the current editor group if there are multiple groups.

Upvotes: 1

Related Questions