GitHub Copilot Setup Guide for VS Code: Workspace Settings, Language Rules, Keybindings & Chat Commands
GitHub Copilot Setup Guide for VS Code: From Installation to Advanced Workflows
GitHub Copilot transforms VS Code into an AI-powered development environment. This guide walks you through complete setup including workspace-level configuration, per-language control, custom keybindings, and leveraging Copilot Chat for test generation workflows.
Prerequisites
- VS Code version 1.90 or later- An active GitHub Copilot subscription (Individual, Business, or Enterprise)- A GitHub account authenticated in VS Code
Step 1: Install the GitHub Copilot Extensions
Open your terminal and install both extensions via the CLI:
code —install-extension GitHub.copilot
code —install-extension GitHub.copilot-chat
Alternatively, open VS Code, press Ctrl+Shift+X, search for GitHub Copilot, and install both GitHub Copilot and GitHub Copilot Chat.
After installation, click the Accounts icon in the bottom-left corner of VS Code and sign in with your GitHub account. Authorize the OAuth flow when prompted.
Step 2: Configure Workspace-Level Settings
Workspace settings override user-level defaults for your specific project. Create or edit .vscode/settings.json in your project root:
{
“github.copilot.enable”: {
”*”: true,
“plaintext”: false,
“markdown”: true,
“yaml”: true
},
“github.copilot.advanced”: {
“inlineSuggestCount”: 3,
“listCount”: 10
},
“github.copilot.chat.localeOverride”: “en”,
“editor.inlineSuggest.enabled”: true,
“editor.inlineSuggest.showToolbar”: “onHover”
}
This configuration enables Copilot globally, disables it for plain text files, and ensures inline suggestions appear with a hover toolbar.
Step 3: Language-Specific Enable/Disable Rules
Fine-grained language control lets you decide exactly where Copilot assists. Add these rules to your .vscode/settings.json:
{
“github.copilot.enable”: {
"": true,
“python”: true,
“javascript”: true,
“typescript”: true,
“html”: true,
“css”: false,
“json”: false,
“plaintext”: false,
“markdown”: false,
“env”: false
}
}
The wildcard sets the default for all languages. Individual language identifiers override the wildcard. Setting env to false is a security best practice to prevent Copilot from suggesting content based on your .env files.
| Language ID | Recommended Setting | Reason |
|---|---|---|
python | true | Strong completion quality for Python |
typescript | true | Excellent type-aware suggestions |
json | false | Avoids noisy completions in config files |
env | false | Prevents secret leakage in suggestions |
markdown | optional | Useful for docs, noisy for notes |
Ctrl+Shift+P → **Preferences: Open Keyboard Shortcuts (JSON)** and add:
[
{
"key": "ctrl+shift+a",
"command": "editor.action.inlineSuggest.trigger",
"when": "editorTextFocus && !inlineSuggestVisible"
},
{
"key": "alt+]",
"command": "editor.action.inlineSuggest.showNext",
"when": "inlineSuggestVisible"
},
{
"key": "alt+[",
"command": "editor.action.inlineSuggest.showPrevious",
"when": "inlineSuggestVisible"
},
{
"key": "ctrl+shift+enter",
"command": "editor.action.inlineSuggest.acceptWord",
"when": "inlineSuggestVisible"
},
{
"key": "ctrl+shift+c",
"command": "workbench.action.chat.open",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+t",
"command": "workbench.action.chat.open",
"args": { "query": "/tests " },
"when": "editorTextFocus"
}
]The last keybinding opens Copilot Chat with the /tests slash command pre-filled, creating a rapid shortcut for test generation.
Step 5: Copilot Chat Slash Commands for Test Generation
Copilot Chat provides built-in slash commands accessible in the chat panel (Ctrl+Shift+I for inline chat or the Chat sidebar). Here are the key commands for test workflows:
| Command | Purpose | Example Usage |
|---|---|---|
/tests | Generate unit tests for selected code | Select a function → /tests |
/fix | Fix failing tests or bugs | Select failing code → /fix |
/explain | Understand code before writing tests | Select complex logic → /explain |
/doc | Add documentation to clarify testable behavior | Select function → /doc |
Ctrl+Shift+T (using the custom keybinding above) or open Chat and type /tests.- Review the generated test code. Copilot uses your project's existing test framework when it detects one.- Refine by adding context in chat: /tests using pytest with fixtures and parametrize for edge cases.- Insert the accepted code into your test file.For framework-specific output, provide context directly:
/tests Write Jest tests with describe/it blocks, mock the database module, and cover error handling paths/tests Generate pytest tests using @pytest.mark.parametrize for the calculate_discount function with boundary values
### Custom Chat Participants and Variables
Reference files and selections for richer context:
/tests #file:src/utils/parser.ts #selection
/tests Use the test patterns from #file:tests/helpers/base_test.py
Pro Tips
- Use
.github/copilot-instructions.md— Place a file at this path in your repo to give Copilot persistent project-wide instructions such as preferred frameworks, naming conventions, and architectural patterns. Copilot Chat reads this automatically.- Accept word-by-word — UseCtrl+Right Arrow(default) or your custom keybinding to accept suggestions one word at a time for more controlled adoption.- Cycle through suggestions — PressAlt+]andAlt+[to browse alternative completions before accepting.- Inline chat for surgical edits — PressCtrl+Ito open inline chat directly in the editor. Type/testsfor contextual test generation without leaving your code.- Exclude sensitive files — Add patterns to.copilotignore(same syntax as.gitignore) to prevent Copilot from reading secrets, credentials, or proprietary logic.- Pin Copilot Chat context — Use the paperclip icon in Chat to attach files as persistent context across multiple prompts in the same session.
Troubleshooting
| Issue | Cause | Solution |
|---|---|---|
| No suggestions appearing | Extension disabled or auth expired | Check status bar for Copilot icon. Click it to verify status. Re-authenticate via Ctrl+Shift+P → **GitHub Copilot: Sign In**. |
| Suggestions in wrong language | Language ID mismatch | Check the language mode in the bottom-right of VS Code. Click to change. Verify github.copilot.enable has the correct language ID. |
| Chat says "Copilot is not available" | Subscription or network issue | Verify subscription at github.com/settings/copilot. Check proxy settings: "http.proxy" in VS Code settings. Ensure *.githubusercontent.com is not blocked. |
| Slow or delayed suggestions | Network latency or large file context | Reduce file size or split large files. Check "github.copilot.advanced": {"length": 2500} to limit prompt size. |
| Keybinding conflicts | Another extension using the same shortcut | Open Ctrl+K Ctrl+S, search for conflicting keys, and reassign or remove duplicates. |
Run this quick checklist after configuration:
- Open a .ts or .py file and start typing a function — inline suggestions should appear.- Open a .json file — no suggestions should appear if you disabled it.- Press Ctrl+Shift+T — Copilot Chat should open with /tests pre-filled.- Select a function and type /tests in Chat — test code should be generated.- Check the Copilot status icon in the status bar — it should show as active.
## Frequently Asked Questions
Can I use different Copilot settings for different projects?
Yes. Workspace-level settings in .vscode/settings.json override your global user settings. Each project can have its own Copilot enable/disable rules, language filters, and inline suggestion preferences. This is especially useful in monorepos where some directories contain sensitive code. You can also use the multi-root workspace feature to apply different settings per folder.
How do I prevent Copilot from suggesting code based on my secrets or environment files?
Create a .copilotignore file in your project root using the same syntax as .gitignore. Add patterns like .env, .pem, secrets/, and config/credentials.. Additionally, set “env”: false in your github.copilot.enable configuration to disable suggestions entirely when editing environment files. For organization-wide policies, GitHub Copilot Business and Enterprise admins can configure content exclusion rules in the organization settings.
Does the /tests slash command support all test frameworks automatically?
Copilot Chat detects your project’s test framework by analyzing existing test files, package.json dependencies, requirements.txt, or build tool configurations. It supports Jest, Mocha, pytest, unittest, JUnit, xUnit, RSpec, and many others. If detection fails or you want a specific framework, explicitly state it in your prompt — for example, /tests using vitest with describe blocks. Providing an example test file as context with #file: further improves framework accuracy.