1

I would like to setup a custom key binding in vscode that passes @: as an argument (or prefix) to the Command Palette, through the workbench.action.quickOpen command. The @: prefix is meant to show all symbols by category. I essentially want a single key binding that performs the following two steps:

  1. Command + P (to open the command palette)
  2. @: (to show and then search symbols sorted by category)

I have tried the following in my keybindings.json, but it only opens the Command Palette without passing the @: text as an argument or prefix:

    {
      "key": "ctrl+l",
      "command": "extension.multiCommand.execute",
      "args": { "command": "workbench.action.quickOpen", "text": "@:"},
    }
Razzle
  • 13
  • 3
  • related command: `Go To Symbol in Editor` (`workbench.action.gotoSymbol`) (opens with `@`, but not `@:`) but does that command solve your problem? – starball May 12 '23 at 21:21
  • Thanks. Unfortunately the `gotoSymbol` command does not sort by category and there does not seem to be a `workbench.action` to mimic the `@:` prefix, so I'm looking for a way to pass it in as an argument. – Razzle May 13 '23 at 02:11

1 Answers1

1

Use this keybinding:

{
    "key": "ctrl+l",
    "command": "workbench.action.quickOpen",
    "args": "@:"   
},

The argument is quite simple, you would expect something like:

"args": {
   "text": "@:"    // ERROR
}

but the correct form is just

"args": "@:"      // GOOD

probably a historical artifact of being an early command before the arguments got more standardized.

And you don't need multiCommand, it isn't helpful here.

Mark
  • 143,421
  • 24
  • 428
  • 436