May 14th, 2024

Mastering Slash Commands with GitHub Copilot in Visual Studio

GitHub Copilot, the AI-powered coding assistant, revolutionizes coding in Visual Studio with its advanced features. In this series, we delve into the efficiency and convenience offered by Slash Commands, elevating your coding workflow.

Introducing Slash Commands

Slash Commands are predefined actions within GitHub Copilot, accessible through the prompt interface. Bruno Capuano, in his latest video, elucidates these commands, accessible via the Slash button in the Copilot Chat window or by typing a forward slash in the message box.

Slash Commands menu by clicking the Slash button in the Copilot Chat window

Alternatively, you can also access the Slash Commands by typing a forward slash in the message box.

Image LBugnion 1 1712226760337

Key commands include:

  • doc: Insert a documentation comment in the current cursor position.
  • exp: Start a new conversation thread with a fresh context.
  • explain: Provide an explanation for the selected code.
  • fix: Suggest fixes for code errors and typos.
  • generate: Generate new code snippets based on your input.
  • optimize: Recommend code optimizations to improve performance.
  • tests: Create a unit test for the current code selection.
  • help: Access help and support for GitHub Copilot.

 

A Practical Example with /fix

Demonstrating the power of Slash Commands, the /fix command automatically suggests corrections for typos and errors, enhancing code quality and efficiency.

In the video, Bruno demonstrates how GitHub Copilot can automatically suggest corrections for typos and other issues. This command can be used in the main chat window, and it’s also accessible in the inline chat by pressing Alt-Slash (Alt-/) or through the right-click context menu.

As you can see, these Slash Commands can significantly improve your productivity in Visual Studio. Learn how to Install GitHub Copilot in Visual Studio.

Additional Resources

To learn more about GitHub Copilot and Slash Commands, check out our resource collection here. You can watch the full video here. For ongoing updates, stay tuned to this blog and consider subscribing to our YouTube channel for more insights and tutorials.

Author

Cynthia Zanoni
Cloud Advocate
Laurent Bugnion
Principal Cloud Advocate

Laurent is a Principal Cloud Advocate for Microsoft, expert in .NET, Visual Studio and is interested in Azure services such as Serverless, App Services, SignalR, Blazor, Data, AI and more. He works from home (Zurich, CH) for Microsoft Azure. His blog is at http://blog.galasoft.ch. He was also the author of the well-known legacy open source toolkit MVVM Light for XAML and Xamarin