Skip to content

vscode 自定义快捷键设置

json
[
    // --- 全局命令
    // 显示命令面板
    {
        "key": "ctrl+g c",
        "command": "workbench.action.showCommands"
    },
    // 打开设置页面
    {
        "key": "ctrl+g s",
        "command": "workbench.action.openSettings"
    },
    // 打开热键映射
    {
        "key": "ctrl+g k",
        "command": "workbench.action.openGlobalKeybindings"
    },
    // 打开一个目录
    {
        "key": "ctrl+g m",
        "command": "workbench.action.files.openFolder"
    },
    // 打开一个文件
    {
        "key": "ctrl+g f",
        "command": "workbench.action.files.openFile"
    },
    // 打开最近记录
    {
        "key": "ctrl+g r",
        "command": "workbench.action.openRecent"
    },
    // 新建vscode实例
    {
        "key": "ctrl+g n",
        "command": "workbench.action.newWindow"
    },
    // 关闭vscode实例
    {
        "key": "ctrl+g q",
        "command": "workbench.action.closeWindow"
    },
    // --- 文件命令
    // 新建文件
    {
        "key": "ctrl+e n",
        "command": "welcome.showNewFileEntries",
    },
    // 打开文件
    {
        "key": "ctrl+e o",
        "command": "workbench.action.files.openFileFolder"
    },
    // 另存为文件
    {
        "key": "ctrl+e e",
        "command": "workbench.action.files.saveAs"
    },
    // 保存文件
    {
        "key": "cctrl+e s",
        "command": "workbench.action.files.save"
    },
    // 保存所有文件
    {
        "key": "ctrl+e w",
        "command": "workbench.action.files.saveAll"
    },
    // 关闭文件
    {
        "key": "ctrl+e q",
        "command": "workbench.action.closeActiveEditor"
    },
    // 关闭所有文件
    {
        "key": "ctrl+e a",
        "command": "workbench.action.closeAllEditors"
    },
    // -- 侧边栏命令
    // 切换侧边栏显示状态
    {
        "key": "ctrl+n n",
        "command": "workbench.action.toggleSidebarVisibility"
    },
    // 显示文件资源管理器
    {
        "key": "ctrl+n 1",
        "command": "workbench.files.action.focusFilesExplorer"
    },
    // 显示TODO Tree
    {
        "key": "ctrl+n 2",
        "command": "todo-tree-view.focus"
    },
    // 显示全局搜索
    {
        "key": "ctrl+n 3",
        "command": "workbench.action.replaceInFiles",
    },
    // 显示debug
    {
        "key": "ctrl+n 4",
        "command": "workbench.view.debug",
        "when": "viewContainer.workbench.view.debug.enabled"
    },
    // 显示版本控制
    {
        "key": "ctrl+n 5",
        "command": "workbench.view.scm",
        "when": "workbench.scm.active"
    },
    // 显示Docker
    {
        "key": "ctrl+n 6",
        "command": "workbench.view.extension.dockerView"
    },
    // 显示插件商店
    {
        "key": "ctrl+n 7",
        "command": "workbench.view.extensions",
        "when": "viewContainer.workbench.view.extensions.enabled"
    },
    // --- 面板命令
    // 切换面板显示状态
    {
        "key": "ctrl+p [",
        "command": "workbench.action.togglePanel"
    },
    // 显示问题
    {
        "key": "ctrl+p 1",
        "command": "workbench.panel.markers.view.focus"
    },
    // 显示输出
    {
        "key": "ctrl+p 2",
        "command": "workbench.action.output.toggleOutput",
        "when": "workbench.panel.output.active"
    },
    // 显示终端
    {
        "key": "ctrl+p 3",
        "command": "workbench.action.terminal.toggleTerminal",
        "when": "terminal.active"
    },
    // 显示调试控制台
    {
        "key": "ctrl+p 4",
        "command": "workbench.debug.action.toggleRepl",
        "when": "workbench.panel.repl.view.active"
    },
    // --- 编辑区命令
    // 关闭当前选项卡或分屏
    {
        "key": "ctrl+q",
        "command": "workbench.action.closeActiveEditor"
    },
    // 拆分一个上下分屏
    {
        "key": "ctrl+w s",
        "command": "workbench.action.splitEditorDown"
    },
    // 拆分一个左右分屏
    {
        "key": "ctrl+w v",
        "command": "workbench.action.splitEditor"
    },
    // 将光标向上动1屏
    {
        "key": "ctrl+w k",
        "command": "workbench.action.focusAboveGroup"
    },
    // 将光标向下动1屏
    {
        "key": "ctrl+w j",
        "command": "workbench.action.focusBelowGroup"
    },
    // 将光标向左移动1屏
    {
        "key": "ctrl+w h",
        "command": "workbench.action.focusLeftGroup"
    },
    // 将光标向右移动1屏
    {
        "key": "ctrl+w l",
        "command": "workbench.action.focusRightGroup"
    },
    
    // --- 代码编辑命令
    /**
    // 触发帮助提示
    {
        "key": "ctrl+h",
        "command": "editor.action.showHover",
        "when": "editorTextFocus"
    },
    // 触发参数提示
    {
        "key": "ctrl+shift+p",
        "command": "editor.action.triggerParameterHints",
        "when": "editorHasSignatureHelpProvider && editorTextFocus"
    },
    {
        "key": "ctrl+shift+p",
        "command": "closeParameterHints",
        "when": "editorFocus && parameterHintsVisible"
    },
    // 触发建议提示
    {
        "key": "ctrl+k",
        "command": "editor.action.triggerSuggest",
        "when": "editorHasCompletionItemProvider && textInputFocus && !editorReadonly"
    },
    {
        "key": "ctrl+k",
        "command": "hideSuggestWidget",
        "when": "suggestWidgetVisible && textInputFocus"
    },
    // 移动到下一个建议
    {
        "key": "ctrl+n",
        "command": "selectNextSuggestion",
        "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
    },
    // 移动到上一个建议
    {
        "key": "ctrl+p",
        "command": "selectPrevSuggestion",
        "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
    },
    // 格式化代码
    {
        "key": "ctrl+shift+i",
        "command": "editor.action.formatDocument",
        "when": "editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly && !inCompositeEditor"
    },
    */
    // 放大字体
    {
        "key": "ctrl+=",
        "command": "editor.action.fontZoomIn"
    },
    // 缩小字体
    {
        "key": "ctrl+-",
        "command": "editor.action.fontZoomOut"
    },
    // --- 资源管理器中对文件或目录的操作
    // 新建文件
    {
        "key": "i",
        "command": "explorer.newFile",
        "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus "
    },
    // 新建目录
    {
        "key": "o",
        "command": "explorer.newFolder",
        "when": " explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus "
    },
    // 刷新资源管理器
    {
        "key": "r",
        "command": "workbench.files.action.refreshFilesExplorer",
        "when": " explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus "
    },
    // 重命名文件或目录
    {
        "key": "a",
        "command": "renameFile",
        "when": " explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus "
    },
    // 删除文件或目录
    {
        "key": "d",
        "command": "deleteFile",
        "when": " explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus "
    },
    // 剪切文件或目录
    {
        "key": "x",
        "command": "filesExplorer.cut",
        "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
    },
    // 复制文件或目录
    {
        "key": "y",
        "command": "filesExplorer.copy",
        "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !inputFocus"
    },
    // 粘贴文件或目录
    {
        "key": "p",
        "command": "filesExplorer.paste",
        "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceReadonly && !inputFocus"
    },
    // 禅模式
    {
        "key": "ctrl+alt+z",
        "command": "workbench.action.toggleZenMode"
    }
]

Lucking