We have introduced two new powerful 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. These features are available on the latest Chat extension that is compatible with Visual Studio 2022 version 17.8 and higher.
Slash Commands
Slash commands are special commands that you can use in chat to receive targeted assistance, including explanations, documentation, test creation, and various other forms of support related to 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 with Copilot Chat
- /optimize to analyze and improve the running time of the selected code
- /tests to create unit tests for the selected code
Context Variables
The context variables feature enables you to add files from your solution into your questions using the # symbol. By referencing a file in this way, you allow Copilot to access the content of the file and provide more targeted answers 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.
Besides these main features, you can also explore our other exciting new preview features
Join the discussion within GitHub Community.