參加你附近的 ,瞭解 VS Code 中的 AI 輔助開發。

VS Code 中的 GitHub Copilot 設定參考

本文列出了 Visual Studio Code 中 GitHub Copilot 的配置設定。有關在 VS Code 中使用設定的常規資訊,請參閱使用者和工作區設定

團隊正在持續改進 VS Code 中的 Copilot 並新增新功能。一些功能仍處於實驗階段。歡迎試用並在我們的 issues中分享您的反饋。獲取更多關於VS Code 中功能生命週期的資訊。

提示

如果你還沒有 Copilot 訂閱,可以透過註冊 Copilot 免費計劃 免費使用 Copilot,並獲得每月限量的補全和聊天互動次數。

常規設定

設定與描述 預設值
chat.commandCenter.enabled
控制是否在 VS Code 標題欄中顯示聊天選單。
true
workbench.settings.showAISearchToggle
在設定編輯器中啟用 AI 搜尋設定。
true
workbench.commandPalette.experimental.askChatLocation (實驗性功能)
控制命令面板應在何處提出聊天問題。
"chatView"
search.searchView.semanticSearchBehavior (預覽功能)
配置何時在搜尋檢視中執行語義搜尋:手動(預設)、未找到文字搜尋結果時,或始終執行。
"manual"
search.searchView.keywordSuggestions (預覽功能)
控制是否在搜尋檢視中顯示關鍵字建議。
false

程式碼編輯設定

設定與描述 預設值
github.copilot.editor.enableCodeActions
控制當 Copilot 命令可用時,是否將其顯示為程式碼操作。
true
github.copilot.renameSuggestions.triggerAutomatically
生成符號重新命名建議。
true
github.copilot.enable
為指定的語言啟用或停用程式碼補全。
{ "*": true, "plaintext": false, "markdown": false, "scminput": false }
github.copilot.nextEditSuggestions.enabled
啟用後續編輯建議 (NES)。
true
editor.inlineSuggest.edits.allowCodeShifting
配置 NES 是否能夠移動您的程式碼以顯示建議。
"always"
editor.inlineSuggest.edits.renderSideBySide
配置 NES 是否可以在可能的情況下並排顯示較大的建議,或者 Copilot NES 是否應始終在相關程式碼下方顯示較大的建議。
"auto"
github.copilot.nextEditSuggestions.fixes
基於診斷資訊(波浪線)啟用後續編輯建議。例如,缺少匯入。
true
editor.inlineSuggest.minShowDelay
顯示內聯建議前等待的時間(毫秒)。
0

聊天設定

設定與描述 預設值
github.copilot.chat.localeOverride
為聊天響應指定區域設定,例如 enfr
"auto"
github.copilot.chat.useProjectTemplates
在使用 /new 時,使用相關的 GitHub 專案作為啟動專案。
true
github.copilot.chat.scopeSelection
當您使用 /explain 且活動編輯器中沒有選區時,是否提示指定符號範圍。
false
github.copilot.chat.terminalChatLocation
控制來自終端的聊天查詢應在何處開啟。
"chatView"
chat.detectParticipant.enabled
在聊天檢視中啟用聊天參與者檢測。
true
chat.checkpoints.enabled
在聊天中啟用或停用檢查點
true
chat.checkpoints.showFileChanges
在每次聊天請求結束時顯示檔案更改的摘要。
false
chat.editRequests
啟用或停用編輯先前的聊天請求
"inline"
chat.editor.fontFamily
聊天程式碼塊中的字體系列。
"default"
chat.editor.fontSize
聊天程式碼塊中的字型大小(畫素)。
14
chat.editor.fontWeight
聊天程式碼塊中的字型粗細。
"default"
chat.editor.lineHeight
聊天程式碼塊中的行高(畫素)。
0
chat.editor.wordWrap
切換聊天程式碼塊中的換行。
"off"
chat.editing.confirmEditRequestRemoval
在撤銷編輯前請求確認。
true
chat.editing.confirmEditRequestRetry
在重做上次編輯前請求確認。
true
chat.editing.autoAcceptDelay
配置一個延遲時間,在此之後建議的編輯將自動被接受,使用零來停用自動接受。
0
chat.fontFamily
聊天中 Markdown 內容的字體系列。
"default"
chat.fontSize
聊天中 Markdown 內容的字型大小(畫素)。
13
chat.notifyWindowOnConfirmation
啟用或停用在需要使用者輸入時顯示作業系統通知視窗。
true
chat.math.enabled (預覽功能)
在聊天中啟用或停用使用KaTeX進行數學公式渲染。
false
github.copilot.chat.codesearch.enabled (預覽功能)
在提示中使用 #codebase 時,Copilot 會自動發現需要編輯的相關檔案。
false
github.copilot.chat.edits.suggestRelatedFilesFromGitHistory (實驗性功能)
在聊天上下文中從 git 歷史記錄中建議相關檔案。
true
chat.sendElementsToChat.enabled (實驗性功能)
啟用將簡單瀏覽器中的元素作為上下文傳送到聊天檢視。
true
chat.useAgentsMdFile (實驗性功能)
啟用或停用使用工作區根目錄下的 AGENTS.md 檔案作為聊天請求的上下文。
true

代理模式設定

設定與描述 預設值
chat.agent.enabled
啟用或停用代理模式(需要 VS Code 1.99 或更高版本)。
true
chat.agent.maxRequests
Copilot 在代理模式下可以發出的最大請求數。
25
github.copilot.chat.agent.autoFix
自動診斷並修復生成的程式碼更改中的問題。
true
github.copilot.chat.agent.runTasks
使用代理模式時執行工作區任務。
true
chat.mcp.access
管理可以在 VS Code 中使用的模型上下文協議(MCP)伺服器。
true
chat.mcp.discovery.enabled
配置從其他應用程式自動發現 MCP 伺服器配置。
false
chat.tools.terminal.autoApprove
控制哪些終端命令在代理模式下自動批准。命令可以設定為 true(自動批准)或 false(需要批准)。可以透過將模式包裝在 / 字元中來使用正則表示式。
{ "rm": false, "rmdir": false, "del": false, "kill": false, "curl": false, "wget": false, "eval": false, "chmod": false, "chown": false, "/^Remove-Item\\b/i": false }
chat.tools.global.autoApprove
自動批准所有工具 - 此設定會停用關鍵的安全保護措施
false
chat.mcp.autoStart (實驗性功能)
檢測到 MCP 配置更改時自動啟動 MCP 伺服器。
never
chat.todoListTool.enabled (實驗性功能)
在聊天中啟用待辦事項列表工具。
false
github.copilot.chat.newWorkspaceCreation.enabled (實驗性功能)
啟用代理模式工具,以便在聊天中搭建新工作區。
true
github.copilot.chat.agent.thinkingTool (實驗性功能)
在代理模式下啟用思考工具。
false
github.copilot.chat.virtualTools.threshold (實驗性功能)
工具數量的閾值,超過此閾值應使用虛擬工具。虛擬工具將相似的工具集組合在一起,並使模型能夠按需啟用它們。這使您能夠突破聊天請求中 128 個工具的限制。
128

內聯聊天設定

設定與描述 預設值
inlineChat.finishOnType
當在已更改區域之外部索引鍵入時,結束編輯器內聯聊天會話。
false
inlineChat.holdToSpeech
按住編輯器內聯聊天鍵盤快捷鍵(⌘I (Windows、Linux 為 Ctrl+I))可自動啟用語音識別。
true
editor.inlineSuggest.syntaxHighlightingEnabled
為程式碼補全顯示語法高亮。
true
inlineChat.lineEmptyHint (實驗性功能)
在空行上顯示編輯器內聯聊天的提示。
false
inlineChat.lineNaturalLanguageHint (實驗性功能)
當一行主要由單片語成時,立即觸發編輯器內聯聊天。
true
github.copilot.chat.editor.temporalContext.enabled (實驗性功能)
將最近檢視和編輯過的檔案包含在編輯器內聯聊天的上下文中。
false

程式碼審查設定

設定與描述 預設值
github.copilot.chat.reviewSelection.enabled (預覽功能)
為編輯器文字選區啟用 AI 程式碼審查。
true
github.copilot.chat.reviewSelection.instructions (預覽功能)
新增到請求中的自定義指令,用於透過 AI 審查當前編輯器選區。
[]

自定義指令設定

設定與描述 預設值
github.copilot.chat.codeGeneration.useInstructionFiles
自動將 .github/copilot-instructions.md 中的自定義指令新增到聊天請求中。
true
chat.instructionsFilesLocations (實驗性功能)
搜尋自定義指令檔案的位置。相對路徑從工作區的根資料夾解析。支援檔案路徑的 glob 模式。
{ ".github/instructions": true }
github.copilot.chat.commitMessageGeneration.instructions (實驗性功能)
使用 AI 生成提交訊息的自定義指令。
[]
github.copilot.chat.pullRequestDescriptionGeneration.instructions (實驗性功能)
使用 AI 生成拉取請求標題和描述的自定義指令。
[]

可重用提示檔案設定

設定與描述 預設值
chat.promptFiles (實驗性功能)
啟用或停用可重用提示檔案。
true
chat.promptFilesLocations (實驗性功能)
搜尋提示檔案的位置。相對路徑從工作區的根資料夾解析。支援檔案路徑的 glob 模式。
{ ".github/prompts": true }

聊天模式設定

設定與描述 預設值
chat.modeFilesLocations (實驗性功能)
搜尋聊天模式檔案的位置。相對路徑從工作區的根資料夾解析。支援檔案路徑的 glob 模式。
{ ".github/chatmodes": true }

除錯設定

設定與描述 預設值
github.copilot.chat.startDebugging.enabled (預覽功能)
在聊天檢視中啟用實驗性的 /startDebugging 意圖以生成除錯配置。
true
github.copilot.chat.copilotDebugCommand.enabled (預覽功能)
啟用 copilot-debug 終端命令。
true

測試設定

設定與描述 預設值
github.copilot.chat.generateTests.codeLens (實驗性功能)
為當前測試覆蓋率資訊未覆蓋的符號顯示生成測試程式碼鏡頭。
false
github.copilot.chat.setupTests.enabled (實驗性功能)
啟用實驗性的 /setupTests 意圖並在 /tests 生成中進行提示。
true

Notebook 設定

設定與描述 預設值
notebook.experimental.generate (實驗性功能)
啟用生成操作,以透過 notebook 內聯聊天建立程式碼單元格。
true
github.copilot.chat.edits.newNotebook.enabled (實驗性功能)
在編輯模式下啟用 notebook 工具以建立新的 notebook 檔案。
true
github.copilot.chat.notebook.followCellExecution.enabled (實驗性功能)
在編輯器中顯示當前正在執行的單元格。
false

輔助功能設定

設定與描述 預設值
inlineChat.accessibleDiffView
內聯聊天是否也為其更改渲染一個可訪問的差異檢視器。
"auto"
accessibility.signals.chatRequestSent
當發出聊天請求時播放一個訊號 - 聲音(音訊提示)和/或通告(警報)。
{ "sound": "auto", "announcement": "auto" }
accessibility.signals.chatResponseReceived
當收到響應時播放聲音/音訊提示。
{ "sound": "auto" }
accessibility.signals.chatEditModifiedFile
當檔案被聊天編輯修改時播放聲音/音訊提示。
{ "sound": "auto" }
accessibility.signals.chatUserActionRequired
當用戶需要在聊天中執行操作時播放聲音/音訊提示。
{ "sound": "auto", "announcement": "auto" }
accessibility.signals.lineHasInlineSuggestion
當游標位於有內聯建議的行上時播放聲音/音訊提示。
{ "sound": "auto" }
accessibility.signals.nextEditSuggestion
當有後續編輯建議可用時播放聲音/音訊提示。
{ "sound": "auto", "announcement": "auto" }
accessibility.verbosity.inlineChat
提供有關如何訪問內聯編輯器聊天輔助功能幫助選單的資訊,並在輸入框獲得焦點時透過提示進行提醒,描述如何使用該功能。
true
accessibility.verbosity.inlineCompletions
提供有關如何訪問內聯補全懸停提示和可訪問檢視的資訊。
true
accessibility.verbosity.panelChat
提供有關在聊天輸入框獲得焦點時如何訪問聊天幫助選單的資訊。
true
accessibility.voice.keywordActivation
控制是否識別關鍵字短語“Hey Code”以啟動語音聊天會話。
"off"
accessibility.voice.autoSynthesize
控制當使用語音作為輸入時,文字響應是否應自動大聲朗讀。
"off"
accessibility.voice.speechTimeout
在您停止說話後,語音識別保持活動狀態的持續時間(毫秒)。
1200