0

I want to execute 2 commands on 1 hotkey "F4"

  1. workbench.action.toggleSidebarVisibility
  2. workbench.action.toggleActivityBarVisibility

I am trying to use this code, but it doesn't work.

{
  "key": "F4",                
  "command": "workbench.action.toggleSidebarVisibility && workbench.action.toggleActivityBarVisibility" 
}

2 Answers 2

2

Not possible, at least not as of today with a vanilla installation.

But you can try this extension here, it creates macros from multiple commands, which can then be bound to a shortcut: https://marketplace.visualstudio.com/items?itemName=geddski.macros

1

Another way to achieve this without an extension:

  1. Run "Tasks: Open User Tasks" command to create or open a user level tasks file.

  2. Define commands as separate tasks, like so:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "my-f4-1",
            "command": "${command:workbench.action.toggleSidebarVisibility}"
        },
        {
            "label": "my-f4-2",
            "command": "${command:workbench.action.toggleActivityBarVisibility}"
        },
        {
            "label": "my-f4",
            "dependsOrder": "sequence",
            "dependsOn": [
                "my-f4-1",
                "my-f4-2"
            ],
            "problemMatcher": []
        }
    ]
}
  1. In your keybindings.json:
{
    "key": "f4",
    "command": "my-f4"
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.