VS Code 键盘快捷方式的 JSON 配置完整
时间: 2024-03-18 10:41:12 浏览: 23
VS Code 键盘快捷方式的 JSON 配置文件路径为:
- Windows:`%APPDATA%\Code\User\keybindings.json`
- macOS:`$HOME/Library/Application Support/Code/User/keybindings.json`
- Linux:`$HOME/.config/Code/User/keybindings.json`
以下是一个完整的 VS Code 键盘快捷方式的 JSON 配置文件示例:
```json
[
{
"key": "ctrl+n",
"command": "workbench.action.files.newUntitledFile",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+n",
"command": "workbench.action.files.newFolder",
"when": "explorerViewletVisible"
},
{
"key": "ctrl+o",
"command": "workbench.action.files.openFile",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+o",
"command": "workbench.action.files.openFolder",
"when": "explorerViewletVisible"
},
{
"key": "ctrl+s",
"command": "workbench.action.files.save",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+s",
"command": "workbench.action.files.saveAs",
"when": "editorTextFocus"
},
{
"key": "ctrl+c",
"command": "editor.action.clipboardCopyAction",
"when": "editorTextFocus"
},
{
"key": "ctrl+v",
"command": "editor.action.clipboardPasteAction",
"when": "editorTextFocus"
},
{
"key": "ctrl+x",
"command": "editor.action.clipboardCutAction",
"when": "editorTextFocus"
},
{
"key": "ctrl+z",
"command": "undo",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "shift+ctrl+z",
"command": "redo",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+f",
"command": "actions.find",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+f",
"command": "workbench.action.findInFiles",
"when": "editorTextFocus"
},
{
"key": "f12",
"command": "editor.action.goToDeclaration",
"when": "editorHasDefinitionProvider && editorTextFocus && !inReferenceSearchEditor"
},
{
"key": "ctrl+shift+oem_2",
"command": "workbench.action.showCommands",
"when": "inQuickOpen && inWindowsPicker && pickerRowsVisible"
}
]
```
该配置文件中包含了常用的文件操作、剪切、复制、粘贴、撤销、重做、查找、跳转等快捷方式的配置。其中,`key` 字段表示快捷键,`command` 字段表示要执行的命令,`when` 字段表示在何种情况下可以执行该命令。可以根据自己的需求对快捷方式进行配置。