Use edit mode in VS Code (original) (raw)

In this article

With chat edit mode in Visual Studio Code, you can use natural language to make edits across multiple files in your project. The edits are applied directly in the editor, where you can review them in-place, with the full context of the surrounding code.

By selecting specific files and providing clear context, you can guide edit mode to make targeted code changes and improvements.

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.

Prerequisites

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.

  1. Open edit mode in VS Code Stable or Insiders.
    Alternatively, open the Chat view (⌃⌘I (Windows, Linux Ctrl+Alt+I)) and select Edit from the chat mode selector.
    Screenshot showing the Copilot Edits view, highlighting edit mode selected.
  2. Select Add Context to provide indicate relevant context for your prompt.
    To make sure that Copilot has the right context for the changes you want to make, add context to your prompt, such as files or folders in your workspace. Learn more about adding context to your Copilot prompt.
    The active editor is automatically added as context. When you add files, other relevant files might be suggested.
    Tip
    Let Copilot find the right files automatically by adding #codebase in your prompt. Make sure to enable the github.copilot.chat.codesearch.enabled (preview) setting to get the best results.
  3. Enter your prompt in the chat input field to indicate the type of edits you want to make.
    Experiment with some of these example questions to get started:
    • Refactor the calculate function to make it more efficient.
    • Add a login form to the app. Use OAuth for authentication.
    • Add unit tests for the calculator class. Use vitest as the test framework.
  4. Notice that Copilot streams the suggested edits directly in the editor.
    The Chat view shows the list of files that were edited in bold text. The editor overlay controls enable you to navigate between the suggested edits.
    Screenshot that shows the Copilot Edits view, highlighting the changed files list and the indicator in the Explorer view and editor tabs.
  5. Review the suggested edits and accept or discard the suggested edits.
  6. Continue to iterate on the code changes to refine the edits or to implement additional features.

Accept or discard edits

Copilot lists the files that were edited in the changed files list in the Chat view. Files with pending edits also have an indicator in the Explorer view and editor tabs.

Screenshot that shows the Copilot Edits view, highlighting the changed files list and the indicator in the Explorer view and editor tabs.

With the editor overlay controls, you can navigate between the suggested edits by using the Up () and Down () controls. Use the Keep or Undo 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 overlay controls.

Use the Keep or Undo controls in the editor or Chat view to accept or reject individual or all suggested edits.

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.

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.

Revert 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 or because Copilot starts walking down the wrong path when generating edits.

You can use the Undo Last Edit control in the Chat 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 edit, you can redo those edits again by using the Redo Last Edit control in the Chat view title bar.

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 (x icon) when hovering over a request in the Copilot Edits view to revert all edits that were made from that request onwards.

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

Settings

The following list contains the settings related to edit mode. You can configure settings through the Setting editor (⌘, (Windows, Linux Ctrl+,)).

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 (Windows, Linux Ctrl+K Ctrl+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

Frequently asked questions

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.

Why would I use edit mode instead of agent mode?

Consider the following criteria to choose between edit mode and agent mode:

05/08/2025