Edit

Share via


Copilot Next Edit Suggestions

Next edit suggestions use recent edits you make to anticipate the next edit you might want to make, and the ___location of that edit. With this new ability, GitHub Copilot suggests revisions to your code, comments, tests, and more.

Inline completions are great at autocompleting a section of code. Copilot NES helps you stay in the logical edit flow, suggesting changes relevant to your current work, and you can simply Tab to quickly navigate and accept Copilot's suggestions. Suggestions may span a single symbol, an entire line, or multiple lines, depending on the scope of the potential change.

Prerequisites

To get started, you need:

Get started with NES

To get started with Copilot NES, enable the feature in Tools > Options > GitHub > Copilot > Copilot Completions > Enable Next Edit Suggestions.

Use next edit suggestions

To start getting suggestions from NES, start coding. When Copilot suggests code edits, you can navigate to it with the Tab key, and then accept it with the Tab key again. You save time by quickly jumping to the next relevant edit, without needing to manually search through files or references yourself. An arrow in the gutter indicates whether an edit suggestion is available.

Screenshot that shows arrows in gutter indicating next edit suggestions.

An arrow in the gutter indicates if there is an edit suggestion available. Click the arrow to explore the edit suggestion menu, which includes keyboard shortcuts.

Screenshot that shows the next edits menu.

If an edit suggestion is below the current editor view, the arrow points down instead of right. Scroll past an edit suggestion and the arrow hints the ___location of the next edit suggestion, pointing up or down based on where you're in the file.

Screenshot that shows arrow pointing upward to indicate next edit suggestion ___location in file.

Use cases for Next Edit Suggestions

NES is helpful in various scenarios, not only making obvious repetitive changes, but also logical changes. Here are some examples:

Catch and correct mistakes

  • NES helps with mistakes like typos, for example, if you wrote bol instead of bool.

    Screenshot that shows NES suggesting typo correction.

  • Copilot can also help with more challenging mistakes in logic, like an inverted ternary expression or a comparison that should use || instead of &&.

    Screenshot that shows NES suggesting the correction for an expression.

Change in intent

NES suggests changes to the rest of your code that match a change in intent. For example, when refactoring a Point class to Point3D.

Animated screenshot that shows NES suggestions for change in intent updates.

Update code syntax

NES helps with repetitive changes, such as updating code syntax to modern C++ using the Standard Library (STL). For example, when updating all printf() to std::cout, also update other syntax such as fgets().

Animated screenshot that shows NES suggesting code syntax updates

Refactor

  • Rename a variable once in a file, and NES will suggest updating it throughout the file. If you introduce a new name or naming pattern, Copilot suggests updates to subsequent code to match.

    Screenshot that shows NES suggesting edits when a variable is renamed.

  • Match code style. After you paste some code, NES suggests adjustments to match it with the style of the surrounding code.