Vscode: Add a way to bind a keybinding for a command from the F1 list

Created on 31 May 2017  ·  13Comments  ·  Source: microsoft/vscode

I think we've discussed this, but we've never written it down.

IMHO, it would be very helpful to have an alternative action next to each command in the F1 list (similar how open to the side is an alternative action in the ctrl+p file list) that when executed would bring up the keybindings editor with the action selected and will execute the "edit" action on that command.

e.g. I use Git: Stage Selected Ranges and today I always run it from the F1 list because it is not bound. It would be nice to have an action that allows me to record a keybinding for it such that I can easily map it.

feature-request insiders-released keybindings quick-pick

Most helpful comment

With the new quick access for commands this is relatively easy to add by adding the following:

buttons: [{
  iconClass: 'codicon-gear',
  tooltip: localize('customizeTask', "Configure Keybinding")
}],
trigger: () => {
  // Open keybindings editor etc...
  return TriggerAction.CLOSE_PICKER;
}

to this object:

https://github.com/microsoft/vscode/blob/b5a2ab1e1093fd35c849f2096de1f8b85582b0e8/src/vs/platform/quickinput/browser/commandsQuickAccess.ts#L138

It looks a bit overcrowded though:

Kapture 2020-03-12 at 10 43 04

All 13 comments

This is relatively simple, I just helped Dirk to get actions into the task quick open.

@sandy081 if there is API I can use to do what @alexandrudima is suggesting, I can add such an action. E.g. it could show up with a gear icon similar to how Dirk is doing it for tasks:

image

However we also have to think about how often people are using the commands picker and how many want such a prominent action.

@bpasero There is no API to show the keybinding defining widget. But I can do it.

With the new quick access for commands this is relatively easy to add by adding the following:

buttons: [{
  iconClass: 'codicon-gear',
  tooltip: localize('customizeTask', "Configure Keybinding")
}],
trigger: () => {
  // Open keybindings editor etc...
  return TriggerAction.CLOSE_PICKER;
}

to this object:

https://github.com/microsoft/vscode/blob/b5a2ab1e1093fd35c849f2096de1f8b85582b0e8/src/vs/platform/quickinput/browser/commandsQuickAccess.ts#L138

It looks a bit overcrowded though:

Kapture 2020-03-12 at 10 43 04

This is cool! But I agree it looks funny when the keybindings are pushed out of the way.

If you leave the gear icon space “reserved”, the funny behavior would go away. But you end up with less space available for command description/shortcuts.

Another idea would be adding the gear icon at the top of the QuickPick, similar to what you have while using multi-step QuickPicks. But if I remember correctly, this would add a Header to the QuickPick 😕 .

Maybe @misolori has some ideas?

@bpasero could we change the order and place the gear on the left-most side of the keybindings?

There is currently just one fixed location for actions in the quick pick widget, we would have to add another action bar. Maybe post a screen shot from Figma what you think about to check how it looks?

Something like this:

image

Yes, that is doable. We currently create the container for keybindings first and then the action bar but we can probably flip that:

https://github.com/microsoft/vscode/blob/5cb962bbd60f6cffd71e9d900e253b6a74163567/src/vs/base/parts/quickinput/browser/quickInputList.ts#L133

I am not sure though that having an action at varying positions is a good idea for users to use.

Another alternative, hold down option (or some other key) and we hide the keybinding and show a blue "Set/Change Keybinding"? Less discoverable but also doesn't clutter up the UI. We do this in other place like closing multiple tabs.

Personally, I'm not sure how useful it is to have this but using it via option provides the best of both worlds.

Any way the gearwheel could replace the existing keybinding symbols when the mouse goes over one of them?

Any way the gearwheel could replace the existing keybinding symbols when the mouse goes over one of them?

That will be problematic for accessibility reasons we cannot do this only on mouse hover, it would have to be on the selected item as well. This would mean the selected (e.g. first) item would never show its keybinding, which imho defeats the purpose.

Added Configure Keybinding button (Gear icon) to the commands quick pick -

image

Clicking on it opens the Keyboard Shortcuts Editor showing above command

image

User can configure keybinding for this command from the editor.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

curtw picture curtw  ·  3Comments

vsccarl picture vsccarl  ·  3Comments

villiv picture villiv  ·  3Comments

shanalikhan picture shanalikhan  ·  3Comments

omidgolparvar picture omidgolparvar  ·  3Comments