How to Use Copilot Chat and Inline Chat in VS Code
Ask questions in the Copilot chat sidebar and edit code in place with inline chat and slash commands.
Inline completions are only half of Copilot. The chat features let you ask about your code in plain language, request fixes, and make edits without leaving the editor. This guide covers the chat sidebar, inline chat, and the slash commands and references that make chat answers far more accurate.
What you need
- GitHub Copilot and Copilot Chat installed and signed in
- A project open in VS Code
- About 6 minutes
Step 1: Open the chat sidebar
Click the chat icon in the Activity Bar or press Ctrl+Alt+I on Windows and Linux, or Cmd+Ctrl+I on macOS. Type a question and press Enter. The reply can include code blocks with buttons to copy them or insert them at your cursor.
Step 2: Use inline chat for in-place edits
Select a block of code and press Ctrl+I on Windows and Linux, or Cmd+I on macOS. A small chat box opens right over the selection. Describe the change you want, such as add input validation, and Copilot shows a diff you can accept or discard.
// before
function divide(a, b) {
return a / b;
}
// after: "add a guard for division by zero"
function divide(a, b) {
if (b === 0) throw new Error("Cannot divide by zero");
return a / b;
}Step 3: Use slash commands
Slash commands tell Copilot what kind of help you want. Type a forward slash at the start of a chat message to see the list. Common ones include /explain to walk through selected code, /fix to propose a correction, /tests to generate unit tests, and /doc to add documentation comments.
Step 4: Add context with references
Type the hash symbol in a chat message to attach context. Use #file to point at a specific file, #selection for the highlighted code, or #codebase to let Copilot search the whole workspace. Adding the right reference is the single biggest factor in getting a useful answer.
Example
Select a messy function, press the inline chat shortcut, and type rename variables for clarity and add comments. Copilot returns a cleaned-up version as a diff. You skim the change, click Accept, and the edit applies in place without copying anything by hand.
Watch related tutorials
30:00
5:42
24:16
33:42
41:18
28:05