|
| 1 | +--- |
| 2 | +title: Copilot Next Edit Suggestions |
| 3 | +description: Use Copilot Next Edit Suggestions (NES) to predict where you'll want to make your next edit and what that edit should be, based on your recent code edits. |
| 4 | +ms.date: 5/13/2025 |
| 5 | +ms.topic: get-started |
| 6 | +author: anandmeg |
| 7 | +ms.author: meghaanand |
| 8 | +ms.manager: mijacobs |
| 9 | +ms.subservice: ai-tools |
| 10 | +ms.collection: ce-skilling-ai-copilot |
| 11 | +monikerRange: '>= vs-2022' |
| 12 | +--- |
| 13 | +# Copilot Next Edit Suggestions |
| 14 | + |
| 15 | +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. |
| 16 | + |
| 17 | +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. |
| 18 | + |
| 19 | +## Prerequisites |
| 20 | + |
| 21 | +To get started, you need: |
| 22 | ++ Visual Studio 2022 [version 17.14](/visualstudio/releases/2022/release-history) or later |
| 23 | ++ [Sign in to Visual Studio using a GitHub account](work-with-github-accounts.md) with [Copilot access](https://docs.github.com/en/copilot/about-github-copilot/what-is-github-copilot#getting-access-to-copilot) <br/> |
| 24 | + <sup>**</sup> You can use [GitHub Copilot for Free](copilot-free-plan.md). Sign up and leverage AI to code faster and more efficiently. |
| 25 | + |
| 26 | +## Get started with NES |
| 27 | + |
| 28 | +To get started with Copilot NES, enable the feature in **Tools > Options > GitHub > Copilot > Copilot Completions > Enable Next Edit Suggestions**. |
| 29 | + |
| 30 | +## Use next edit suggestions |
| 31 | + |
| 32 | +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. |
| 33 | + |
| 34 | +:::image type="content" source="media/vs-2022/next-edit-suggestions/next-edit-suggestions-arrows.png" alt-text="Screenshot that shows arrows in gutter indicating next edit suggestions."::: |
| 35 | + |
| 36 | +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. |
| 37 | + |
| 38 | +:::image type="content" source="media/vs-2022/next-edit-suggestions/next-edits-menu.png" alt-text="Screenshot that shows the next edits menu." lightbox="media/vs-2022/next-edit-suggestions/next-edits-menu.png"::: |
| 39 | + |
| 40 | +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. |
| 41 | + |
| 42 | +:::image type="content" source="media/vs-2022/next-edit-suggestions/arrow-upward.png" alt-text="Screenshot that shows arrow pointing upward to indicate next edit suggestion location in file."::: |
| 43 | + |
| 44 | +## Use cases for Next Edit Suggestions |
| 45 | + |
| 46 | +NES is helpful in various scenarios, not only making obvious repetitive changes, but also logical changes. Here are some examples: |
| 47 | + |
| 48 | +### Catch and correct mistakes |
| 49 | + |
| 50 | +- NES helps with mistakes like typos, for example, if you wrote `bol` instead of `bool`. |
| 51 | + |
| 52 | + :::image type="content" source="media/vs-2022/next-edit-suggestions/fix-typo.png" alt-text="Screenshot that shows NES suggesting typo correction."::: |
| 53 | + |
| 54 | +- Copilot can also help with more challenging mistakes in logic, like an inverted ternary expression or a comparison that should use `||` instead of `&&`. |
| 55 | + |
| 56 | + :::image type="content" source="media/vs-2022/next-edit-suggestions/ternary-expression.png" alt-text="Screenshot that shows NES suggesting the correction for an expression."::: |
| 57 | + |
| 58 | +### Change in intent |
| 59 | + |
| 60 | +NES suggests changes to the rest of your code that match a change in intent. For example, when refactoring a `Point` class to `Point3D`. |
| 61 | + |
| 62 | +:::image type="content" source="media/vs-2022/next-edit-suggestions/change-in-intent-point-example.gif" alt-text="Animated screenshot that shows NES suggestions for change in intent updates." lightbox="media/vs-2022/next-edit-suggestions/change-in-intent-point-example.gif"::: |
| 63 | + |
| 64 | +### Update code syntax |
| 65 | + |
| 66 | +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()`. |
| 67 | + |
| 68 | +:::image type="content" source="media/vs-2022/next-edit-suggestions/update-code-syntax.gif" alt-text="Animated screenshot that shows NES suggesting code syntax updates" lightbox="media/vs-2022/next-edit-suggestions/update-code-syntax.gif"::: |
| 69 | + |
| 70 | +### Refactor |
| 71 | + |
| 72 | +- 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. |
| 73 | + |
| 74 | + :::image type="content" source="media/vs-2022/next-edit-suggestions/rename-variable-edits.png" alt-text="Screenshot that shows NES suggesting edits when a variable is renamed."::: |
| 75 | + |
| 76 | +- Match code style. After you paste some code, NES suggests adjustments to match it with the style of the surrounding code. |
| 77 | + |
| 78 | +## Related content |
| 79 | + |
| 80 | +- [GitHub Copilot Completions](visual-studio-github-copilot-extension.md) |
| 81 | +- [GitHub Copilot Chat](visual-studio-github-copilot-chat.md) |
| 82 | +- [GitHub Copilot Trust Center](https://resources.github.com/copilot-trust-center/) |
0 commit comments