如何在 Visual Studio Code 中更改键盘快捷键绑定? [英] How can I change keyboard shortcut bindings in Visual Studio Code?
问题描述
使用 Visual Studio Code 的过程是什么:
Using Visual Studio Code what is the procedure to:
重新映射内置命令的键盘快捷键.例如,比如说,打开文件(默认为 Ctrl+O,实际上任何人都不太可能改变它,但相同的过程可能适用于任何内置快捷方式).
Remap a built in command's keyboard shortcut. For example, say, Open File (default is Ctrl+O, it's unlikely that anyone would actually change this, but the same process should probably apply for any built in shortcut).
重新映射扩展命令的键盘快捷键,比如书签扩展的切换书签(默认 Ctrl+Alt+K)
Remap an extension command's keyboard shortcut, say the Bookmark extension's toggle-bookmark (default Ctrl+Alt+K)
在 2015 年,这涉及编辑配置 JSON 文件,但我不知道是哪一个,也不知道如何编辑.2021 年会有新的用户界面,我如何找到它?
IN 2015, this involved editing configuration JSON files, but I don't know which one, or how. In 2021 there's a new UI, how do I find it?
推荐答案
点击文件 ->首选项 ->键盘快捷键.使用打开的选项卡编辑和查找可用的键绑定并分配它们.
Click File -> Preferences -> Keyboard shortcuts. Use the tab that opens up to edit and find available key bindings and assign them.
历史注释:在早期版本的 Visual Studio 代码中,您将单击文件 ->首选项 ->键盘快捷键,你会得到这样的 JSON keybindings.json
:
Historical Note: In very early versions of visual studio code, you would Click File -> Preferences -> Keyboard shortcuts and you would get JSON like this keybindings.json
:
// Place your key bindings in this file to overwrite the defaults
[
{ "key": "ctrl+o", "command": "workbench.action.files.openFile" },
{ "key": "ctrl+alt+k", "command": "bookmarks.toggle",
"when": "editorTextFocus" }
]
但是现在在 2021 版本中,有一个适当的 GUI,这很好,因为 json 编辑方法容易出错且难以发现.
But now in 2021 versions, there is a proper GUI, which is great because the json editing method was error prone and hard to discover.
json 编辑器功能已移至新图标:
The json editor feature has been moved to a new icon:
这篇关于如何在 Visual Studio Code 中更改键盘快捷键绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!