Reputation: 3102
It would be very useful for me if there was a keyboard shortcut for moving focus to the sidebar in Visual Studio Code. I have seen the question Is there a shortcut to hide the side bar in Visual Studio Code? but this is not what I want.
I want to get focus there without using the mouse so that I can select another file listed in the sidebar without having to use the mouse.
Upvotes: 66
Views: 44430
Reputation: 340
I am aware of a shortcut Ctrl + B
to toggle the sidebar open and close.
Upvotes: 1
Reputation: 11323
Ctrl
0
is the default binding of View: Focus into Side Bar command that focuses sidebar regardless what it shows at the moment - be it Explorer, Source Control, Extensions or any other pane. (Or reveals its last visible state.)
Zero (0
) in this key combination represents character that "English-keyboard-layout" zero key in the top 'numerical' row produces in current regional keyboard layout. It is not the zero key in the "NumPad".
Like most other commands it is discoverable either in the Command Palette (F1 or CtrlShiftP):
(N.B. é
instead of 0
due to aforementioned regional layout in effect), or in the Keyboard Shortcuts settings page (CtrlK CtrlS):
Btw Ctrl1 .. 3 focuses editor groups respectively.
If you'd like to have this (or other) key combination to act like two way "focus toggle" between editor and sidebar (like Show Explorer
behaves), you can alter your settings accordingly using distinct actions with identical key combination differentiated by excluding "when"
conditions. Resulting part of keybindings.json
would then be:
{ // Unbind unconditional default using "minus" (-) before command
"key": "ctrl+0",
"command": "-workbench.action.focusSideBar"
},
{ // Move focus to the SideBar if not (!) there
"key": "ctrl+0",
"when": "!sideBarFocus",
"command": "workbench.action.focusSideBar"
},
{ // Move focus to the Editor, if currently in the SideBar
"key": "ctrl+0",
"when": "sideBarFocus",
"command": "workbench.action.focusActiveEditorGroup"
},
Upvotes: 122
Reputation: 2210
Mine, on windows, numpad key doesn't work. I have to use the other Zero key that is on the top of the keyboard.
Upvotes: 0
Reputation: 1552
you can hover over the icons in the sidebar if you want a tooltip telling you what shortcut each tab has
Upvotes: 7
Reputation: 2780
These are the different shortcuts to focus on the various components(in order of the icons) of the sidebar.
File Explorer: ctrlshifte
Search: ctrlshiftf
Source Control: ctrlshiftg
Debug: ctrlshiftd
Extensions: ctrlshiftx
To toggle the visibility of the sidebar, just press ctrlb
Upvotes: 36