尝试以扩展 VS Code 中的代理模式!

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 标题栏中显示 Copilot 菜单。
true
workbench.commandPalette.experimental.askChatLocation (实验性)
控制命令面板应在何处提出聊天问题。
"chatView"
search.searchView.semanticSearchBehavior (预览)
配置何时在搜索视图中运行语义搜索:手动(默认)、未找到文本搜索结果时或始终。
"manual"
search.searchView.keywordSuggestions (预览)
控制是否在搜索视图中显示关键字建议。
false
workbench.settings.showAISearchToggle (实验性)
在设置编辑器中启用使用 AI 搜索设置。
true

代码编辑设置

设置和说明 默认值
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.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.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
github.copilot.chat.codesearch.enabled (预览)
在提示中使用 #codebase 时,Copilot 会自动发现要编辑的相关文件。
false
chat.editRequests (实验性)
启用或禁用编辑之前的聊天请求
"inline"
github.copilot.chat.edits.suggestRelatedFilesFromGitHistory (实验性)
在 Copilot 编辑中从 git 历史记录中建议相关文件。
true
chat.sendElementsToChat.enabled (实验性)
启用将来自简易浏览器(Simple Browser)的元素作为上下文发送到聊天视图。
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.enabled
在 VS Code 中启用模型上下文协议 (MCP) 支持。这允许在代理模式下从 MCP 服务器添加工具。
true
chat.tools.autoApprove (实验性)
自动批准所有工具。
false
github.copilot.chat.newWorkspaceCreation.enabled (实验性)
启用代理模式工具,以便在聊天中搭建新工作区。
true
github.copilot.chat.agent.thinkingTool (实验性)
在代理模式中启用思考工具。
false
github.copilot.chat.agent.terminal.allowList (实验性)
允许在代理模式下无需确认即可运行的终端命令列表。
{ "echo": true, "cd": true, "ls": true, "cat": true, "pwd": true, "Write-Host": true, "Set-Location": true, "Get-ChildItem": true, "Get-Content": true, "Get-Location": true }
github.copilot.chat.agent.terminal.denyList (实验性)
不允许在代理模式下无需确认即可运行的终端命令列表。
{ "rm": true, "rmdir": true, "del": true, "kill": true, "curl": true, "wget": true, "eval": true, "chmod": true, "chown": true, "Remove-Item": true }

内联聊天设置

设置和说明 默认值
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.experimental.generate (实验性)
启用 生成 操作,以通过笔记本内联聊天创建代码单元格。
true
github.copilot.chat.edits.newNotebook.enabled (实验性)
在编辑模式下启用笔记本工具,以创建新的笔记本文件。
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