如何在VS Code中向一个命令添加多个键盘快捷键?

时间:2020-06-06 17:56:05

标签: visual-studio-code vscode-settings

如何在VS Code中为单个命令添加多个键盘快捷键?

作为一个示例(从注释中),ctrl + 0ctrl + 1应该都执行相同的命令/动作。因此,完全相同的快捷键可以执行相同的命令。

1 个答案:

答案 0 :(得分:1)

假设有2种绑定来关闭窗口,如下所示:

enter image description here

假设我们要再添加一个键绑定,例如CMD + K,CMD + 1。您可以通过右键单击命令并选择复制来做到这一点:

enter image description here

然后,单击右上角的图标以打开键盘快捷键JSON。该图标在页面上具有弯曲的箭头:

enter image description here

您的用户定义的键绑定。将显示JSON。在其中输入:

// Place your key bindings in this file to override the defaults
[
    {
        "key": "cmd+k cmd+1",
        "command": "workbench.action.closeWindow"
    }
]

保存并关闭。

现在,您将看到以下3个键绑定操作:

enter image description here

现在,尝试新的键盘绑定。