Effortless adjustments with an adaptive paste

Find yourself needing to adjust pasted code to actually work in your project? Visual Studio 2022 introduces the capability to adapt your pasted code with Copilot to reduce the time you spend on making tedious changes.

Streamline manual code modifications with adaptive paste

When you’re copying and pasting code, the process often comes with extra steps. Adjusting parameters, correcting styling, or fixing even the most minor errors can slow down your workflow. These small, repetitive tasks add up and disrupt your focus. Addressing these challenges, Visual Studio introduces a new Copilot-powered capability that adapts pasted code seamlessly, saving you time and effort.

This feature intelligently adapts pasted code to your solution’s context, incorporating the new code into your existing project by:

  • Aligning syntax and styling with the document
  • Inferring parameter adjustments
  • Fixing minor errors
  • Supporting language translation, human and code-based
  • Completing patterns or filling in blanks

Example: Implementing interface members

Imagine you’re working with a `Math` class that implements the `IMath` interface. You copy and paste the implementation for the `Ceiling` method into the same file. Adapting the pasted code will adjust the code to implement the missing `Floor` method, completing the interface for you.

Adaptive paste example gif

How to use it

The adaptive paste springs into action the moment you perform a regular paste using `Ctrl+V`, assuming the pasted code has at least three lines. When the “Tab to adapt” suggestion action appears, you can press the `TAB` key to request a suggestion. You’ll then see a diff that compares the original pasted code with the adjusted version, so you can preview changes before they’re applied.

Try adaptive paste in Version 17.14 Preview 3

Starting in Visual Studio 2022 version 17.14 Preview 3, you can try adaptive paste by turning on the option:

Tools > Options > GitHub > Copilot > Editor > Enable Adaptive Paste.

Once activated, adaptive paste becomes a helpful tool in your workflow. Whether you’re integrating new snippets, fixing small errors, or streamlining patterns, it supports you in coding more efficiently.

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 Effortless adjustments with an adaptive paste appeared first on Visual Studio Blog.

Previous Article

“Periodic table of machine learning” could fuel AI discovery

Next Article

New model predicts a chemical reaction’s point of no return

Write a Comment

Leave a Comment

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