这是用户在 2025-2-8 11:31 为 https://code.visualstudio.com/docs/copilot/copilot-edits 保存的双语快照页面,由 沉浸式翻译 提供双语支持。了解如何保存?
Restriction  限制

🚀 Get in VS Code!
🚀 在 VS 代码中免费获取 GitHub Copilot!

Copilot Edits  副驾驶编辑

Use Copilot Edits to start an AI-powered code editing session and iterate quickly on code changes across multiple files by using natural language. Copilot Edits applies the edits directly in the editor, where you can review them in-place, with the full context of the surrounding code.
使用 Copilot Edits 启动人工智能驱动的代码编辑会话,使用自然语言快速迭代多个文件中的代码更改。Copilot Edits 可直接在编辑器中应用编辑,你可以在编辑器中就地审查,并查看周围代码的完整上下文。

Copilot Edits can function in two modes:
Copilot Edits 可在两种模式下运行:

  • Edit mode: select which files to edit, provide the relevant context and prompt, and Copilot will suggest code edits.
    编辑模式:选择要编辑的文件,提供相关上下文和提示,Copilot 就会提出代码编辑建议。
  • Agent mode (preview): let Copilot autonomously plan the tasks and relevant files that are needed to implement the request. Copilot will apply code edits and suggest terminal commands, and will continuously iterate to resolve any issues that arise.
    代理模式(预览):让 Copilot 自主规划执行请求所需的任务和相关文件。Copilot 会应用代码编辑和终端命令建议,并不断更新以解决出现的任何问题。
Note   备注

Agent mode is currently in preview and is only available in VS Code Insiders. Provide feedback and report issues in the Copilot repository.
代理模式目前处于预览阶段,仅适用于 VS Code Insiders。请在 Copilot 代码库中提供反馈并报告问题。

Important   重要

If you're using notebooks, Copilot Edits support is currently limited. We recommend that you use Copilot Chat or Inline Chat with notebooks in VS Code.
如果您使用笔记本,Copilot Edits 支持目前还很有限。我们建议您使用 Copilot Chat 或内联聊天与 VS Code 中的笔记本一起使用。

The following video demonstrates how to use Copilot Edits to extend a basic Express app, such as adding a new page, navigation bar, and theme switcher.
下面的视频演示了如何使用 Copilot Edits 扩展基本的 Express 应用程序,例如添加新页面、导航栏和主题切换器。

Tip   提示

If you don't yet have a Copilot subscription, you can use Copilot for free by signing up for the Copilot Free plan and get a monthly limit of completions and chat interactions.
如果您还没有订阅 Copilot,可以注册 Copilot 免费计划免费使用 Copilot,并获得每月完成次数和聊天互动次数限制。

Start a Copilot Edits session
启动 Copilot 编辑会话

You access Copilot Edits through the Copilot Edits view, where you can enter natural language prompts for getting edit suggestions. By default, the Copilot Edits view is available in the Secondary Side Bar.
您可以通过 Copilot Edits 视图访问 Copilot Edits,在此输入自然语言提示以获取编辑建议。默认情况下,Copilot Edits 视图位于辅助侧栏。

Screenshot showing the Copilot Edits view and welcome message.

To access the Copilot Edits view:
要访问 "副驾驶编辑 "视图:

  • Use the Ctrl+Shift+I keyboard shortcut
    使用 Ctrl+Shift+I 快捷键

  • Open the Copilot menu in the VS Code title bar, and then select Open Copilot Edits
    打开 VS 代码标题栏中的 Copilot 菜单,然后选择 Open Copilot Edits(打开 Copilot 编辑)。

    Screenshot showing the Copilot menu in VS Code title bar, highlighting the Open Edit Session item.

  • Use the View: Toggle Copilot Edits or Copilot Edits: Focus on Copilot Edits View command in the Command Palette (Ctrl+Shift+P)
    使用视图:切换 "副驾驶编辑 "或 "副驾驶编辑":命令面板中的 "视图:切换副驾驶编辑 "或 "副驾驶编辑:聚焦副驾驶编辑视图 "命令(Ctrl+Shift+P)

Because making code changes can be an iterative process, an edit session in Copilot Edits can consist of a sequence of requests (or turns). You can send as many requests as you need to get the code to where you want it.
由于代码修改可能是一个迭代过程,因此 Copilot Edits 中的编辑会话可以由一系列请求(或转向)组成。你可以根据需要发送任意数量的请求,使代码达到你想要的效果。

Use edit mode  使用编辑模式

In edit mode, you select which files to edit and provide the relevant context and prompt. Copilot will suggest code edits based on your prompt.
在编辑模式下,你可以选择要编辑的文件,并提供相关的上下文和提示。Copilot 会根据你的提示提出代码编辑建议。

  1. Open the Copilot Edits view (Ctrl+Shift+I)
    打开 "副驾驶编辑 "视图 (Ctrl+Shift+I)

  2. Select Edit from the mode dropdown
    从模式下拉菜单中选择编辑

    Screenshot showing the Copilot Edits view, highlighting edit mode selected.

  3. Use Add Files to add files to the working set
    使用 "添加文件 "将文件添加到工作集中

    The working set indicates which files in the workspace can be edited by Copilot Edits.
    工作集表示 Copilot Edits 可以编辑工作区中的哪些文件。

  4. Enter a prompt to request code edits. Be specific and precise about the changes you want, and decompose larger tasks into smaller tasks.
    输入要求编辑代码的提示。要具体准确地说明您想要的更改,并将较大的任务分解为较小的任务。

    Copilot Edits streams the edits in the editor. In the working set, files that were edited by Copilot are marked in bold.
    Copilot 编辑将编辑器中的编辑信息流化。在工作集中,由 Copilot 编辑过的文件会以粗体标出。

    Tip   提示

    Let Copilot find the right files automatically by adding #codebase in your prompt. Make sure to enable the github.copilot.chat.edits.codesearch.enabled (preview) setting to get the best results.
    在提示中添加 #codebase ,让 Copilot 自动找到正确的文件。确保启用 github.copilot.chat.edits.codesearch.enabled (预览) 设置,以获得最佳效果。

  5. Review the suggested edits and accept or discard the suggested edits
    审查建议的编辑内容,接受或放弃建议的编辑内容

  6. Iterate on the code changes
    迭代代码更改

    If you're not entirely happy with the edits, you can ask follow-up questions, such as "don't include the phone number", or "use jest instead of vitest". Or you can incrementally edit your code further. For example, when building a web app, use a series of prompts such as "add a navigation bar", "add a theme switcher", "store order items in JSON format in MongoDB".
    如果您对编辑不完全满意,可以提出后续问题,如 "不要包含电话号码 "或 "使用 jest 而不是 vitest"。或者,你也可以循序渐进地进一步编辑代码。例如,在构建网络应用时,可以使用一系列提示,如 "添加导航栏"、"添加主题切换器"、"在 MongoDB 中以 JSON 格式存储订单项目"。

Use agent mode (preview)
使用代理模式(预览)

In agent mode, Copilot Edits operates in a more autonomous and dynamic manner to achieve the desired outcome. To process a request, Copilot loops over the following steps and iterates multiple times as needed:
在代理模式下,Copilot Edits 会以更加自主和动态的方式运行,以实现所需的结果。在处理请求时,Copilot 会循环执行以下步骤,并根据需要进行多次迭代:

  • Determines the relevant context and files to edit autonomously.
    确定要自主编辑的相关上下文和文件。
  • Offers both code changes and terminal commands to complete the task. For example, Copilot might compile code, install packages, run tests, and more.
    提供代码更改和终端命令来完成任务。例如,Copilot 可以编译代码、安装软件包、运行测试等。
  • Monitors the correctness of code edits and terminal command output and iterates to remediate issues.
    监控代码编辑和终端命令输出的正确性,并反复修正问题。

Copilot Edits agent mode uses a set of tools to accomplish these tasks. These tools can run in parallel to accomplish the requested task.
Copilot 编辑代理模式使用一组工具来完成这些任务。这些工具可以并行运行,以完成要求的任务。

To use agent mode in Copilot Edits:
在 Copilot Edits 中使用代理模式:

  1. Enable agent mode in by setting the chat.agent.enabled setting to true.
    将 chat.agent.enabled 设置为 true 以启用代理模式。

  2. Open the Copilot Edits view (Ctrl+Shift+I)
    打开 "副驾驶编辑 "视图 (Ctrl+Shift+I)

  3. Select Agent from the mode dropdown
    从模式下拉菜单中选择代理

    Screenshot showing the Copilot Edits view, highlighting agent mode selected.

  4. Enter a prompt to request code edits.
    输入要求编辑代码的提示。

    You don't have to specify the working set. In agent mode, Copilot Edits determines the relevant context and files to edit autonomously.
    您无需指定工作集。在代理模式下,Copilot Edits 会自主决定相关上下文和要编辑的文件。

    Screenshot showing the Copilot Edits view, highlighting that Copilot searched the codebase for relevant files.

    Copilot Edits streams the edits in the editor and updates the working set. In addition, Copilot can suggest terminal commands to run.
    Copilot 编辑器可在编辑器中进行流式编辑,并更新工作集。此外,Copilot 还能建议运行终端命令。

  5. Review the suggested code edits, and confirm if Copilot can run the proposed terminal commands
    查看建议的代码编辑,并确认 Copilot 是否可以运行建议的终端命令

    As a user, you stay in control of the changes that are made to your project and can review the generated edits and need to confirm the terminal commands to run.
    作为用户,你可以随时控制对项目所做的更改,查看生成的编辑内容,并确认要运行的终端命令。

    Screenshot showing the Copilot Edits view, highlighting the terminal command that Copilot wants to run.

  6. Copilot Edits detects issues and problems in code edits and terminal commands, and will iterate and perform additional actions to resolve them.
    Copilot Edits 可检测代码编辑和终端命令中的问题,并会重复执行其他操作来解决这些问题。

    Screenshot showing the Copilot Edits view, highlighting that Copilot verified the code edits for errors.

    Note   备注

    The chat.agent.maxRequests setting controls the maximum number of requests that Copilot Edits can make in agent mode.
    chat.agent.maxRequests 设置可控制 Copilot Edits 在代理模式下可发出的最大请求数。

  7. Continue to ask follow-up questions and iterate on the code changes that Copilot Edits provides.
    继续提出后续问题,并对 Copilot Edits 提供的代码修改进行反复修改。

Note   备注

Agent mode for Copilot Edits is currently only available in VS Code Insiders.
Copilot 编辑的代理模式目前仅适用于 VS Code Insiders。

Manage the working set
管理工作集

The working set is the set of files that you want Copilot Edits to work on for your edit session. Copilot Edits does not make changes outside the working set, except when suggesting to create a new file. When you use agent mode, Copilot autonomously determines which files to edit and adds them to the working set.
工作集是您希望 Copilot Edits 在编辑会话中处理的文件集。Copilot Edits 不会在工作集之外进行修改,除非建议创建新文件。使用代理模式时,Copilot 会自主决定要编辑哪些文件,并将它们添加到工作集中。

Screenshot of Copilot Edits, showing the working set contains 3 files, including the currently opened file.

Important   重要

The working set is currently limited to 10 files.
工作集目前仅限于 10 个文件。

Copilot Edits automatically adds the active editor to the working set. If you have multiple editor groups, the active editor for each group is added to the working set. To add all open editors, select Add Files..., and then choose Open Editors from the Files Quick Pick.
Copilot Edits 会自动将活动编辑器添加到工作集中。如果有多个编辑器组,则每个编辑器组的活动编辑器都会添加到工作集中。要添加所有打开的编辑器,请选择 "添加文件...",然后从 "文件快速选取 "中选择 "打开编辑器"。

You have many options to add files to the working set:
您有很多将文件添加到工作集的选项:

  • Select Add Files... or use the Attach icon (Ctrl+/), and then select files in the Quick Pick.
    选择 "添加文件... "或使用 "附加 "图标 (Ctrl+/),然后在 "快速选择 "中选择文件。

    Tip   提示

    To quickly select multiple items from a Quick Pick, use the Up and Down keys to navigate the list, use the Right key to add the item as context, and then repeat this for other items.
    要从 "快速选取 "中快速选取多个项目,可使用 "向上 "和 "向下 "键浏览列表,使用 "向右 "键将项目添加为上下文,然后对其他项目重复此操作。

    Screenshot showing the Copilot Edits view and the file search Quick Pick, highlighting the buttons to add context.

  • Let Copilot find the right files automatically by adding #codebase in your prompt.
    在提示符中添加 #codebase ,让 Copilot 自动找到正确的文件。

    Make sure to enable the github.copilot.chat.edits.codesearch.enabled (preview) setting to get the best results.
    确保启用 github.copilot.chat.edits.codesearch.enabled (预览)设置,以获得最佳效果。

  • Drag and drop editor tabs, or files or folders from the Explorer view, Search view, or editor breadcrumb onto the Copilot Edits view.
    从 "资源管理器 "视图、"搜索 "视图或编辑器面包屑中拖放编辑器选项卡或文件或文件夹到 "Copilot 编辑 "视图。

    When you drop a folder onto the Copilot Edits view, all files in that folder are added to the working set.
    将文件夹拖放到 Copilot 编辑视图上时,该文件夹中的所有文件都会添加到工作集中。

  • Right-click on a file in the Explorer view or Search view and select Add File to Copilot Edits.
    右键单击 "资源管理器 "视图或 "搜索 "视图中的文件,然后选择 "添加文件到 Copilot 编辑"。

  • Select a suggested file. When you add one or more files to the working set, Copilot Edits proposes other relevant files based on the Git history.
    选择推荐文件当你在工作集中添加一个或多个文件时,Copilot Edits 会根据 Git 历史记录推荐其他相关文件。

    If you don't want to see these suggestions, you can disable them with the github.copilot.chat.edits.suggestRelatedFilesFromGitHistory setting.
    如果不想看到这些建议,可以使用 github.copilot.chat.edits.suggestRelatedFilesFromGitHistory 设置禁用它们。

When Copilot Edits generates edits for your project, it visually indicates which files in the working set are edited. Select a file in the working set to open it and view the proposed edits in the editor.
Copilot Edits 为项目生成编辑时,会直观显示工作集中哪些文件需要编辑。选择工作集中的某个文件,即可打开该文件,并在编辑器中查看建议的编辑内容。

Screenshot showing the Copilot Edits response for "Add a feedback field in the contact page" and showing the diff in the editor.

Accept or discard edits
接受或放弃编辑

Copilot Edits gives you a code review flow where you can accept or discard each of the AI-generated edits. If you discard the edits, the modified files are restored to their previously accepted state.
Copilot Edits 为你提供了一个代码审查流程,你可以接受或放弃人工智能生成的每个编辑。如果放弃编辑,修改后的文件将恢复到之前接受的状态。

With the editor overlay controls, you can navigate between the suggested edits by using the and controls. Use the Accept or Discard button to accept or reject the edits for a given file.
通过编辑器叠加控件,您可以使用 和 在建议的编辑之间进行导航。使用 "接受 "或 "放弃 "按钮可接受或拒绝指定文件的编辑。

Screenshot showing the Editor with proposed changes, highlighting the review controls in the editor table bar.

To accept or discard a specific edit within a file, hover over the code edit and use the Accept or Discard controls for that edit.
要接受或放弃文件中的特定编辑,请将鼠标悬停在代码编辑上,然后使用该编辑的 "接受 "或 "放弃 "控件。

Alternatively, you can also accept or discard the changes from the working set in the Copilot Edits view:
或者,您也可以在 Copilot Edits 视图中接受或放弃工作集中的更改:

  • Select Accept (Ctrl+Enter) or Discard (Ctrl+Backspace) in the working set title bar to accept or discard all edits in the working set
    在工作集标题栏中选择接受(Ctrl+Enter)或丢弃(Ctrl+Backspace),以接受或丢弃工作集中的所有编辑内容

  • Select the Accept or Discard icon on an individual working set file to apply the action to that specific file
    在单个工作集文件上选择 "接受 "或 "丢弃 "图标,将操作应用于该特定文件

Screenshot showing the Copilot Edits view, highlighting the Accept All and Discard All buttons.

With the chat.editing.autoAcceptDelay setting, you can configure a delay after which the suggested edits are automatically accepted. Hover over the editor overlay controls to cancel the auto-accept countdown.
通过 chat.editing.autoAcceptDelay 设置,您可以配置自动接受建议编辑的延迟时间。将鼠标悬停在编辑器覆盖控件上可取消自动接受倒计时。

When you close VS Code, the status of the pending edits is remembered. When you reopen VS Code, the pending edits are restored and you can still accept or discard the edits.
当您关闭 VS 代码时,待处理编辑的状态会被记住。当您重新打开 VS 代码时,待处理的编辑会恢复,您仍然可以接受或放弃编辑。

Note   备注

In agent mode, edits are automatically saved to disk, regardless if Auto Save (files.autoSave) is enabled. You can still review the edits and choose to discard them if needed.
在代理模式下,无论是否启用自动保存 (files.autoSave),编辑内容都会自动保存到磁盘。您仍然可以查看编辑内容,并在需要时选择放弃。

Undo edits  撤销编辑

As you're sending requests to make edits to your code, you might want to roll back some of these changes, for example because you want to use another implementation strategy.
在您发送请求对代码进行编辑时,您可能希望回滚其中的一些更改,例如因为您想使用另一种实现策略。

You can use the Undo Last Edit control in the Copilot Edits view title bar to revert the last edits and return to the state before sending the last request. After you perform an undo of the last edits, you can redo those edits again by using the Redo Last Edit control in the Copilot Edits view title bar.
您可以使用 Copilot 编辑视图标题栏中的 "撤销上次编辑 "控件来恢复上次编辑,并返回到发送上次请求前的状态。撤销最后一次编辑后,可以使用 Copilot 编辑视图标题栏中的重做最后一次编辑控件再次重做这些编辑。

Screenshot showing the Copilot Edits view, highlighting the Undo and Redo actions in the view title bar.

You can also use the Undo Edits (Delete) control when hovering over a request in the Copilot Edits view to revert all edits that were made from that request onwards.
将鼠标悬停在 Copilot 编辑视图中的申请上时,还可以使用撤销编辑(删除)控件来恢复从该申请开始的所有编辑。

Screenshot showing the Copilot Edits view, highlighting the Undo Edits control for a specific request.

Tip   提示

Sometimes Copilot starts walking down the wrong path when generating edits. Once that happens, it can be hard to convince it about another approach by adding to the conversation. In that case, use Undo Last Edit to the point where you agree with Copilot's responses. Then restart from there with a refined prompt.
有时,Copilot 会在生成编辑时走错路。一旦出现这种情况,就很难通过添加对话来说服它采用另一种方法。在这种情况下,可以使用 "撤消上次编辑",直到您同意 Copilot 的回复。然后从那里重新开始,并进行细化提示。

Send a chat request to Copilot Edits
向 Copilot Edits 发送聊天请求

Copilot Chat is great for asking questions and exploring ideas about your project or technology topics in general. Rather than applying each code block from Copilot Chat to your code, you can transfer the chat session to Copilot Edits. Copilot Edits is optimized for code editing and can apply code suggestions directly in your code, across multiple files simultaneously.
Copilot 聊天室非常适合就您的项目或一般技术主题提出问题和探讨想法。与其将 Copilot Chat 中的每个代码块应用到代码中,不如将聊天会话转移到 Copilot Edits 中。Copilot Edits 针对代码编辑进行了优化,可直接在代码中应用代码建议,并同时跨多个文件。

In the Chat view, select the Edit with Copilot button at the bottom of the chat conversation to apply the suggested code changes with Copilot Edits. If you have multiple chat requests in the chat session, you can select which requests you want to transfer to Copilot Edits.
在聊天视图中,选择聊天对话底部的 Copilot 编辑按钮,即可使用 Copilot 编辑应用建议的代码更改。如果聊天会话中有多个聊天请求,可以选择要转移到 Copilot 编辑的请求。

Screenshot highlighting the Edit with Copilot button in the Chat view to move a chat conversation to Copilot Edits.

After moving a chat request to Copilot Edits, the chat request is removed from the chat conversation in the Chat view.
将聊天请求移动到 Copilot Edits 后,聊天请求会从聊天视图的聊天对话中移除。

Agent mode tools  代理模式工具

To complete a request, Copilot Edits uses a set of tools to accomplish the individual tasks. Consider these tools as specialized utilities that Copilot can use to perform a specific task. Examples of such tasks are listing the files in a directory, editing a file in your workspace, running a terminal command, getting the output from the terminal, and more.
为了完成一个请求,Copilot Edits 使用一系列工具来完成各项任务。将这些工具视为专门的实用工具,Copilot 可以使用它们来执行特定任务。例如,列出目录中的文件、编辑工作区中的文件、运行终端命令、从终端获取输出等。

Based on the outcome of a tool, Copilot might invoke other tools to accomplish the overall request. For example, if a code edit results in syntax errors in the file, Copilot might explore another approach and suggest different code changes.
根据一个工具的结果,Copilot 可能会调用其他工具来完成整个请求。例如,如果代码编辑导致文件出现语法错误,Copilot 可能会探索另一种方法,并提出不同的代码修改建议。

Although agent mode can operate in an autonomous manner, you maintain control over the generated edits and the terminal commands that are run.
虽然代理模式可以自主运行,但您仍可以控制生成的编辑内容和运行的终端命令。

Settings  设置

The following list contains the settings related to Copilot Edits. You can configure settings through the Setting editor (Ctrl+,).
以下列表包含与 Copilot 编辑相关的设置。您可以通过设置编辑器(Ctrl+, )配置设置。

  • chat.editing.confirmEditRequestRemoval - ask for confirmation before undoing an edit (default: true)
    chat.editing.confirmEditRequestRemoval--撤销编辑前要求确认(默认: true )
  • chat.editing.confirmEditRequestRetry - ask for confirmation before performing a redo of the last edit (default: true)
    chat.editing.confirmEditRequestRetry-重做最后一次编辑前请求确认(默认: true )
  • chat.editing.alwaysSaveWithGeneratedChanges - automatically save generated changes from Copilot Edits to disk (default: false)
    chat.editing.alwaysSaveWithGeneratedChanges - 自动将 Copilot 编辑生成的更改保存到磁盘(默认: false )
  • chat.agent.enabled - enable or disable agent mode in Copilot Edits (default: false)
    chat.agent.enabled - 在 Copilot 编辑中启用或禁用代理模式(默认: false )
  • chat.editing.autoAcceptDelay - configure a delay after which suggested edits are automatically accepted, use zero to disable auto-accept (default: 0)
    chat.editing.autoAcceptDelay - 配置自动接受编辑建议的延迟时间,使用 0 可禁用自动接受(默认值:0)
  • github.copilot.chat.edits.codesearch.enabled (preview) - let Copilot find the right files by adding #codebase to your prompt, similar to how agent mode works (default: false)
    github.copilot.chat.edits.codesearch.enabled (预览)- 让 Copilot 通过在提示中添加 #codebase 来找到正确的文件,类似于代理模式的工作方式(默认: false )
  • chat.agent.maxRequests - maximum number of requests that Copilot Edits can make in agent mode (default: 5 for Copilot Free users, 15 for other users)
    chat.agent.maxRequests - Copilot Edits 在代理模式下可发出的最大请求数(默认值:Copilot 免费用户为 5,其他用户为 15)

Keyboard shortcuts  键盘快捷键

The following list contains the default keyboard shortcuts related to Copilot Edits. You can modify any of the default keyboard shortcuts by using the Keyboard Shortcuts editor (Ctrl+K Ctrl+S).
以下列表包含与 Copilot 编辑相关的默认键盘快捷键。您可以使用键盘快捷键编辑器(Ctrl+K Ctrl+S)修改任何默认键盘快捷键。

  • Ctrl+Shift+I - Open the Copilot Edits view
    Ctrl+Shift+I - 打开 "副驾驶编辑 "视图
  • Ctrl+Alt+Enter - Send a prompt from the Chat view to Copilot Edits
    Ctrl+Alt+Enter - 从 "聊天 "视图向 "Copilot 编辑 "发送提示信息
  • Ctrl+/ - Attach context to your prompt
    Ctrl+/ - 将上下文附加到提示符上
  • unassigned - Save all edited files to disk
    未指定 - 将所有编辑过的文件保存到磁盘中
  • Ctrl+Enter - Accept all edits
    Ctrl+Enter - 接受所有编辑
  • Ctrl+Backspace - Discard all edits
    Ctrl+Backspace - 丢弃所有编辑内容
  • Shift+Alt+F5 - Navigate to the previous edit within a file
    Shift+Alt+F5 - 导航至文件中的上一个编辑内容
  • Alt+F5 - Navigate to the next edit within a file
    Alt+F5 - 导航至文件中的下一个编辑内容
Tip   提示

If you want to change a keyboard shortcut for an action that's specific to the Copilot Edits view, you need to include the following condition in the when clause: chatLocation == 'editing-session'.
如果要更改 Copilot 编辑视图特定操作的键盘快捷键,需要在 when 子句中包含以下条件: chatLocation == 'editing-session' .

Limitations  局限性

  • Multiple simultaneous edit sessions are not supported yet.
    目前还不支持多个同步编辑会话。
  • The use of @workspace /new to scaffold a new project is not supported yet in an Edit session. For now, use Copilot Chat for the initial scaffolding.
    在 "编辑 "会话中,还不支持使用 @workspace /new 为新项目搭建脚手架。目前,请使用 Copilot Chat 搭建初始脚手架。
  • Although #codebase is great at finding relevant context for your query, subsequent generated edits are of widely varying quality. Experiment with the github.copilot.chat.edits.codesearch.enabled (preview) setting for an improved, agentic experience to find files, or explicitly add files to your working set to create better results.
    虽然 #codebase 能很好地为您的查询找到相关上下文,但随后生成的编辑质量参差不齐。请尝试使用 github.copilot.chat.edits.codesearch.enabled (预览)设置,以获得更好的代理体验来查找文件,或者明确地将文件添加到工作集中,以创建更好的结果。
  • Support for Jupyter notebooks, other custom text formats, and binary file formats is absent or untested.
    不支持或未测试 Jupyter 笔记本、其他自定义文本格式和二进制文件格式。
  • The working set is currently limited to 10 files.
    工作集目前仅限于 10 个文件。
  • Copilot Edits is limited to 7 editing requests per 10 minutes.
    Copilot Edits 每 10 分钟仅限 7 次编辑请求。

Frequently asked questions
常见问题

How is Copilot Edits different from Copilot Chat?
Copilot Edits 与 Copilot Chat 有何不同?

Both Copilot Chat and Copilot Edits use a conversational interface, where you can use natural language prompts to get AI-powered suggestions. There are several distinct differences between Copilot Edits and Copilot Chat.
Copilot Chat 和 Copilot Edits 都使用对话式界面,你可以使用自然语言提示来获取人工智能支持的建议。Copilot Edits 和 Copilot Chat 有几个明显的不同点。

Copilot Edits puts you in the context of code editing, where you start an edit session and use prompts for making changes to your codebase. Copilot Edits can generate and apply code changes directly across multiple files in your codebase. You can immediately preview the generated edits within the context of your code.
Copilot Edits 可让你置身于代码编辑的环境中,启动编辑会话并使用提示对代码库进行更改。Copilot Edits 可以直接在代码库的多个文件中生成和应用代码更改。您可以在代码上下文中立即预览生成的编辑。

The Chat view gives you a more general-purpose chat interface for asking questions about your code or technology topics in general. Copilot can also provide code suggestions and generate code blocks as part of the chat conversation. You need to manually apply each code block to the different files in your project to evaluate their validity.
聊天 "视图为您提供了一个更通用的聊天界面,用于询问有关代码或一般技术主题的问题。作为聊天对话的一部分,Copilot 还能提供代码建议并生成代码块。您需要手动将每个代码块应用到项目中的不同文件,以评估其有效性。

Inline Chat keeps you in the coding flow by providing a chat interface in the editor, where you can preview the generated code suggestions directly in the context of your code. The scope of Inline Chat is limited to the editor in which it's started, so it can only provide code suggestions for a single file. You can also use Inline Chat to ask general-purpose questions.
Inline Chat 通过在编辑器中提供一个聊天界面,让你保持在编码流程中,你可以直接在代码上下文中预览生成的代码建议。Inline Chat 的范围仅限于启动它的编辑器,因此它只能为单个文件提供代码建议。您也可以使用内联聊天工具提出通用问题。

Copilot Edits also provides you a code review flow where you can easily review generated edits and decide to accept or discard them. Copilot Chat does not have this code review mechanism. In addition, you can undo past edits and roll back changes to a previous accepted state.
Copilot Edits 还为您提供了代码审查流程,您可以轻松审查生成的编辑内容,并决定接受或放弃它们。Copilot Chat 没有这种代码审查机制。此外,您还可以撤销过去的编辑,并将更改回滚到之前已接受的状态。

The following table shows a comparison of the capabilities of each experience.
下表列出了每种体验的功能对比。

Capability  能力 Copilot Edits  副驾驶编辑 Chat view  聊天视图 Inline Chat  在线聊天 Quick Chat  快速聊天
Multi-file edits  多文件编辑 ✅* ✅*
Preview code edits  预览代码编辑
Code review flow  代码审查流程
Roll back changes  回滚更改
Attach context  附加上下文
Use participants & commands
使用参与者和命令
Generate shell commands  生成 shell 命令
General-purpose chat  通用聊天

* code blocks are included in the chat conversation and need to be applied to the right file manually
* 代码块包含在聊天对话中,需要手动应用到正确的文件中

Can I change the location of the Copilot Edits view?
可以更改 "副驾驶编辑 "视图的位置吗?

You can drag and drop the Copilot Edits view into the Activity Bar to show it in the Primary Side Bar. You can also move it to the Secondary Side Bar. Learn more about custom layouts in VS Code.
您可以将 Copilot Edits 视图拖放到 "活动栏 "中,使其显示在 "主侧栏 "中。也可以将其移动到辅助侧栏。了解有关 VS 代码中自定义布局的更多信息。

Why would I use edit mode instead of agent mode?
为什么要使用编辑模式而不是代理模式?

Consider the following criteria to choose between edit mode and agent mode:
在编辑模式和代理模式之间做出选择时,请考虑以下标准:

  • Edit scope: you might use edit mode if your request involves only code edits and you know the precise scope and working set for the changes.
    编辑范围:如果您的请求只涉及代码编辑,并且您知道更改的精确范围和工作集,则可以使用编辑模式。
  • Preview feature: agent mode is still in preview and might not work for all scenarios.
    预览功能:代理模式仍处于预览阶段,可能无法适用于所有场景。
  • Duration: agent mode involves multiple steps to process a request, so it might take longer to get a response. For example, to determine the relevant context and files to edit, determine the plan of action, and more.
    持续时间:代理模式涉及多个步骤来处理请求,因此可能需要更长的时间才能得到回复。例如,确定要编辑的相关上下文和文件、确定行动计划等。
  • Non-deterministic: agent mode evaluates the outcome of the generated edits and might iterate multiple times. As a result, agent mode can be more non-deterministic than edit mode.
    非确定性:代理模式会对生成的编辑结果进行评估,并可能重复多次。因此,代理模式可能比编辑模式更具非确定性。
  • Request quota: in agent mode, depending on the complexity of the task, one prompt might result in many requests to the backend.
    请求配额:在代理模式下,根据任务的复杂程度,一个提示可能会导致向后台发出许多请求。

Can I use Copilot Edits with notebooks?
Copilot Edits 可以与笔记本一起使用吗?

Copilot Edits support is limited when you're using notebooks. For example, agent mode is not available for working with notebooks in VS Code.
使用笔记本时,对 Copilot Edits 的支持有限。例如,代理模式不适用于在 VS Code 中使用笔记本。

We recommend that you use Copilot Chat or Inline Chat with notebooks in VS Code instead.
我们建议您在 VS Code 中使用 Copilot Chat 或带笔记本的 Inline Chat。