07-Copilot Edits
07-Copilot Edits
com/docs/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.
• Edit mode: select which files to edit, provide the relevant context and prompt, and Copilot will suggest code edits.
• 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.
Note
Agent mode is currently in preview and is only available in VS Code Insiders (https://code.visualstudio.com/insiders). Provide
feedback and report issues in the Copilot repository (https://github.com/microsoft/vscode-copilot-release/issues).
Important
If you're using notebooks, Copilot Edits support is currently limited. We recommend that you use Copilot Chat (/docs/copilot/
copilot-chat) or Inline Chat (/docs/copilot/copilot-chat#_inline-chat) with notebooks in 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.
0:00 / 1:06
Tip
If you don't yet have a Copilot subscription, you can use Copilot for free by signing up for the Copilot Free plan (https://
github.com/github-copilot/signup) and get a monthly limit of completions and chat interactions.
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.
• Open the Copilot menu in the VS Code title bar, and then select Open Copilot Edits
• Use the View: Toggle Copilot Edits or Copilot Edits: Focus on Copilot Edits View command in the Command Palette
( ⇧⌘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.
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.
The working set indicates which files in the workspace can be edited by 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.
Tip
Let Copilot find the right files automatically by adding #codebase in your prompt. Make sure to enable the
! (vscode://settings/github.copilot.chat.edits.codesearch.enabled)github.copilot.chat.edits.codesearch.enabled
(preview) setting to get the best results.
5 Review the suggested edits and accept or discard the suggested edits
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".
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 agent mode uses a set of tools to accomplish these tasks. These tools can run in parallel to accomplish the
requested task.
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 streams the edits in the editor and updates the working set. In addition, Copilot can suggest terminal
commands to run.
5 Review the suggested code edits, and confirm if Copilot can run the proposed terminal commands
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.
6 Copilot Edits detects issues and problems in code edits and terminal commands, and will iterate and perform additional
actions to resolve them.
Note
The ! (vscode://settings/chat.agent.maxRequests)chat.agent.maxRequests setting controls the maximum number of
requests that Copilot Edits can make in agent mode.
7 Continue to ask follow-up questions and iterate on the code changes that Copilot Edits provides.
Note
Agent mode for Copilot Edits is currently only available in VS Code Insiders (https://code.visualstudio.com/insiders).
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.
Important
The working set is currently limited to 10 files.
Copilot Edits automatically adds the active editor to the working set. If you have multiple editor groups (/docs/getstarted/
userinterface#_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.
• Select Add Files... or use the Attach " icon ( ⌘/ ), and then select files in the Quick Pick.
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.
• Let Copilot find the right files automatically by adding #codebase in your prompt.
• Drag and drop editor tabs, or files or folders from the Explorer view, Search view, or editor breadcrumb onto the Copilot
Edits view.
When you drop a folder onto the Copilot Edits view, all files in that folder are added to the working set.
• Right-click on a file in the Explorer view or Search view and select Add File to Copilot Edits.
• 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.
If you don't want to see these suggestions, you can disable them with the
! (vscode://settings/
github.copilot.chat.edits.suggestRelatedFilesFromGitHistory)github.copilot.chat.edits.suggestRelatedFilesFromGitHistory
setting.
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 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.
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.
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:
• Select Accept ( ⌘Enter ) or Discard ( ⌘Backspace ) in the working set title bar to accept or discard all edits in the working
set
• Select the Accept or Discard icon on an individual working set file to apply the action to that specific file
countdown.
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.
Note
In agent mode, edits are automatically saved to disk, regardless if Auto Save (
! (vscode://settings/files.autoSave)files.autoSave ) is enabled. You can still review the edits and choose to discard them if
needed.
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.
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.
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 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.
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.
After moving a chat request to Copilot Edits, the chat request is removed from the chat conversation in the Chat view.
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.
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.
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 ( ⌘, ).
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 ( ⌘K ⌘S ).
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' .
Limitations
! (vscode://settings/github.copilot.chat.edits.codesearch.enabled)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.
• Support for Jupyter notebooks, other custom text formats, and binary file formats is absent or untested.
• The working set is currently limited to 10 files.
• Copilot Edits is limited to 7 editing requests per 10 minutes.
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.
The Chat view (/docs/copilot/copilot-chat#_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.
Inline Chat (/docs/copilot/copilot-chat#_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.
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.
Multi-file edits ✅ ✅* ✅*
Attach context ✅ ✅ ✅ ✅
General-purpose chat ✅ ✅ ✅
* code blocks are included in the chat conversation and need to be applied to the right file manually
Secondary Side Bar. Learn more about custom layouts (/docs/editor/custom-layout#_workbench) in VS Code.
• 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.
Copilot Edits support is limited when you're using notebooks. For example, agent mode is not available for working with notebooks
in VS Code.
We recommend that you use Copilot Chat (/docs/copilot/copilot-chat) or Inline Chat (/docs/copilot/copilot-chat#_inline-chat) with
notebooks in VS Code instead.
Related content
Yes No
02/06/2025
Follow @code(https://go.microsoft.com/fwlink/?LinkID=533687)
Request features(https://go.microsoft.com/fwlink/?LinkID=533482)
Report issues(https://www.github.com/Microsoft/vscode/issues)
Watch videos(https://www.youtube.com/channel/UCs5Y5_7XK8HLDX0SLNwkd3w)
(https://
www.microsoft.com)
(https://go.microsoft.com/fwlink/?LinkID=533687)
(https://github.com/microsoft/vscode) (https://www.youtube.com/@code)
Support (https://support.serviceshub.microsoft.com/supportforbusiness/create?sapId=d66407ed-3967-b000-4cfb-2c318cad363d)
Privacy (https://go.microsoft.com/fwlink/?LinkId=521839) Terms of Use (https://www.microsoft.com/legal/terms-of-use)
License (/License)