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

huangapple go评论64阅读模式
英文:

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

问题

我最近开始在VS Code中使用配置文件,并且在大多数情况下都表现不错,但我找不到一种定义适用于所有配置文件的自定义键绑定的方法。以下是我已经能够找出的信息:

  1. 用户键绑定存储在 Code/User/keybindings.json 中。
  2. 配置文件键绑定存储在 Code/User/profiles/<profile ID>/keybindings.json 中。
  3. 如果我通过GUI(⌘K ⌘S)添加/编辑键绑定,它将保存在配置文件中,而不是用户中,并且不会在其他配置文件中可用。
  4. 如果我通过 User/keybindings.json 添加/编辑键绑定,它将仅在默认配置文件中可用,而不会在其他配置文件中可用。

不确定这是一个错误还是一个功能,但在使用配置文件时是否有一种定义全局键绑定的方法?

英文:

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/&lt;profile ID&gt;/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?

答案1

得分: 0

请查看 Insiders 中的“Partial Profiles”功能,现在和 2023 年 8 月初的 Stable 版本。

支持部分配置文件

您现在可以创建一个配置文件,只能自定义一部分配置(设置、键盘快捷键、代码片段、任务和扩展)。例如,您可以创建一个配置文件,包括除了键盘快捷键以外的所有配置,当此配置文件处于活动状态时,VS Code 将应用默认配置文件中的键盘快捷键。以下图片显示了创建这种配置文件的用户界面。

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

您还可以通过从配置文件模板或从现有配置文件复制来创建部分配置文件,使用下拉菜单显示在下图中。

从我的测试中,如果您创建一个没有选择键盘快捷键的配置文件,那么您在默认配置文件中创建的任何快捷键都将在新配置文件中可用。而在新配置文件处于活动状态时创建的快捷键将可用于默认配置文件,但显然不可用于在选择“部分配置文件”选项之前创建的其他配置文件。

这可能是修改任何现有配置文件的更好方法:

您还可以通过编辑配置文件,如下图所示,来配置现有配置文件以使用默认配置文件中的配置。

[与上图相同的图片]

在导出这样的配置文件时,您可以选择仅导出在配置文件中自定义的配置,或者还包括默认配置文件中的配置。以下图片显示了导出配置文件的用户界面。

英文:

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.
>

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

>
> 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.

huangapple
  • 本文由 发表于 2023年4月6日 23:15:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/75951122.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定