开发常用快捷键

1 阅读2分钟
[
  // ========== 基础文件操作 ==========
  {
    "key": "ctrl+s",
    "command": "workbench.action.files.save",
    "when": "editorTextFocus"
  }, // 保存文件
  {
    "key": "ctrl+shift+s",
    "command": "workbench.action.files.saveAs"
  }, // 另存为
  {
    "key": "ctrl+w",
    "command": "workbench.action.closeActiveEditor",
    "when": "editorTextFocus"
  }, // 关闭当前标签页
  {
    "key": "ctrl+n",
    "command": "workbench.action.files.newUntitledFile"
  }, // 新建空白文件
  {
    "key": "ctrl+shift+n",
    "command": "workbench.action.newWindow"
  }, // 新建窗口
  // ========== 基础编辑剪切复制粘贴 ==========
  {
    "key": "ctrl+c",
    "command": "editor.action.clipboardCopyAction",
    "when": "editorTextFocus"
  }, // 复制
  {
    "key": "ctrl+x",
    "command": "editor.action.clipboardCutAction",
    "when": "editorTextFocus"
  }, // 剪切
  {
    "key": "ctrl+v",
    "command": "editor.action.clipboardPasteAction",
    "when": "editorTextFocus"
  }, // 粘贴
  {
    "key": "ctrl+z",
    "command": "undo",
    "when": "editorTextFocus"
  }, // 撤销
  {
    "key": "ctrl+y",
    "command": "redo",
    "when": "editorTextFocus"
  }, // 重做
  // ========== 整行快速操作(前端高频) ==========
  {
    "key": "shift+alt+down",
    "command": "editor.action.copyLinesDownAction",
    "when": "editorTextFocus"
  }, // 向下复制整行
  {
    "key": "shift+alt+up",
    "command": "editor.action.copyLinesUpAction",
    "when": "editorTextFocus"
  }, // 向上复制整行
  {
    "key": "alt+down",
    "command": "editor.action.moveLinesDownAction",
    "when": "editorTextFocus"
  }, // 下移整行
  {
    "key": "alt+up",
    "command": "editor.action.moveLinesUpAction",
    "when": "editorTextFocus"
  }, // 上移整行
  {
    "key": "ctrl+shift+k",
    "command": "editor.action.deleteLines",
    "when": "editorTextFocus"
  }, // 快速删除整行
  // ========== 批量选中修改 ==========
  {
    "key": "ctrl+a",
    "command": "editor.action.selectAll",
    "when": "editorTextFocus"
  }, // 全选
  {
    "key": "ctrl+d",
    "command": "editor.action.addSelectionToNextFindMatch",
    "when": "editorTextFocus"
  }, // 选中下一个相同内容
  {
    "key": "ctrl+shift+l",
    "command": "editor.action.selectHighlights",
    "when": "editorTextFocus"
  }, // 选中所有相同内容
  // ========== 代码注释(前端HTML/CSS/JS通用) ==========
  {
    "key": "ctrl+/",
    "command": "editor.action.commentLine",
    "when": "editorTextFocus"
  }, // 单行注释/取消注释
  {
    "key": "alt+shift+i",
    "command": "editor.action.insertSnippet",
    "args": {
      "snippet": "/**\n * $1\n */"
    },
    "when": "editorTextFocus"
  }, // JS快速生成文档注释
  {
    "key": "alt+shift+c",
    "command": "editor.action.insertSnippet",
    "args": {
      "snippet": "/* ========== $1 ========== */"
    },
    "when": "editorTextFocus"
  }, // CSS区域分割注释
  // ========== 代码格式化(必备) ==========
  {
    "key": "shift+alt+f",
    "command": "editor.action.formatDocument",
    "when": "editorTextFocus"
  }, // 全局格式化代码
  {
    "key": "ctrl+k",
    "command": "editor.action.formatSelection",
    "when": "editorTextFocus"
  }, // 选中区域格式化
  // ========== 查找替换 ==========
  {
    "key": "ctrl+f",
    "command": "actions.find",
    "when": "editorTextFocus"
  }, // 页面内查找
  {
    "key": "ctrl+h",
    "command": "actions.replace",
    "when": "editorTextFocus"
  }, // 页面内替换
  {
    "key": "ctrl+shift+f",
    "command": "search.action.openNewEditor"
  }, // 全局跨文件查找
  // ========== 视图与窗口 ==========
  {
    "key": "ctrl+b",
    "command": "workbench.action.toggleSidebarVisibility"
  }, // 显示/隐藏侧边栏
  {
    "key": "ctrl+`",
    "command": "workbench.action.terminal.toggleTerminal"
  }, // 调出/隐藏终端
  // ========== Trae AI 专属快捷键 ==========
  {
    "key": "ctrl+shift+i",
    "command": "trae.inlineChat.open",
    "when": "editorTextFocus"
  }, // 唤起行内AI助手
  // 导航历史后退/前进
  {
    "key": "alt+left",
    "command": "workbench.action.navigateBack"
  }, // 回退
  {
    "key": "alt+right",
    "command": "workbench.action.navigateForward"
  }, // 前进
  // ========== 光标跳转 ==========
  {
    "key": "ctrl+enter",
    "command": "editor.action.insertLineAfter",
    "when": "editorTextFocus"
  }, // 光标下方空一行
  {
    "key": "ctrl+shift+enter",
    "command": "editor.action.insertLineBefore",
    "when": "editorTextFocus"
  }, // 光标上方换行
  {
    "key": "ctrl+shift+alt+down",
    "command": "editor.action.insertCursorBelow",
    "when": "editorTextFocus"
  }, // 下方多光标
  {
    "key": "ctrl+shift+alt+up",
    "command": "editor.action.insertCursorAbove",
    "when": "editorTextFocus"
  }, // 上方多光标
  // ========== 前端【高级进阶快捷键】 ==========
  {
    "key": "ctrl+shift+m",
    "command": "workbench.action.showErrorsWarnings"
  }, // 快速查看代码报错
  {
    "key": "f2",
    "command": "editor.action.rename",
    "when": "editorTextFocus"
  }, // 全局重命名变量/方法
  {
    "key": "ctrl+shift+p",
    "command": "workbench.action.showCommands"
  }, // 打开所有命令面板
  {
    "key": "ctrl+p",
    "command": "workbench.action.quickOpen"
  }, // 快速搜索打开文件
  {
    "key": "ctrl+shift+o",
    "command": "workbench.action.gotoSymbol"
  }, // 快速跳转函数/方法
  {
    "key": "ctrl+g",
    "command": "workbench.action.gotoLine"
  }, // 跳转到指定行数
  {
    "key": "ctrl+shift+]",
    "command": "editor.fold",
    "when": "editorTextFocus"
  }, // 折叠代码块
  {
    "key": "ctrl+shift+[",
    "command": "editor.unfold",
    "when": "editorTextFocus"
  }, // 展开代码块
  {
    "key": "ctrl+tab",
    "command": "workbench.action.nextEditorInGroup"
  }, // 切换已打开标签页
  {
    "key": "ctrl+shift+tab",
    "command": "workbench.action.previousEditorInGroup"
  }, // 反向切换标签页
  {
    "key": "shift+f12",
    "command": "editor.action.showReferences",
    "when": "editorTextFocus"
  }, // 查看变量所有引用位置
  {
    "key": "f12",
    "command": "editor.action.gotoDeclaration",
    "when": "editorTextFocus"
  } // 跳转到方法定义源码
]