Effortless Adjustments with Adaptive Paste Powered by Copilot in Visual Studio 2022
Leah Tran details how Visual Studio 2022’s new Copilot-powered ‘adaptive paste’ feature reduces manual code adjustments, helping developers integrate and modify pasted code more efficiently.
Effortless Adjustments with Adaptive Paste in Visual Studio 2022
Author: Leah Tran
Visual Studio 2022 introduces a productivity-enhancing feature called adaptive paste, powered by GitHub Copilot. This new capability aims to minimize the manual work developers typically perform when integrating pasted code into their projects.
Streamline Manual Code Modifications with Adaptive Paste
Copying and pasting code often introduces the need for corrections and adjustments—such as fixing parameters, adjusting code style, or handling minor errors. These interruptions can disrupt your focus and accumulate to significant time spent on repetitive work. The adaptive paste feature addresses these issues by intelligently adapting newly pasted code to your project’s context.
Key ways adaptive paste helps:
- Aligns syntax and styling with the destination document.
- Infers and adjusts parameters based on context.
- Fixes minor errors introduced by code copying.
- Supports translation between human and code languages.
- Completes patterns or fills in missing code where appropriate.
Example: Implementing Interface Members
Consider a scenario where you’re working with a Math
class that implements an IMath
interface. If you paste only the implementation for the Ceiling
method, adaptive paste can recognize the incomplete interface and automatically suggest adding the missing Floor
method implementation, helping you complete your code more efficiently.
![Adaptive paste example gif]
How to Use Adaptive Paste
Adaptive paste works immediately when you perform a standard paste (Ctrl+V) in Visual Studio 2022, provided the snippet is at least three lines long. When applicable, a “Tab to adapt” suggestion appears. Press TAB
to see Copilot’s suggested adjustments. A preview diff lets you compare changes before accepting them.
Steps to enable and use adaptive paste
- Update to Visual Studio 2022 version 17.14 Preview 3 or the stable 17.14 version.
- Go to
Tools > Options > GitHub > Copilot > Editor > Enable Adaptive Paste
to turn it on. - Paste your code (at least three lines). If Copilot can adapt it, the suggestion will appear.
- Press
TAB
to view and accept the adapted code.
Integration with Developer Workflows
Adaptive paste is designed to help developers:
- Quickly integrate new code snippets with less manual rework.
- Reduce friction when fixing minor errors after a paste.
- Streamline coding patterns and repetitive modifications, letting you focus on more complex development tasks.
Stay Connected and Share Feedback
For the latest updates and resources, visit the Visual Studio Hub.
Your feedback is crucial—share your experiences and suggestions via the Developer Community to help make Visual Studio even better.
This post appeared first on “Microsoft DevBlog”. Read the entire article here