Have you ever wished you had an AI assistant that could help you write code faster and better? That’s what Visual Studio Copilot Chat offers you: an AI-powered pair programmer that can answer your questions, suggest code snippets, explain code logic, and chat with you about your project. You can use Copilot to code faster and better, as it helps you avoid errors and learn new skills.
We have added two new features to the latest Visual Studio Copilot Chat extension: slash commands (/) that allow you to direct Copilot to perform specific tasks, and context Variables (#) that allow you to specify a file for Copilot to focus its answer on. We also have several preview features you can get a sneak peek on.
Download or update Visual Studio Copilot Chat extension to get the latest features
The ultimate conversational AI assistant for your coding tasks, download the Visual Studio extension.Compatible with Visual Studio 2022 version 17.8 and higher.
GitHub Copilot is free for verified students and for maintainers of popular open source projects on GitHub. If you are not a student or maintainer of a popular open source project, you can try GitHub Copilot for free with a one-time 30-day trial. After the free trial, you will need a paid subscription for continued use.
Slash commands
Slash commands are special commands that you can use in chat to perform specific actions on your code. For example, you can use:
- /doc to add a documentation comment
- /explain to explain the code
- /fix to propose a fix for the problems in the selected code
- /generate to generate code to answer your question
- /help to get help on Copilot Chat
- /optimize to analyze and improve running time of the selected code
- /tests to create unit tests for the selected code
Context variables
The context variables feature lets you easily add files from your solution to your questions by using the # symbol. When you reference a file, Copilot can access the file content and answer more specific questions about it. For example, you can ask “How does the #file:Main.cs file work?” or “What is the purpose of the #file:Calculator.cs file?” and get relevant answers from Copilot Chat. You can add multiple files to one question. This feature saves you time and effort by allowing you to include content from your project without copying and pasting.
You can see the referenced files in the chat under the answers. Just look for the link to the references to see what was added to your question. If you click on the links, it will take you to the included content.
Tips & Tricks for GitHub Copilot Chat in Visual Studio:
Get better answers by setting the context for GitHub Copilot in Visual Studio.Preview features
In addition to the main released feature of Visual Studio Copilot Chat, we also have some exciting preview features that you can try out and give us your feedback. These preview features are experimental and may not work as expected, but they can enhance your development experience with Visual Studio Copilot Chat. Here are some of the preview features and their brief descriptions:
- Exception Assistant in debugger: Copilot helps you diagnose and fix exceptions in your code. Copilot will provide you with relevant information about the exception, such as the cause, the location, the stack trace, and possible solutions.
- Suggestions for breakpoint expressions: Copilot helps you set conditional breakpoints in your code. Copilot will suggest expressions that evaluate to true or false based on the current context of your code.
- Commit message suggestions: Copilot helps you describe your set of changes by generating a Git commit message. You can then refine the message with “why” the change was made and commit.
- Solution reference: Copilot helps you find and navigate to the references of your code elements in your solution. By using #solution you are letting Copilot know to search your solution for relevant code to the question. These will than automatically added to the context of your question so copilot can use those for answering your question.
- Suggestions in the Performance Profiler: Copilot helps you optimize the performance of your code. Copilot will analyze the performance data collected by the Visual Studio Performance Profiler and suggest ways to improve the speed, memory usage, and responsiveness of your code.
- Test failure Analysis: Copilot helps you debug and fix the failures of your unit tests. Copilot will provide you with useful information about the test failure, such as the assertion message, the expected and actual values, the source code, and possible solutions.
Enable the Preview features
To enable these preview features, you need to go to Options -> GitHub -> Copilot Chat -> Preview features and check the boxes for the features you want to try and let us know how you experience is.We want to hear from you!
We appreciate all the feedback you’ve provided so far as we’ve been creating Copilot, and are excited to see where this next wave of AI-assisted productivity takes you as you create great software. Please try the new features and share your feedback – just use Visual Studio Visual Studio “Send feedback” to send us your suggestions, feedback and issues for GitHub Copilot in Visual Studio.
Commit message suggestions:
Is that only working on GitHub repositories?
I have a repository in DevOps where I want to use this feature as well.
Using Visual Studio 17.8.6
And Extension version 0.2.393.21236
I see those options:
- Enable AI Exception Assistant in the debugger
- Enable AI suggestions for breakpoint expressions
- Enable referencing your #Solutions (currently C# only)
- Enable suggestions in the Performance Profiler
But I don't see an option in the Tools\Options to enable Commit...
Hi Iwan, this seems to be a new bug.
We’re tracking this work here: https://developercommunity.visualstudio.com/t/AI-comment-on-commits-pencil-icon-missin/10579321
The commit messages are on by default in 0.2.393.21236 (released Feb 2). Check if you see the button when you create a commit message in Visual Studio. If that is not the case, can you create a Feedback Ticket so we can investigate what is going.
They should work on any git repository.
welp i guess skill just got thrown out the window, and this is where i get replaced.
Great stuff.
Consider adding buttons “Fix, Document, Test” instead of commands.
Aslo add links to Microsoft docs in the answers.
Why is ChatGPT often smarter? Sometimes Copilot Chat will just return the code you asked about without comment. ChatGPT never does that.
Good that you like it! If you have any examples where we do something else than you have request, can you share those with us in feedback tickets? That enables us to tune our instruction on real examples and adjust it better to your needs.
Thanks,
Peter [MSFT]
Add natural languages other than English to it, such as ChatGPT.
Hi Arman,
The model is instructed to use the language your IDE is in (locale). If you have any thoughts about this or specific case, can you make a feedback ticket in VS and show us how you would like it to work so we can improve on this.
Thanks Peter [MSFT]
still think I would prefer use ChatGPT, its real smarter
Just realized I was mixing up Visual Studio with VSCode after writing my thoughts below, oops 😅.
I'm genuinely enthusiastic about AI tools in development, especially for VSCode. That said, I've been noticing some standout features in other tools that seem to edge out Copilot and Copilot Chat in certain areas. Take Tabnine, for example - their chat for slash commands and documentation generation is super slick. CodiumAI impresses with its testing capabilities and its...
Hi Benjamin!
Thank you for the feedback. I would love to learn more about your experience using Copilot and the conversational aspects. Would you be interested in jumping on a call? If, so please reply with your email and I will organize something.
Thanks,
Rhea Patel
Product Manager for GitHub Copilot in Visual Studio
If only the in-editor chat would work... already opened a ticket for this issue (https://developercommunity.visualstudio.com/t/AskCopilot-not-working-in-C-code-windo/10560551)
The #solution reference will be very handy, also using multiple file references, although it would be nice if it would use automatically all "using" references in the current file or in referenced files, by default.
I find that /doc is very useful, as long as you dont select too much code, tried to /doc an interface declaration with about 30 methods,...
Thank you for reporting this, we have done a number of fixes for the focus in the latest version. Can you check you have updated to the latest version of the extension. Than if you still see the issue, can you report that in the open feedback ticket and tell us what extensions you have installed so we can check what is taking the focus away.
Am updating right now to VS2022 Preview 4, lets see if anything changes.
As for the bug – nothing takes focus away – its impossible to put focus onto the Copilot Chat in-editor window, it just doesnt accept it, clicks go through.
Done, updated and culprit found: Visual Assist from Wholetomato. Lets go testing Copilot Chat further.
I love it. This is the future.
Sometimes it gets lazy and tries to circulate around the question instead giving the answer, but eventually it normally gives up and spits out what is wanted.
Perhaps next step would be giving it more monitoring abilities and let it comment without asking, if the programmer is stuck. Not just code completions, but in the chat with explanations and bigger concepts. Little bit in a way where co-worker...
I’m glad you enjoy using GitHub Copilot and find it helpful for your programming tasks. I appreciate your suggestions for improving my functionalities and adding more personality to my responses. We will keep them in mind for future updates.
Fantastic features! Could you consider adding an option to customize the language for generating commit messages? I collaborate with a team that prefers commit messages in Portuguese.
Thank you for your feedback. If the editor is in Portuguese, we should give a response in Portuguese. If that is not the case, can you ask them to create a feedback ticket ‘report an issue’. We ask the model to respond in the local of Visual Studio.
Is this only for VS Copilot?
It is not for VS Code Copilot?
The features described in this blog are specific for Visual Studio Copilot. Visual Studio Code Copilot does have its own feature set, when possible, we try to sync on how the features can be used.
How can I get the feature set of VS code copilot?
Github Copilot seems to be a single service with a price plan and supported IDEs/tools. Do you mean that as a paid subscriber of this service, I will not get the full features although I use a supported tool like VS Code? Actually are there as many Github Copilot services as supported IDEs/tools with a shared same price plan?