GitHub Copilot with Visual Studio Code
VS Code is where Copilot is finished. Every tracked feature is supported rather than in preview, new capabilities land here first, and several — chat participants, chat variables, edit mode — exist in no other editor at all.
That makes this lesson do double duty. If you work in VS Code, it is your guide. If you work elsewhere, it is the clearest picture of what Copilot looks like with everything switched on, and therefore of what your editor is missing.
Copilot support
VS Code
The reference implementation. Every Copilot feature ships here first, and several exist nowhere else.
- Code completionSupported
- ChatSupported
- Agent modeSupported
- Custom instructionsSupported
- MCPSupported
- Copilot code reviewSupported
Key takeaways
- Chat variables (
#file,#selection) and chat participants (@terminal,@vscode) are VS Code-only, and they are the fastest way to control context precisely. - Edit mode is the gear most people skip: scoped multi-file edits without handing over the agent loop.
- Prompt files, custom agents and agent skills are all fully supported here — the customisation layer is only complete in this editor.
- Inline chat (
Ctrl/Cmd+i) beats the chat panel for focused edits and is badly underused. - Repository custom instructions remain the highest-return configuration, exactly as in Cluster 1.
Why VS Code holds this position
It is not favouritism so much as architecture. VS Code’s extension API exposes inline completion, chat participants, terminal access, task execution and workspace search — and much of that surface was shaped alongside Copilot’s needs. When GitHub builds a new capability, VS Code is where it can be built first without waiting on somebody else’s API.
The practical effect is that VS Code is the only editor where you never have to ask whether a Copilot feature exists. It does.
Prerequisites
You need VS Code and a Copilot plan — Copilot Free is enough to follow everything here except where noted. Installation is covered separately in How to Install GitHub Copilot in VS Code, including authentication and a troubleshooting table; this lesson assumes it is already working.
Code completion
Inline suggestions appear as ghost text ahead of your cursor.
Two things worth doing that most people do not.
Bind the toggle. github.copilot.toggleCopilot ships with no keybinding.
Being able to silence ghost text while you think is genuinely useful, and it
takes thirty seconds in the Keyboard Shortcuts editor.
Use the separate pane for real choices. Ctrl+Enter opens several
candidates side by side. When the first suggestion took a structurally different
approach from the one you wanted — iterative where you wanted recursive, broad
exception handling where you wanted narrow — comparing beats cycling blind.
Next edit suggestions are supported here too: rather than only completing at the cursor, Copilot proposes where your next edit probably belongs. Rename a parameter and it will often offer the downstream changes.
One behaviour worth calling out because it differs elsewhere: in VS Code, Tab
accepts the entire suggestion, however many lines it spans. That sounds
unremarkable until you move to Xcode, where Tab accepts only the first line and
Option+Tab accepts the rest. Developers who work in both regularly lose a few
minutes to this before the difference clicks.
Code Completion Explained covers the underlying behaviour; this is the VS Code-specific surface.
Copilot Chat
Three ways in, and they are not interchangeable:
| Surface | Shortcut | Best for |
|---|---|---|
| Chat view | Chat icon in the title bar | Discussion, planning, explanation |
| Inline chat | Cmd/Ctrl+i | A focused edit to the code under your cursor |
| Quick chat | Shift+Opt+Cmd+L / Ctrl+Shift+Alt+L | A one-off question without leaving your file |
Chat variables: VS Code’s real advantage
Typing # pulls specific context into a prompt. This exists only in VS Code, and
it is the single biggest practical difference between chat here and chat
elsewhere.
| Variable | Includes |
|---|---|
#file | The current file’s contents |
#selection | The current selection |
#project | Project context |
#function | The enclosing function or method |
#class | The enclosing class |
#block | The enclosing block |
#line | The current line |
#path | The file path |
#sym | The current symbol |
#comment | The current comment |
The reason this matters: everywhere else, you hope the right thing is focused. Here you say so.
Explain how #class relates to #sym, and whether the relationship is a dependency or just a naming coincidence.
Chat participants
Typing @ scopes a question to a domain. Also VS Code-only.
| Participant | Domain |
|---|---|
@github | GitHub-specific Copilot skills |
@terminal | The integrated terminal and its contents |
@vscode | VS Code commands, settings and features |
@azure | Azure services (public preview) |
@terminal Why did the last command fail, and what should I run instead? Tell me what the fix changes before I run it.
@terminal already has the shell context, so you skip the copy-paste step
entirely. @vscode is the fastest way to find a setting whose name you cannot
remember.
Slash commands
/clear, /explain, /fix, /fixTestFailure, /help, /new, /tests.
/new and /fixTestFailure are VS Code-only. Note that Visual Studio’s /doc
and /optimize are not available here — the sets genuinely differ, and
the pillar has the full cross-editor table.
Edit mode
The feature most VS Code users never try, and the one that changes the workflow most.
Chat suggests and you apply. Agent mode decides what to change and does it. Edit mode sits between: you nominate the files, describe the change, and Copilot edits across them — without the autonomous loop, tool calls or terminal approvals.
Use it when you know exactly which files are involved and do not want an agent exploring. Renaming a concept across four known files is an edit-mode task. Adding a feature that might touch anything is an agent-mode task.
Agent mode
Copilot plans, edits across files, runs commands with your approval, reads the output and iterates. It is covered properly in GitHub Copilot Agent Mode in VS Code — including a REST API built end to end — so this is the summary.
VS Code supports the whole supporting cast: checkpoints to roll a session back, custom agents, agent skills, and MCP for external tools. That combination is what makes agent mode meaningfully more capable here than in editors that have the mode but not the scaffolding.
Practical examples
Three situations where the VS Code-specific surface earns its keep.
Understanding a file you inherited
The instinct is to open chat and type “explain this file”. The better version names the scope and asks for failure modes rather than a summary:
Explain what #file is responsible for, which functions have side effects, and what a caller has to know before using it. Highlight anything that would surprise someone reading it for the first time.
Using #file rather than relying on focus matters more than it appears. If you
have three editor tabs open and the chat panel focused, “this file” is ambiguous
— and the answer will be confidently about the wrong one.
Refactoring a function without collateral damage
Select the function, then use inline chat rather than the panel:
Extract the validation from #selection into a separate function. Keep the public signature, the exception types and the log messages exactly as they are. Do not touch anything outside this function.
The last sentence is doing real work. Models default to helpfulness, which shows up as renaming things you did not ask about and “improving” exception types. Naming the fixed points is what keeps a refactor a refactor.
Working out why a command failed
@terminal The last command failed. Explain the cause, and tell me whether the fix belongs in my shell configuration or in the project.
That final clause turns an answer into a decision. “Your PATH is wrong” and “the project’s script assumes a tool you have not installed” lead to different actions, and the model can usually tell which it is looking at.
Custom agents and agent skills
Both are fully supported in VS Code, and both are worth understanding as the same idea at different scales.
A custom agent is a named configuration — its own instructions, its own tool permissions, its own MCP servers. The use case is a task you perform repeatedly with a consistent shape and a consistent set of boundaries. A “migrations” agent that may read the schema and run the migration tool but may not touch application code is a genuinely different thing from general agent mode, and safer.
An agent skill is a folder of instructions and supporting resources teaching an agent to do one specific job well. Where a custom agent defines who is working, a skill defines how a particular job is done.
Neither is a day-one feature. The honest guidance is to use plain agent mode until you notice yourself writing the same three paragraphs of preamble into every task — that repetition is the signal that the preamble belongs in a skill or an agent definition instead.
Settings worth changing
VS Code ships sensible Copilot defaults, but four settings are worth a look on day one.
Per-language completion. Copilot can be enabled or disabled by language. Turning it off for Markdown or plain text is a common preference — ghost text while writing prose is more distraction than help, and it costs completions on Copilot Free.
The toggle keybinding. Already mentioned, still the highest-value thirty seconds available.
Inline suggestion behaviour. How eagerly ghost text appears is configurable. If you find yourself dismissing more than accepting, a less eager setting reduces the noise without giving up the feature.
Which files Copilot can see. On Business and Enterprise plans, content exclusion is configured centrally rather than per-editor — but it is worth knowing it exists, because it is the answer when someone asks whether a particular directory is being sent.
Custom instructions
Path-specific instructions are worth more than they look. A single repository often has genuinely different conventions per area:
.github/ ├── copilot-instructions.md # applies everywhere └── instructions/ ├── api.instructions.md # scoped to the API layer └── migrations.instructions.md # scoped to database migrations
---
applyTo: "app/api/**"
---
HTTP handlers must not contain business logic — delegate to app/services/.
Every endpoint validates input with Pydantic and returns the error shape in
app/errors.py. Never return a bare dict.Prompt files
Reusable prompt templates stored in the workspace and invoked by name. Fully supported in VS Code; preview or absent everywhere else.
They are worth setting up for anything you ask repeatedly with the same shape — a review checklist, a test-generation prompt encoding your conventions, a release-note generator. The value is not saving typing; it is that the whole team asks the question the same way.
MCP
Model Context Protocol servers give Copilot access to tools it does not have built in — an issue tracker, a database, an internal service. Supported in VS Code, and configured per workspace.
Workspace context and indexing
VS Code supports workspace indexing, so Copilot can find relevant code you have
not opened. That is what makes #project and agent-mode exploration work.
It does not make context management unnecessary. The ordering that actually governs quality:
- What you explicitly attach —
#file,#selection, an attachment - What is open in the editor
- What the workspace index surfaces
- Your custom instructions
Explicit beats inferred, every time. When an answer is wrong, the first question is not “which model” but “could it see the thing it needed”.
Model selection
Pick a model in the chat interface, or leave it on auto. Which models you can reach is a plan feature — identical in every editor — and covered in the plans comparison.
BYOK is in preview in VS Code. If bringing your own model key is a requirement rather than an experiment, Visual Studio has it fully supported today.
Copilot code review
Request a review of your changes and get comments back in the editor. Supported in VS Code.
The habit worth building: run it on your own work before requesting human review. It clears the mechanical findings — an unhandled error path, an inconsistent null check — so a colleague’s attention goes to design instead. It is a first pass, not a review.
A practical VS Code workflow
Putting the pieces in the order you would actually use them:
- Orient. Chat view:
/explainor a#filequestion about code you did not write. - Plan. Describe the change and ask what it would touch, before writing anything.
- Implement small edits inline.
Cmd/Ctrl+ifor the function in front of you. - Implement known multi-file edits in edit mode. You name the files.
- Delegate open-ended work to agent mode. With a scoped task and a test command.
- Test. Run the suite yourself, not just the agent’s claim about it.
- Review. Copilot code review, then read the diff properly.
Steps 6 and 7 do not get delegated in any editor.
Security in VS Code specifically
The plan-level controls are identical everywhere and covered in Cluster 1. Three things are specific to working in this editor.
One habit worth more than any setting: never paste a real credential into chat, not even to check a format. Use a placeholder.
export EXAMPLE_TOKEN="replace-with-your-token"Extensions that interact with Copilot
VS Code’s extension ecosystem is its defining feature, and a handful of common extensions change how Copilot behaves in ways that are easy to misattribute.
Other completion providers. Language servers, snippet extensions and rival AI
assistants all compete for the same inline suggestion slot. When suggestions stop
appearing, or Tab starts doing something unexpected, a second provider is the
usual cause. Disable them one at a time rather than reinstalling Copilot.
Formatters on save. Prettier, Black, gofmt and friends run after you accept a suggestion, which is fine — but if a formatter and Copilot disagree about style, you will see accepted code change shape immediately and conclude something is broken. It is working correctly; the formatter has the last word, as it should.
Linters as a review pass. ESLint, Ruff, golangci-lint and the rest catch a useful slice of what generated code gets wrong: unused variables, shadowed names, unreachable branches, unsafe patterns. Configure them properly and they become the automatic first review of everything Copilot produces, which is a much better use of them than treating them as style enforcement.
Test runners. Extensions that run tests inline shorten the loop between generating a test and finding out whether it means anything, which matters because the test worth catching is the one that passes against broken code.
Notebooks and non-code files
Copilot works beyond source files in VS Code, with characteristics worth knowing.
Jupyter notebooks. Completion and chat both work in cells. The caveat is that notebook behaviour depends on kernel state — what ran, and in what order — and Copilot sees the code, not the state. A suggestion referencing a variable can be correct in the notebook you intended and wrong in the kernel you have.
Markdown and documentation. Copilot is genuinely useful for structure and completeness — filling out a table, drafting a section outline, listing what a README is missing. It is much less useful for factual claims about your project, because it will produce plausible statements you then have to verify individually.
Configuration files. YAML, JSON and TOML get good structural suggestions, because the schemas are widely represented. Values are a different matter: a suggested version number, image tag or resource limit is a guess dressed as a recommendation, and configuration errors tend to surface in production rather than at edit time.
Common problems
| Symptom | Likely cause | Fix |
|---|---|---|
| No ghost text in one file type | Completions disabled for that language | Check per-language settings |
| Chat ignores project conventions | No instructions file, or wrong applyTo | Add .github/copilot-instructions.md; check path scoping |
#project returns little | Index still building on a large workspace | Give it time; attach files explicitly meanwhile |
| A documented feature is missing | Extension or VS Code version behind | Update both; the matrix tracks the latest |
| Agent mode never asks to run tests | No test command it can infer | State the command in the task or in instructions |
| Suggestions stopped mid-session | Rate limiting or exhausted AI credits | Check usage before reinstalling anything |
The installation lesson has the fuller table, including authentication and policy problems.
Best practices specific to VS Code
- Use chat variables instead of hoping.
#selectioncosts three keystrokes and removes an entire class of wrong answers. - Reach for inline chat first. The panel is for discussion; inline is for edits.
- Learn edit mode. It is the gear between chat and agent mode, and it exists here.
- Put conventions in instruction files, scoped with
applyTowhere a directory genuinely differs. - Start a fresh chat per problem. Long sessions carry stale premises into new answers.
- Bind the Copilot toggle. Being able to switch off ghost text is worth the thirty seconds.
Everything in Best Practices for Beginners still applies — this list is what VS Code adds on top.
Frequently asked questions
Do I need both the Copilot and Copilot Chat extensions? VS Code installs what it needs on first use, so in practice you do not manage this yourself. If chat is missing while completions work, the installation lesson covers the checks.
Why does chat sometimes ignore my instructions file?
Two usual causes. Either the file is not where Copilot looks —
.github/copilot-instructions.md at the repository root — or a path-specific
file’s applyTo pattern does not match the file you are editing. Broadening the
pattern is the quickest way to confirm which.
What is the difference between edit mode and agent mode? You choose the files in edit mode; Copilot chooses them in agent mode. Edit mode does not run commands or call tools, which makes it faster and more predictable when you already know the scope.
Are chat variables available in other editors?
No. #file and the rest are VS Code-only. Visual Studio uses file references
like #MyFile.cs and #solution instead, and the other editors have neither.
Does Copilot read files I have not opened? In VS Code, yes — workspace indexing is supported, which is what lets it find relevant code you did not attach. Explicitly attached context still carries more weight than indexed context.
Which model should I pick in VS Code? The default, until a task gives you a reason otherwise. Model choice matters far less than whether Copilot can see the right code, and it consumes AI credits at different rates.
Is Copilot Free enough to use VS Code properly? For everything in this lesson except the cloud agent, yes. The constraint you will meet first is the 2,000 monthly completion cap rather than any missing editor feature — every VS Code capability described here is available on the free tier.
Next steps
If Copilot is not yet installed or something is not working, go to How to Install GitHub Copilot in VS Code.
If it is working and you want the capability that changes how you work most, go to GitHub Copilot Agent Mode in VS Code.
For how VS Code compares with the editors you might otherwise use, see GitHub Copilot for IDEs. If you move between editors, Visual Studio and JetBrains IDEs are the two whose differences from VS Code catch people out most often.
Sources
Every version-sensitive claim on this page was checked against first-party documentation. Only sources actually used are listed.
Your progress
Saved in this browser only. No account, no server, and nothing leaves your device. Clearing site data resets it.
Was this lesson helpful?
Your answer is stored in this browser and is not sent anywhere.