Home > Mobile >  How to hide and show side bar pane with the same shortcut in Visual Studio code
How to hide and show side bar pane with the same shortcut in Visual Studio code

Time:03-18

I hide the following shortcut for VS Code on MacOS:

  {
    "key": "cmd 1",
    "command": "workbench.scm.focus"
  },

What that is focus on the source control pane and show it if the side bar is not visible. What I want now is to to hide the side pane when I click Cmd 1 again and the scm pane is open. Right now I can hide the side pane with Cmd B:

enter image description here

Is there a way to change that? I have been trying to make a conditional shortcut but I have not found the way.

CodePudding user response:

I'm not sure I understand your flow, but have you looked at the when clause contexts?

Find a list here: enter image description here

CodePudding user response:

  {
    "key": "cmd 1",
    "command": "workbench.scm.focus",
    "when": "!workbench.scm.visible"
  },
  {
    "key": "cmd 1",
    "command": "workbench.action.toggleSidebarVisibility",
    "when": "workbench.scm.visible"
  },
  • Related