What is the GitHub Copilot Chat experience for Visual Studio?
GitHub Copilot Completions and GitHub Copilot Chat in Visual Studio enable enhanced AI-assisted development in Visual Studio, helping you be more productive and efficient when writing code.
In this article, you'll learn about using Copilot Chat in Visual Studio, a fully integrated AI-powered chat experience from GitHub Copilot right within the Visual Studio IDE. It enables you to get coding information and support, such as syntax, programming concepts, context-specific code help, test cases, debugging, and more, without leaving the IDE. Use the chat interface to submit your question as prompt and set intent for better scoped answers.
For more information on the GitHub Copilot Completions in Visual Studio, see About GitHub Copilot Completions for Visual Studio.
Why use Copilot Chat in Visual Studio?
Copilot Chat provides AI assistance to help you make informed decisions and write better code. With tight integration in Visual Studio, Copilot Chat understands what you're working on and can help you with development tasks like:
- Code explanations: get in-depth analysis and explanation of how a code block works
- Code help: get answers to programming-related questions in natural language or code snippet format
- Code refinement: get context-specific code suggestions & recommendations
- Unit testing: generate unit tests
- Profiling: optimize code performance
- Debugging: find issues and get proposed fixes to bugs and exceptions.
Prerequisites
To get started, you need:
- Visual Studio 2022 version 17.8 or later
- Active subscription to GitHub Copilot for Individuals or GitHub Copilot for Business
- GitHub Copilot in Visual Studio
- Sign in to Visual Studio with the GitHub account that has an active GitHub Copilot subscription
Get GitHub Copilot Chat for Visual Studio
If you're using Visual Studio version 17.10 or later, GitHub Copilot Chat is included in the new unified GitHub Copilot experience available as a recommended component in the Visual Studio Installer. It is installed by default with all workloads, unless you choose to exclude it during installation.
If you're using Visual Studio versions 17.9 or earlier, install the GitHub Copilot Chat extension.
Note
- The GitHub Copilot and GitHub Copilot Chat extension should only be used in Visual Studio versions 17.9 or earlier. For Visual Studio versions 17.10+, GitHub Copilot experience is available as a recommended component in the Visual Studio Installer, and includes both GitHub Copilot Chat and Completions experiences.
- If you experience authentication issues after installing the extension, see Troubleshooting authentication issues with GitHub Copilot Chat.
- GitHub Copilot is not included in Visual Studio Subscriptions and is a separate subscription managed by GitHub. For questions regarding GitHub Copilot subscriptions and Support, see Individual Subscriptions or Business subscriptions.
Support for GitHub Copilot Chat will be provided by GitHub and can be reached at https://support.github.com.
Use Copilot Chat in Visual Studio
You can ask your coding related questions in natural language and GitHub Copilot Chat will answer these in your development context.
There are two places you can ask Copilot these questions; in a chat window, or directly inline in the code that you're looking to modify, using inline chat. For questions where your goal is to modify or add to the code file you have open in the editor, the inline chat view will usually work best, whereas more general coding questions are best answered in the chat pane.
See tips to improve Copilot chat results to learn how to use slash commands, references, sources used, and threads to get better answers with scoped context in Copilot Chat.
Note
With Visual Studio 2022 version 17.11, content exclusion is available for GitHub Copilot Chat in Visual Studio. Content excluded by your admin will now be ignored in chat's responses. See configuring content exclusions for GitHub Copilot to learn more.
Ask questions in the chat window
The chat window of Copilot Chat in Visual Studio enables you to ask your questions and see answers in the chat pane. It is usually the best way to work with Copilot on programming help and general coding questions.
In Visual Studio, select View > GitHub Copilot Chat.
In the Copilot Chat window, type a coding related question in the Ask Copilot text box. Press Enter or select Send to ask your question.
If Copilot Chat offers a code suggestion you want to use, select Copy code block to copy the code suggestion, Insert in new files to insert the code suggestion in a new file, or select Preview to insert the code suggestion in your current code file. Using the Preview button lets you preview the code in the target location so you can easily see what's being updated.
If you ask a question for help with understanding your code, Copy code block and Insert in new file options won't be available.
If you select Preview, you'll see the code suggestions in normal Visual Studio diff view pattern. You can review and refine what is being proposed and apply to your code by selecting Accept or discard by selecting Cancel.
If you select Insert in new file, you'll see the code suggestions in a new file. The file is not saved by default.
Ask questions in the inline chat view
The inline chat view of Copilot Chat in Visual Studio enables you to ask your questions and see answers inline with the code in the editor window itself. With inline chat, you don't have to go back and forth to the chat window. It is usually the best way to work with Copilot on questions that add to or update a currently open code file.
In Visual Studio, right click in your editor window and select Ask Copilot to bring up the inline chat view of Copilot Chat in the editor itself.
Type your coding related question in the Ask Copilot text box, and then press Enter or select Send to ask your question.
You'll see code suggestions from Copilot Chat in Visual Studio diff view. You can review and refine what is being proposed and apply to your code by selecting Accept or discard by selecting Cancel.
You can promote your inline chat thread to the chat window by selecting Continue in chat window. This'll preserve the record and context of your conversation, and you can continue in the chat window.
You can close the inline chat view by pressing Esc.
Next steps
To learn more, consider exploring the following resources: