Next edit suggestions available in Visual Studio GitHub Copilot

GitHub Copilot code completions, or gray text, are specialized in autocompleting unfinished code or providing helpful template code. In reality, coding activities are more diverse than writing new code. What if Copilot could better assist your coding not only with code generation, but your code editing activities as well?

We are excited to announce next edit suggestions, or NES for short, is now available in Visual Studio 2022 17.14 to further improve your coding experience. NES leverages the previous edits made and predicts the next edit to come, whether it’s an insertion, deletion, or mix of both. Unlike Copilot completions which are limited to generating suggestions at your caret location, NES can support you anywhere in your file, where the next edit is most likely to occur.

Example usage scenarios

Next edit suggestions can be helpful in a variety of scenarios, not only making obvious repetitive changes like renaming, but also more logical changes when you are adding/removing variables or changing the intention of a method. Here are some examples:

1. Refactoring a 2D Point class to 3D Point:

2. Update the code syntax to modern C++ using STL:

Note that NES is not just making repetitive changes to updating all “printf() “ to “std::cout“, but also updating other syntax such as “fgets()“.

3. Make logical changes in response to a newly added variable:

NES responds quickly to the new variable, which adds the maximum number of guesses a player can make in a game, and Copilot Completions also jumps in to help.

Getting started with next edit suggestions

Enable NES via Tools > Options > GitHub > Copilot > Copilot Completions > Enable Next Edit Suggestions.

Like completions, all you need to do to get NES is to start coding!

When there is an available edit suggestion, it could be presented in a diff view where the red diff indicates the original code you had, and the green indicates the new one suggested by Copilot to clearly shows any replacement or deletion of your original code.

If the edit is on a different line than the one you are on now, it will suggest you Tab to Navigate to the corresponding line first. The arrow in the hint bar indicates where the next edit is located. You won’t need to manually search for related edits anymore; NES will lead the way!

Next edit suggestions pop up with a navigation hint bar that includes Tab and arrow key down, a purple arrow in the gutter space next to the line number, and inline diffs where red indicates the original code and green indicates the new code. The current caret location is on line 1 and the edit is on line 4, thus the navigation hint bar is suggesting the user to hit tab to jump from line 1 to line 4.

After you are on the same line as the edit, you can Tab to Accept the suggestion.

Next edit suggestions, still with inline diffs where red indicates the original code and green indicates the new code. Now the caret location is on line 4, where is the part of the suggestion area, so the gutter arrow changes from purple to grey, and the navigation hint bar changes to say Tab accept.

In addition to the hint bars, an arrow in the gutter also pops up to indicate that there is an edit suggestion available. You can click on the arrow to explore the edit suggestion menu. This menu allows you to interact with NES using a mouse, when you don’t want to press the Tab key.

Next edit suggestions, still with inline diffs where red indicates the original code and green indicates the new code. The view where user clicks on the gutter arrow, and a context menu pops up below the gutter arrow with three options: Navigate to, Accept, Dismiss

See next edit suggestions explained step-by-step:

Please give NES a try today to let it assist you in your logical editing flow! If you have any feedback, our team would love to hear from you through Developer Community to help us keep iterating on and improving NES!

Check out the new Visual Studio Hub

Stay connected with everything Visual Studio in one place! Visit the Visual Studio Hub for the latest release notes, YouTube videos, social updates, and community discussions.

Appreciation for your feedback

Your feedback helps us improve Visual Studio, making it an even more powerful tool for developers. We are immensely grateful for your contributions and look forward to your continued support. By sharing your thoughts, ideas, and any issues you encounter through Developer Community, you help us improve and shape the future of Visual Studio.

The post Next edit suggestions available in Visual Studio GitHub Copilot appeared first on Visual Studio Blog.

Previous Article

Restricting PAT Creation in Azure DevOps Is Now in Preview

Next Article

Helping machines understand visual content with AI

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *