Search code examples
visual-studio-codekeyboard-shortcuts

Visual Studio Code: is there a way to define global keybindings that apply to all profiles?


I recently started using Profiles in VS Code and it's been great for the most part, but I can't find a way to define custom keybindings that apply globally to all profiles. Here's what I've been able to figure out:

  1. User keybindings are stored in Code/User/keybindings.json.
  2. Profile keybindings are stored in Code/User/profiles/<profile ID>/keybindings.json.
  3. If I add/edit a keybinding through the GUI (⌘K ⌘S) it will save to the Profile, not the User, and it won't be available in other profiles.
  4. If I add/edit a keybinding through User/keybindings.json it is not available in any profiles except the Default profile.

Not sure if this is a bug or a feature, but is there a way to define global keybindings when using Profiles?


Solution

  • Have a look at Partial Profiles in Insiders now and Stable v1.81 early August 2023.

    Support for Partial Profiles

    You can now create a profile in which you can customize only a subset of configurations (Settings, Keyboard Shortcuts, Snippets, Tasks & Extensions). For example, you can create a Profile with all configurations except for Keyboard Shortcuts, and VS Code will apply the keyboard shortcuts from the Default Profile when this Profile is active. Following picture shows the UI for creating such a Profile.

    partial profiles image

    You can also create a partial profile by copying from Profile Templates or from an existing Profile using the dropdown menu which is shown in the following picture.

    From my testing, if you create a profile without the Keyboard Shortcuts selected, any shortcuts you create in the Default Profile will be available in your new profile. And a shortcut you create while your new profile is active will be available in the Default profile but apparently NOT in other profiles created before the option to make a "partial profile".

    This may be a better route for you to modify any existing profiles:

    You can also configure an existing Profile to use configurations from the Default Profile by editing the Profile like shown in the following picture.

    [same image as above]

    When exporting such a profile you can choose to export only the configurations that are customized in the Profile or also includes the configurations from the Default Profile. The following picture shows the UI for exporting a Profile.