Is there any keybinding in VSCode that can hide Explorer, like Ctrl+Shift+E works for showing it?
I hate reaching for the mouse and I don't have enough screen space to keep Explorer always on.
Is there any keybinding in VSCode that can hide Explorer, like Ctrl+Shift+E works for showing it?
I hate reaching for the mouse and I don't have enough screen space to keep Explorer always on.
Toggle Sidebar Visibility: Ctrl+B (Windows/Linux)
If you're a MacOS user, then it's ⌘ + b.
Ctrl + /
on the first installment. In case anyone's wondering about the actual keybinds.json
name, it's workbench.action.toggleSidebar
.
Shift+B
is better choice for workbench.action.toggleSidebar
if there is a vim plugin using Ctrl+B
Aug 14, 2021 at 7:53
Some clarification: usually Ctrl+B
is used for closing a sidebar (not toggling by default). So if you haven't a sidebar and want to open it - press the following combination: Ctrl+Shift+E
(opens the sidebar with active explorer) or Ctr+Shift+F
(with active search) etc. Now if you want to get rid of a sidebar press Ctrl+B
. Note if you're using vim plugin and want to close a sidebar but currently is working on your code - first make a sidebar active by pressing (Ctrl+Shift+E
) and then close it via Ctrl+B
.
update: recently I've discovered that Ctrl+Shift+E
doesn't play nice with my neo vim plugin, so in order to overcome it there is another shortcut to open sidebar explorer: single press of Ctrl+0
to open it and pressing of Ctrl+0
one more time to get focus on it.
I'm using Visual Studio keymap. On my keyboard shortcuts, Toggle Side Bar Visibility was set to CTRL+B but doesn't works.
I do remap to CTRL+B and works fine.
File > Preferences > KeyBoard ShortCuts
VSCode default Keybinding for Toggling "Side Bar" aka "Explorer" is CTRL+B. Just CTRL+B alone works fine.
If you want to use cmd+b to open and close your explorer add these lines to your keybindings.json
{
"key": "cmd+e",
"command": "workbench.view.explorer"
},
{
"key": "cmd+e",
"command": "-workbench.view.explorer"
},
{
"key": "cmd+e",
"command": "workbench.action.toggleSidebarVisibility",
"when": "explorerViewletVisible"
},
{
"key": "cmd+e",
"command": "-workbench.action.toggleSidebarVisibility",
"when": "explorerViewletVisible"
},
Of course, you must replace the "e" with "b" !
This is an extension of @tsm's answer.
If you want to toggle Explorer
using ctrl+e
then use the following keybindings.
{
"key": "ctrl+e",
"command": "-workbench.action.quickOpen"
},
{
"key": "ctrl+e",
"command": "-workbench.action.quickOpenNavigateNextInFilePicker",
"when": "inFilesPicker && inQuickOpen"
},
{
"key": "ctrl+b",
"command": "-workbench.action.toggleSidebarVisibility"
},
{
"key": "ctrl+e",
"command": "workbench.view.explorer"
},
{
"key": "ctrl+e",
"command": "workbench.action.toggleSidebarVisibility",
"when": "activeViewlet == 'workbench.view.explorer' || activeViewlet == 'workbench.view.search'|| activeViewlet == 'workbench.view.scm'|| activeViewlet == 'workbench.view.debug'|| activeViewlet == 'workbench.view.extensions' || activeViewlet == 'workbench.view.extension.test'|| activeViewlet == 'workbench.view.extension.bookmarks'|| activeViewlet == 'workbench.view.extension.project-manager' || activeViewlet == 'workbench.view.extension.gitlens'|| activeViewlet == 'workbench.view.extension.todo-tree-container'|| activeViewlet == 'snippet-explorer'"
}
Here, the first two keybindings are to unbind ctrl+e
. So, it depends on which commands you are currently using with ctrl+e
.
the third keybinding is to unbind ctrl+b
as you will no longer need ctrl+b
to Toggle Sidebar Visibility.
The fourth keybinding is to view explorer using ctrl+e
.
Now the interesting part. The fifth keybinding. Here, I am saying: "if sidebar is open and I press ctrl+e
then close the sidebar."
Please understand that, one of the way to open a Sidebar
is to click one of the Sidebar Icons
. When we click on a particular Sidebar Icon
, we get it's corresponding Sidebar View
.
To create this keybinding we have to get all the Contexts
(in this case, value of activeViewlet
) of each Sidebar Views
.
How to get Contexts
can be found on VSCODE Accurate keybinding, want to know current context. How to do?. This same information can also be found on the documentation.
So, long story short, I found the contexts by running Developer: Inspect Context Keys
in command pallet and observing the Developer Tools
.
Help > Toggle Developer Tools
).Developer: Inspect Context Keys
in command palletactiveViewlet
) of.Now, add these contexts (for example workbench.view.explorer
, workbench.view.search
, workbench.view.scm
etc.) in the when
key.
Update 1:
You actually do not need to find the contexts. You can just use:
{
"key": "ctrl+e",
"command": "workbench.action.toggleSidebarVisibility",
"when": "activeViewlet != ''"
}
Instead of
{
"key": "ctrl+e",
"command": "workbench.action.toggleSidebarVisibility",
"when": "activeViewlet == 'workbench.view.explorer' || activeViewlet == 'workbench.view.search'|| activeViewlet == 'workbench.view.scm'|| activeViewlet == 'workbench.view.debug'|| activeViewlet == 'workbench.view.extensions' || activeViewlet == 'workbench.view.extension.test'|| activeViewlet == 'workbench.view.extension.bookmarks'|| activeViewlet == 'workbench.view.extension.project-manager' || activeViewlet == 'workbench.view.extension.gitlens'|| activeViewlet == 'workbench.view.extension.todo-tree-container'|| activeViewlet == 'snippet-explorer'"
}
I have to say CTRL+B
stands for calling out the sider bar.
To hide the sider bar, you should type: CTRl+\