Using Slash Commands in GitHub Copilot for Visual Studio
GitHub Copilot is a coding assistant powered by Artificial Intelligence (AI), which can run in various environments and help you be more efficient in your daily coding tasks. In this new series of content, we will show you how GitHub Copilot works in Visual Studio specifically and how it helps you being more productive.
In this installment, we will demonstrate the usage of Slash Commands. Like my colleague Bruno Capuano calls them in the new short video we just published, Slash Commands are like "little magic spells"; in other words, by typing a slash (/) in a GitHub Copilot prompt, you open a choice where you can choose some commands which will have a predefined action.
Opening the Slash Commands menu
In order to open the Slash Commands menu, you can click on the Slash button inside the GitHub Copilot Chat window.
Another option is to simply type a slash character into the message box directly. Either action will open the menu which looks like this:
Let's review the commands together.
- askvs: This command "asks Visual Studio" a question. You can use it to ask questions about your code, about some functionalities, etc.
- doc: This command will insert a documentation comment related to the position of the cursor. For example, if the cursor is inside a method. GitHub Copilot will propose a comment for this method.
- exp: This command starts a new conversation thread, with a brand new context. You can then switch between the threads from a combo box on top of the chat window.
- explain: This command will explain a portion of code, as we saw in previous videos. If code is selected inside the current code window, this code will be explained. You can also use the # command to specify a different context.
- fix: This command will propose a fix for the code currently in context.
- generate: This command will generate some code corresponding to the question you just asked.
- help: This command will show some help about GitHub Copilot itself.
- optimize: This command will analyze the code in context, and propose an optimization (in terms of performance, lines of code, etc).
- tests: This command will create a unit test for the currently selected code. No more excuses for not writing tests!!
We will get more in details about each of these commands in future posts.
An example
In the short video, Bruno is showing how the /fix command works. There are a few typos and other issues in the selected code, and GitHub Copilot proposes a solution. As Bruno shows, the Slash Commands also work in the inline chat dialog which can be opened within any code file by typing Alt-Slash (Alt-/) or by right clicking and selecting "Ask Copilot" from the context menu.
More information
As always, you can find more information, in our collection with resources here. Also, you can see the full-length video here.
Stay tuned to this blog for more content posted regularly. And of course, you can also subscribe to our YouTube channel to get more video content!
Published on:
Learn moreWe can help you with Using Slash Commands in GitHub Copilot for Visual Studio
If you want help implementing, troubleshooting, or improving this product, contact us and we’ll point you in the right direction.
Related posts
This Month in Azure Static Web Apps | 09/2024
We are back with another edition of the Azure Static Web Apps Community! :party_popper: September was yet another month ...
GitHub Copilot for Azure: 6 Must-Try Features
As developers, we are constantly seeking tools that streamline our workflows and boost productivity. … Enter GitHub Copilot for Azure, now in ...
Responsible AI Mitigation Layers
Generative AI is increasingly being used in various kinds of systems to augment humans and infuse intelligent behavior into existing and new a...
Streamline Your Azure Workflow: Introducing GitHub Copilot for Azure in VS Code
I'm excited to announce the public preview of GitHub Copilot for Azure - a new addition to your toolkit that seamlessly integrates with G...
Build Intelligent Apps Code-First with Prompty and Azure AI
Building Generative AI applications can feel daunting for traditional app developers. What does the end-to-end applicati...
Certificación AI-900 (Fundamentos de IA) con Chicas en IA
La inteligencia artificial ha llegado para quedarse, ¡y más aún con la revolucionaria IA generativa! Para ayudar a los profesionales a especia...
Get certified with Learn Live GitHub series!
GitHub Universe is coming, and Microsoft and GitHub are partnering to offer a new special Learn Live series in Brazilian Portuguese, English a...
Certifícate con Learn Live GitHub en Español
Microsoft y GitHub se han unido para ofrecer una nueva serie especial de Learn Live en inglés y español: GitHub 2024. Del 10 al 24 de Octubre,...
Evaluating generative AI: Best practices for developers
As a developer working with generative AI, you've likely marveled at the impressive outputs your models can produce. But how do you ensure the...
Introducing Azure Product Retirement Livestreams
The Azure Retirements team, in collaboration with key partner groups, is excited t...