visual-studio-codetabs

How can I close all tabs included pinned tabs in VS Code?


How can I close all the tabs in VS Code 1.83 including the Pinned tabs?

As far as I understood, some people say if you right-click on any tab you have an option as "Close All But Pinned" option e.g. Keyboard shortcut to close all tabs but pinned in Visual Studio?

I do not have such an option when I rightclick on any tabs. However, if I even had such an option it does not help me as I want all the tabs included the pinned tabs bein closed.

Anyone knows how could I do that. This is my menu when I right click on any tabs.

Even "close all" does not close the pinned tabs.


Solution

  • If you're okay with closing all editor groups, then you can use the View: Close All Editor Groups command in the command palette, which is bound by default to ctrl/cmd+k,ctrl/cmd+shift+w. By virtue of closing the entire editor group(s- all of them), that'll "close" the pinned tabs. If you want to bind a different keyboard shortcut, its command ID is workbench.action.closeAllGroups. There's also workbench.action.closeGroup and workbench.action.closeEditorsAndGroup (if you only want to close current editor group).


    There's also the View: Close All Editors command, which is bound by default to ctrl/cmd+k,ctrl/cmd+w, but that doesn't (at least- not at the time of this writing) close pinned tabs- even if you change your workbench.editor.preventPinnedEditorClose setting to "never" or "mouse". If you take this route, you could still close the remaining pinned tabs pretty quickly by rapidly clicking your middle mouse button on the tab handles or in the Open Editors subview of the Explorer View as long as you've set your workbench.editor.preventPinnedEditorClose setting to "never" or "mouse". You could also write a keyboard shortcut using runCommands and just spam workbench.action.closeActiveEditor:

    // in keybindings.json (use `Preferences: Open Keyboard Shortcuts (JSON)` in command palette)
    {
        "key": "", // TODO
        "command": "runCommands",
        "args": {
            "commands": [
                "workbench.action.closeActiveEditor",
                "workbench.action.closeActiveEditor",
                "workbench.action.closeActiveEditor",
                // and so on...
            ],
        },
    },