預設鍵盤快捷鍵參考
VS Code 提供了一套預設的鍵盤快捷鍵。本文列出了 VS Code 中常用的預設鍵盤快捷鍵。
要獲取完整的鍵盤快捷鍵列表,請在 VS Code 中使用以下任一選項:
- 在命令面板中,選擇“首選項: 開啟預設鍵盤快捷鍵(JSON)”。
- 開啟“鍵盤快捷鍵”編輯器,然後選擇“更多操作” (...) 選單中的“顯示系統鍵繫結”。
注意
以下按鍵假定使用標準的美國鍵盤佈局。有關使用不同鍵盤佈局的資訊,請參閱此處。
基本編輯
| 命令 | 鍵 | 命令 ID |
|---|---|---|
| 剪下行(空選區) | ⌘X (Windows, Linux Ctrl+X) | editor.action.clipboardCutAction |
| 複製行(空選區) | ⌘C (Windows, Linux Ctrl+C) | editor.action.clipboardCopyAction |
| 貼上 | ⌘V (Windows, Linux Ctrl+V) | editor.action.clipboardPasteAction |
| 刪除行 | ⇧⌘K (Windows, Linux Ctrl+Shift+K) | editor.action.deleteLines |
| 在下方插入行 | ⌘Enter (Windows, Linux Ctrl+Enter) | editor.action.insertLineAfter |
| 在上方插入行 | ⇧⌘Enter (Windows, Linux Ctrl+Shift+Enter) | editor.action.insertLineBefore |
| 向下移動行 | ⌥↓ (Windows, Linux Alt+Down) | editor.action.moveLinesDownAction |
| 向上移動行 | ⌥↑ (Windows, Linux Alt+Up) | editor.action.moveLinesUpAction |
| 向下複製行 | ⇧⌥↓ (Windows Shift+Alt+Down, Linux Ctrl+Shift+Alt+Down) | editor.action.copyLinesDownAction |
| 向上複製行 | ⇧⌥↑ (Windows Shift+Alt+Up, Linux Ctrl+Shift+Alt+Up) | editor.action.copyLinesUpAction |
| 撤銷 | ⌘Z (Windows, Linux Ctrl+Z) | undo |
| 重做 | ⇧⌘Z (Windows, Linux Ctrl+Y) | redo |
| 將選區新增到下一個查詢匹配項 | ⌘D (Windows, Linux Ctrl+D) | editor.action.addSelectionToNextFindMatch |
| 將最後一個選區移至下一個查詢匹配項 | ⌘K ⌘D (Windows, Linux Ctrl+K Ctrl+D) | editor.action.moveSelectionToNextFindMatch |
| 撤銷上一個游標操作 | ⌘U (Windows, Linux Ctrl+U) | cursorUndo |
| 在每行選區的末尾插入游標 | ⇧⌥I (Windows, Linux Shift+Alt+I) | editor.action.insertCursorAtEndOfEachLineSelected |
| 選擇當前選區的所有匹配項 | ⇧⌘L (Windows, Linux Ctrl+Shift+L) | editor.action.selectHighlights |
| 選擇當前單詞的所有匹配項 | ⌘F2 (Windows, Linux Ctrl+F2) | editor.action.changeAll |
| 選擇當前行 | ⌘L (Windows, Linux Ctrl+L) | expandLineSelection |
| 在下方插入游標 | ⌥⌘↓ (Windows Ctrl+Alt+Down, Linux Shift+Alt+Down) | editor.action.insertCursorBelow |
| 在上方插入游標 | ⌥⌘↑ (Windows Ctrl+Alt+Up, Linux Shift+Alt+Up) | editor.action.insertCursorAbove |
| 跳轉到匹配的括號 | ⇧⌘\ (Windows, Linux Ctrl+Shift+\) | editor.action.jumpToBracket |
| 縮排行 | ⌘] (Windows, Linux Ctrl+]) | editor.action.indentLines |
| 取消縮排行 | ⌘[ (Windows, Linux Ctrl+[) | editor.action.outdentLines |
| 轉到行開頭 | Home | cursorHome |
| 轉到行末尾 | End | cursorEnd |
| 轉到檔案末尾 | ⌘↓ (Windows, Linux Ctrl+End) | cursorBottom |
| 轉到檔案開頭 | ⌘↑ (Windows, Linux Ctrl+Home) | cursorTop |
| 向下滾動行 | ⌃PageDown (Windows, Linux Ctrl+Down) | scrollLineDown |
| 向上滾動行 | ⌃PageUp (Windows, Linux Ctrl+Up) | scrollLineUp |
| 向下滾動頁面 | ⌘PageDown (Windows, Linux Alt+PageDown) | scrollPageDown |
| 向上滾動頁面 | ⌘PageUp (Windows, Linux Alt+PageUp) | scrollPageUp |
| 摺疊(收起)區域 | ⌥⌘[ (Windows, Linux Ctrl+Shift+[) | editor.fold |
| 展開(展開)區域 | ⌥⌘] (Windows, Linux Ctrl+Shift+]) | editor.unfold |
| 切換摺疊區域 | ⌘K ⌘L (Windows, Linux Ctrl+K Ctrl+L) | editor.toggleFold |
| 摺疊(收起)所有子區域 | ⌘K ⌘[ (Windows, Linux Ctrl+K Ctrl+[) | editor.foldRecursively |
| 展開(展開)所有子區域 | ⌘K ⌘] (Windows, Linux Ctrl+K Ctrl+]) | editor.unfoldRecursively |
| 摺疊(收起)所有區域 | ⌘K ⌘0 (Windows, Linux Ctrl+K Ctrl+0) | editor.foldAll |
| 展開(展開)所有區域 | ⌘K ⌘J (Windows, Linux Ctrl+K Ctrl+J) | editor.unfoldAll |
| 新增行註釋 | ⌘K ⌘C (Windows, Linux Ctrl+K Ctrl+C) | editor.action.addCommentLine |
| 移除行註釋 | ⌘K ⌘U (Windows, Linux Ctrl+K Ctrl+U) | editor.action.removeCommentLine |
| 切換行註釋 | ⌘/ (Windows, Linux Ctrl+/) | editor.action.commentLine |
| 切換塊註釋 | ⇧⌥A (Windows Shift+Alt+A, Linux Ctrl+Shift+A) | editor.action.blockComment |
| 查詢 | ⌘F (Windows, Linux Ctrl+F) | actions.find |
| 替換 | ⌥⌘F (Windows, Linux Ctrl+H) | editor.action.startFindReplaceAction |
| 查詢下一個 | Enter | editor.action.nextMatchFindAction |
| 查詢上一個 | ⇧Enter (Windows, Linux Shift+Enter) | editor.action.previousMatchFindAction |
| 選擇查詢匹配項的所有例項 | ⌥Enter (Windows, Linux Alt+Enter) | editor.action.selectAllMatches |
| 切換查詢區分大小寫 | ⌥⌘C (Windows, Linux Alt+C) | toggleFindCaseSensitive |
| 切換查詢正則表示式 | ⌥⌘R (Windows, Linux Alt+R) | toggleFindRegex |
| 切換查詢全字匹配 | ⌥⌘W (Windows, Linux Alt+W) | toggleFindWholeWord |
| 切換使用 Tab 鍵設定焦點 | ⌃⇧M (Windows, Linux Ctrl+M) | editor.action.toggleTabFocusMode |
| 切換換行 | ⌥Z (Windows, Linux Alt+Z) | editor.action.toggleWordWrap |
富語言編輯
| 命令 | 鍵 | 命令 ID |
|---|---|---|
| 觸發建議 | ⌃Space (Windows, Linux Ctrl+Space) | editor.action.triggerSuggest |
| 觸發引數提示 | ⇧⌘Space (Windows, Linux Ctrl+Shift+Space) | editor.action.triggerParameterHints |
| 格式化文件 | ⇧⌥F (Windows Shift+Alt+F, Linux Ctrl+Shift+I) | editor.action.formatDocument |
| 格式化選區 | ⌘K ⌘F (Windows, Linux Ctrl+K Ctrl+F) | editor.action.formatSelection |
| 轉到定義 | F12 | editor.action.revealDefinition |
| 顯示懸停 | ⌘K ⌘I (Windows, Linux Ctrl+K Ctrl+I) | editor.action.showHover |
| 速覽定義 | ⌥F12 (Windows Alt+F12, Linux Ctrl+Shift+F10) | editor.action.peekDefinition |
| 在側邊開啟定義 | ⌘K F12 (Windows, Linux Ctrl+K F12) | editor.action.revealDefinitionAside |
| 快速修復 | ⌘. (Windows, Linux Ctrl+.) | editor.action.quickFix |
| 轉到引用 | ⇧F12 (Windows, Linux Shift+F12) | editor.action.goToReferences |
| 重新命名符號 | F2 | editor.action.rename |
| 替換為下一個值 | ⇧⌘. (Windows, Linux Ctrl+Shift+.) | editor.action.inPlaceReplace.down |
| 替換為上一個值 | ⇧⌘, (Windows, Linux Ctrl+Shift+,) | editor.action.inPlaceReplace.up |
| 展開 AST 選擇 | ⌃⇧⌘→ (Windows, Linux Shift+Alt+Right) | editor.action.smartSelect.expand |
| 收縮 AST 選擇 | ⌃⇧⌘← (Windows, Linux Shift+Alt+Left) | editor.action.smartSelect.shrink |
| 修剪尾隨空格 | ⌘K ⌘X (Windows, Linux Ctrl+K Ctrl+X) | editor.action.trimTrailingWhitespace |
| 更改語言模式 | ⌘K M (Windows, Linux Ctrl+K M) | workbench.action.editor.changeLanguageMode |
導航
| 命令 | 鍵 | 命令 ID |
|---|---|---|
| 顯示所有符號 | ⌘T (Windows, Linux Ctrl+T) | workbench.action.showAllSymbols |
| 轉到行... | ⌃G (Windows, Linux Ctrl+G) | workbench.action.gotoLine |
| 轉到檔案...,快速開啟 | ⌘P (Windows, Linux Ctrl+P) | workbench.action.quickOpen |
| 轉到符號... | ⇧⌘O (Windows, Linux Ctrl+Shift+O) | workbench.action.gotoSymbol |
| 顯示問題 | ⇧⌘M (Windows, Linux Ctrl+Shift+M) | workbench.actions.view.problems |
| 轉到下一個錯誤或警告 | F8 | editor.action.marker.nextInFiles |
| 轉到上一個錯誤或警告 | ⇧F8 (Windows, Linux Shift+F8) | editor.action.marker.prevInFiles |
| 顯示所有命令 | ⇧⌘P (Windows, Linux Ctrl+Shift+P) 或 F1 | workbench.action.showCommands |
| 導航編輯器組歷史記錄 | ⌃Tab (Windows, Linux Ctrl+Tab) | workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup |
| 後退 | ⌃- (Windows Alt+Left, Linux Ctrl+Alt+-) | workbench.action.navigateBack |
| 在快速輸入中後退 | ⌃- (Windows Alt+Left, Linux Ctrl+Alt+-) | workbench.action.quickInputBack |
| 前進 | ⌃⇧- (Windows Alt+Right, Linux Ctrl+Shift+-) | workbench.action.navigateForward |
| 聚焦麵包屑 | ⇧⌘; (Windows, Linux Ctrl+Shift+;) | breadcrumbs.focus |
| 聚焦並選擇麵包屑 | ⇧⌘. (Windows, Linux Ctrl+Shift+.) | breadcrumbs.focusAndSelect |
編輯器/視窗管理
| 命令 | 鍵 | 命令 ID |
|---|---|---|
| 新視窗 | ⇧⌘N (Windows, Linux Ctrl+Shift+N) | workbench.action.newWindow |
| 關閉視窗 | ⌘W (Windows, Linux Alt+F4) | workbench.action.closeWindow |
| 關閉編輯器 | ⌘W (Windows Ctrl+F4, Linux Ctrl+W) | workbench.action.closeActiveEditor |
| 關閉資料夾 | ⌘K F (Windows, Linux Ctrl+K F) | workbench.action.closeFolder |
| 拆分編輯器 | ⌘\ (Windows, Linux Ctrl+\) | workbench.action.splitEditor |
| 聚焦第一個編輯器組 | ⌘1 (Windows, Linux Ctrl+1) | workbench.action.focusFirstEditorGroup |
| 聚焦第二個編輯器組 | ⌘2 (Windows, Linux Ctrl+2) | workbench.action.focusSecondEditorGroup |
| 聚焦第三個編輯器組 | ⌘3 (Windows, Linux Ctrl+3) | workbench.action.focusThirdEditorGroup |
| 聚焦左側編輯器組 | ⌘K ⌘← (Windows, Linux Ctrl+K Ctrl+Left) | workbench.action.focusLeftGroup |
| 聚焦右側編輯器組 | ⌘K ⌘→ (Windows, Linux Ctrl+K Ctrl+Right) | workbench.action.focusRightGroup |
| 將編輯器向左移動 | ⌘K ⇧⌘← (Windows, Linux Ctrl+Shift+PageUp) | workbench.action.moveEditorLeftInGroup |
| 將編輯器向右移動 | ⌘K ⇧⌘→ (Windows, Linux Ctrl+Shift+PageDown) | workbench.action.moveEditorRightInGroup |
| 將活動編輯器組向左移動 | ⌘K ← (Windows, Linux Ctrl+K Left) | workbench.action.moveActiveEditorGroupLeft |
| 將活動編輯器組向右移動 | ⌘K → (Windows, Linux Ctrl+K Right) | workbench.action.moveActiveEditorGroupRight |
| 將編輯器移至下一個組 | ⌃⌘→ (Windows, Linux Ctrl+Alt+Right) | workbench.action.moveEditorToNextGroup |
| 將編輯器移至上一個組 | ⌃⌘← (Windows, Linux Ctrl+Alt+Left) | workbench.action.moveEditorToPreviousGroup |
檔案管理
| 命令 | 鍵 | 命令 ID |
|---|---|---|
| 新建檔案 | ⌘N (Windows, Linux Ctrl+N) | workbench.action.files.newUntitledFile |
| 開啟檔案... | ⌘O (Windows, Linux Ctrl+O) | workbench.action.files.openFile |
| 儲存 | ⌘S (Windows, Linux Ctrl+S) | workbench.action.files.save |
| 全部儲存 | ⌥⌘S (Windows Ctrl+K S, Linux ) | saveAll |
| 另存為... | ⇧⌘S (Windows, Linux Ctrl+Shift+S) | workbench.action.files.saveAs |
| 關閉 | ⌘W (Windows Ctrl+F4, Linux Ctrl+W) | workbench.action.closeActiveEditor |
| 關閉組 | ⌘K W (Windows, Linux Ctrl+K W) | workbench.action.closeEditorsInGroup |
| 關閉所有 | ⌘K ⌘W (Windows, Linux Ctrl+K Ctrl+W) | workbench.action.closeAllEditors |
| 重新開啟已關閉的編輯器 | ⇧⌘T (Windows, Linux Ctrl+Shift+T) | workbench.action.reopenClosedEditor |
| 保持開啟 | ⌘K Enter (Windows, Linux Ctrl+K Enter) | workbench.action.keepEditor |
| 複製活動檔案的路徑 | ⌘K P (Windows, Linux Ctrl+K P) | workbench.action.files.copyPathOfActiveFile |
| 在 Windows 中顯示活動檔案 | ⌘K R (Windows, Linux Ctrl+K R) | workbench.action.files.revealActiveFileInWindows |
顯示
| 命令 | 鍵 | 命令 ID |
|---|---|---|
| 切換全屏 | ⌃⌘F (Windows, Linux F11) | workbench.action.toggleFullScreen |
| 切換專注模式 | ⌘K Z (Windows, Linux Ctrl+K Z) | workbench.action.toggleZenMode |
| 退出專注模式 | Escape Escape | workbench.action.exitZenMode |
| 放大 | ⌘= (Windows, Linux Ctrl+=) | workbench.action.zoomIn |
| 縮小 | ⌘- (Windows, Linux Ctrl+-) | workbench.action.zoomOut |
| 重置縮放 | ⌘Numpad0 (Windows, Linux Ctrl+Numpad0) | workbench.action.zoomReset |
| 切換側邊欄可見性 | ⌘B (Windows, Linux Ctrl+B) | workbench.action.toggleSidebarVisibility |
| 顯示資源管理器/切換焦點 | ⇧⌘E (Windows, Linux Ctrl+Shift+E) | workbench.view.explorer |
| 顯示搜尋 | ⇧⌘F (Windows, Linux Ctrl+Shift+F) | workbench.view.search |
| 顯示原始碼管理 | ⌃⇧G (Windows, Linux Ctrl+Shift+G) | workbench.view.scm |
| 顯示執行 | ⇧⌘D (Windows, Linux Ctrl+Shift+D) | workbench.view.debug |
| 顯示擴充套件 | ⇧⌘X (Windows, Linux Ctrl+Shift+X) | workbench.view.extensions |
| 顯示輸出 | ⇧⌘U (Windows Ctrl+Shift+U, Linux Ctrl+K Ctrl+H) | workbench.action.output.toggleOutput |
| 快速開啟檢視 | ⌃Q (Windows Ctrl+Q, Linux ) | workbench.action.quickOpenView |
| 開啟新的命令提示符 | ⇧⌘C (Windows, Linux Ctrl+Shift+C) | workbench.action.terminal.openNativeConsole |
| 切換 Markdown 預覽 | ⇧⌘V (Windows, Linux Ctrl+Shift+V) | markdown.showPreview |
| 在側邊開啟預覽 | ⌘K V (Windows, Linux Ctrl+K V) | markdown.showPreviewToSide |
| 切換整合終端 | ⌃` (Windows, Linux Ctrl+`) | workbench.action.terminal.toggleTerminal |
搜尋
| 命令 | 鍵 | 命令 ID |
|---|---|---|
| 顯示搜尋 | ⇧⌘F (Windows, Linux Ctrl+Shift+F) | workbench.view.search |
| 在檔案中替換 | ⇧⌘H (Windows, Linux Ctrl+Shift+H) | workbench.action.replaceInFiles |
| 切換區分大小寫 | ⌥⌘C (Windows, Linux Alt+C) | toggleSearchCaseSensitive |
| 切換全字匹配 | ⌥⌘W (Windows, Linux Alt+W) | toggleSearchWholeWord |
| 切換使用正則表示式 | ⌥⌘R (Windows, Linux Alt+R) | toggleSearchRegex |
| 切換搜尋詳細資訊 | ⇧⌘J (Windows, Linux Ctrl+Shift+J) | workbench.action.search.toggleQueryDetails |
| 聚焦下一個搜尋結果 | F4 | search.action.focusNextSearchResult |
| 聚焦上一個搜尋結果 | ⇧F4 (Windows, Linux Shift+F4) | search.action.focusPreviousSearchResult |
| 顯示下一個搜尋詞 | ↓ (Windows, Linux Down) | history.showNext |
| 顯示上一個搜尋詞 | ↑ (Windows, Linux Up) | history.showPrevious |
搜尋編輯器
| 命令 | 鍵 | 命令 ID |
|---|---|---|
| 在編輯器中開啟結果 | ⌘Enter (Windows, Linux Alt+Enter) | search.action.openInEditor |
| 聚焦搜尋編輯器輸入 | Escape | search.action.focusQueryEditorWidget |
| 再次搜尋 | ⇧⌘R (Windows, Linux Ctrl+Shift+R) | rerunSearchEditorSearch |
| 刪除檔案結果 | ⇧⌘Backspace (Windows, Linux Ctrl+Shift+Backspace) | search.searchEditor.action.deleteFileResults |
首選項
| 命令 | 鍵 | 命令 ID |
|---|---|---|
| 開啟設定 | ⌘, (Windows, Linux Ctrl+,) | workbench.action.openSettings |
| 開啟鍵盤快捷鍵 | ⌘K ⌘S (Windows, Linux Ctrl+K Ctrl+S) | workbench.action.openGlobalKeybindings |
| 選擇顏色主題 | ⌘K ⌘T (Windows, Linux Ctrl+K Ctrl+T) | workbench.action.selectTheme |
聊天
| 命令 | 鍵 | 命令 ID |
|---|---|---|
| 開啟聊天檢視 | ⌃⌘I(Windows、Linux Ctrl+Alt+I) | workbench.action.chat.open |
| 以代理模式開啟聊天 | ⇧⌘I (Windows Ctrl+Shift+I, Linux Ctrl+Shift+Alt+I) | workbench.action.chat.openagent |
| 開啟內聯編輯器聊天 | ⌘I(Windows、Linux Ctrl+I) | inlineChat.start |
| 開啟終端內聯聊天 | ⌘I(Windows、Linux Ctrl+I) | workbench.action.terminal.chat.start |
| 開啟快速聊天 | ⇧⌥⌘L(Windows、Linux Ctrl+Shift+Alt+L) | workbench.action.quickchat.toggle |
| 開啟代理選擇器 | ⌘. (Windows, Linux Ctrl+.) | workbench.action.chat.openModePicker |
| 開啟語言模型選擇器 | ⌥⌘. (Windows, Linux Ctrl+Alt+.) | workbench.action.chat.openModelPicker |
| 新聊天會話 | ⌘N (Windows, Linux Ctrl+N) | workbench.action.chat.newChat |
| 接受內聯建議 | Tab | editor.action.inlineSuggest.commit |
除錯
| 命令 | 鍵 | 命令 ID |
|---|---|---|
| 切換斷點 | F9 | editor.debug.action.toggleBreakpoint |
| 開始 | F5 | workbench.action.debug.start |
| 繼續 | F5 | workbench.action.debug.continue |
| 開始(不除錯) | ⌃F5 (Windows, Linux Ctrl+F5) | workbench.action.debug.run |
| 暫停 | F6 | workbench.action.debug.pause |
| 單步進入 | F11 | workbench.action.debug.stepInto |
任務
| 命令 | 鍵 | 命令 ID |
|---|---|---|
| 執行構建任務 | ⇧⌘B (Windows, Linux Ctrl+Shift+B) | workbench.action.tasks.build |