Not sure if you/others will agree but it would be nice to be able to open (collapsed) SideBar panel (eg. Explorer) and close it with the same shortcut.
I mostly work with hidden Activity Bar and Side bar and when I need for example Explorer for a moment:
Cmd+Shift+E (my hand stays over that key combination)Cmd+Shift+E combination does not toggle/close Panel - I need to switch to Cmd+B to closeMaybe additional setting or logic that if panel got open due to shortcut (while hidden) one can close with the same key combinations - seems the most natural
I think the argument against this (and one I'd go along with) is that if you even if you have the explorer sidebar open, you might want to focus it, and it's good to know that ctrl+shift+e will always do this whether it's open or not.
Maybe you could argue that if the panel has focus, then the shortcut should close it, but that's making the behavior a bit complicated
There is a solution for your particular case though. You can add custom keybindings that only trigger in certain situations through the when field of the keybinding entry. This is documented at the bottom of the page at https://code.visualstudio.com/docs/customization/keybindings. There doesn't seem to be an existing when option for when the explorer panel has focus, but you can achieve the same thing by saying: "when the editor doesn't have focus".
It's a bit hacky but if you add this to your keybindings.json file, you should get the behavior you want:
{
"key": "ctrl+shift+e",
"when": "!editorTextFocus",
"command": "workbench.action.toggleSidebarVisibility"
}
@stkb That works like a charm. Thanks so much
Most helpful comment
I think the argument against this (and one I'd go along with) is that if you even if you have the explorer sidebar open, you might want to focus it, and it's good to know that
ctrl+shift+ewill always do this whether it's open or not.Maybe you could argue that if the panel has focus, then the shortcut should close it, but that's making the behavior a bit complicated
There is a solution for your particular case though. You can add custom keybindings that only trigger in certain situations through the
whenfield of the keybinding entry. This is documented at the bottom of the page at https://code.visualstudio.com/docs/customization/keybindings. There doesn't seem to be an existingwhenoption for when the explorer panel has focus, but you can achieve the same thing by saying: "when the editor doesn't have focus".It's a bit hacky but if you add this to your keybindings.json file, you should get the behavior you want: