Closing Multiple Panels in VS Code


Problem

In VS Code I often find myself with multiple panels open (the terminal and the sidebar). I have keyboard shortcuts (cmd+b and cmd+t) to toggle the panels.

If the terminal isn't focused, then I have to do cmd+t twice to close. Once to focus, then again to toggle it off.

So in the end when I want to close all the panels and just focus on writing code I have to do cmd+t cmd+t cmd+b just to get to writing.

There has to be a way to close multiple panels at once.

Solution

The Commands extension. You could do a lot of powerful things with this extension. But for now, this is what I did to close both panels at once.

I added this to my settings.json to create a sequence of commands.

"commands.commands": {
    "Close Panels": {
        "sequence": [
            "workbench.action.closePanel",
            "workbench.action.closeSidebar"
        ]
    }
}

Then I added this to my key bindings to get have the command run with the chord cmd+k cmd+m.

{
    "key": "cmd+k cmd+m",
    "command": "Close Panels"
}

Now it's super easy to close panels and get to writing code. I love little things like this to improve my workflow.



Other posts you might enjoy...
11 May, 2021
Mac Mail error occurred while moving messages to mailbox
23 Mar, 2025
Upgrading to PHP 8.1
10 Apr, 2020
Smart Semicolon