Posted 11/12/2024

Tips and Tricks for Copilot in VS Code and VS

GitHub Copilot is getting smarter every month — and both VS Code and Visual Studio offer features beyond simple inline suggestions. Here’s a collection of practical tips, commands, and best practices to get the most out of it.

General

@workspace – a chat participant that understands your workspace, codebase, and project structure. It’s ideal for explaining code, generating tests, or helping with refactors.

Slash commands – shorthand for common tasks:

Type / in the chat input to see all supported commands.

Prompting Tips

Copilot performs best when you give it context. Instead of vague prompts like “optimize this code”, try being explicit:

// Optimize this method for readability and performance.
// Use LINQ and avoid multiple enumerations.

Workspace Awareness

Copilot can understand your entire workspace when you use @workspace. This is especially powerful for large projects or when working across multiple files.

Tip: You can index your workspace in VS Code settings so Copilot can search and reason across the entire solution.

VS Code Shortcuts

You can snooze inline suggestions if you want Copilot to stay silent for a while (Ctrl + . → “Snooze”).

Visual Studio Shortcuts

In Visual Studio, Copilot is tightly integrated with Solution Explorer — you can invoke it directly on classes or files.