Sub topic 1
What Copilot does in VS Code
GitHub Copilot is an AI coding assistant that runs inside Visual Studio Code through an extension. This chapter explains what it does, how a request moves from your editor to a result, and which mistakes cause the most confusion early on. Later chapters cover installation, sign-in, and configuration in detail.
Prerequisites
This chapter assumes you already have the following:
- Basic use of Visual Studio Code: opening folders, using the Extensions view, and running commands from the Command Palette.
- A GitHub account. You don't need a Copilot plan yet, because the plans chapter covers access.
- Familiarity with editing code in at least one programming language.
You don't need to install anything to follow this chapter. The examples show what you will see once Copilot is set up.
The working model
Copilot is not a single feature. It is a set of features that share one extension, one GitHub sign-in, and one backend service. Keeping that in mind explains most of its behavior.
- You work in the editor or in a chat panel.
- The extension collects context. This can be the text around your cursor, open files, a file you attach, or your project instructions.
- The extension sends that context to a Copilot service hosted by GitHub, together with your request.
- A language model generates a response, and the service returns it.
- The extension shows the result as a suggestion, a chat answer, or a proposed edit.
Because the model runs remotely, Copilot needs a network connection and a signed-in account that has access. Most "Copilot does nothing" problems come from a break at the first or last step of this chain: no account access, a blocked network, or a feature turned off for the current file type.
What Copilot does
The extension offers four main ways to work. They differ in how much you control and how much the tool does on its own.
Inline suggestions
Inline suggestions appear as faded "ghost text" while you type. Copilot predicts what comes next, from a single line to a whole function. You accept the suggestion with Tab or ignore it by continuing to type. It is the lowest-friction feature, because you don't have to leave the editor or write a prompt.
A descriptive comment plus a function signature is a reliable trigger:
# Return the n-th Fibonacci number using iteration
def fibonacci(n):
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
return a
print(fibonacci(10)) # 55You type the first two lines. Copilot proposes the body, and the exact text varies from run to run. Read it before accepting, because a plausible-looking body can still be wrong for edge cases such as negative n.
The Chat view
The Chat view is a conversation panel, usually in a side bar. You ask questions in plain language, such as "why does this test fail?" or "explain this regular expression." Chat can see the file you have open and the code you have selected. You can also point it at specific material, which is covered in the context section below.
Inline chat
Inline chat opens a small prompt directly in the editor, next to the code you selected. It suits a focused change, such as "convert this loop to a list comprehension." The result appears as a diff in place, and you accept or discard it. You never leave the file.
Ask, Edit, and Agent modes
Chat has three modes that change how much it acts on your behalf:
| Mode | What it does | Typical use |
|---|---|---|
| Ask | Answers questions and shows code. It does not change your files. | Learning a codebase, debugging ideas |
| Edit | Proposes changes to files you choose. You review each one. | A known change across a few files |
| Agent | Plans steps, edits files, and can run tools or terminal commands with your approval. | Larger tasks, such as adding a feature with tests |
The more autonomy a mode has, the more you should check its output. Start with Ask when you are unsure what you want.
What Copilot sees
Quality depends heavily on context. Copilot cannot read your whole machine. It works from what the extension gives it.
- Inline suggestions mostly use the current file, especially the code before and after your cursor, and may draw on other open files.
- Chat uses the active file or selection, plus anything you attach.
- Custom instructions add standing rules for a repository.
You can attach a specific file in chat with the #file reference:
Explain what #file:utils.ts does and suggest one way to simplify it.For project-wide conventions, you can save a file at .github/copilot-instructions.md. Copilot Chat then follows those rules without you repeating them in every prompt:
# Copilot instructions
- Use TypeScript with strict typing; avoid `any`.
- Write unit tests with Vitest.
- Prefer named exports over default exports.Both topics get their own chapters. For now, remember that vague prompts get vague answers. Naming a file, selecting the relevant lines, or stating a convention narrows what the model has to guess.
Where you control it
Copilot is active by default in most languages once it is working, but you can narrow that. The github.copilot.enable setting in settings.json switches inline suggestions on or off per language:
{
"github.copilot.enable": {
"*": true,
"plaintext": false,
"markdown": false
}
}This keeps suggestions on everywhere except plain text and Markdown files. The * key is the default for any language you don't list.
Privacy also has controls. Plans differ in what they let you set, such as whether your prompts and suggestions may be used to improve the product, and organizations can exclude certain files from Copilot entirely. The privacy chapter covers these in depth.
Strengths and limits
Copilot works well for:
- Boilerplate and repeated patterns, such as data classes, test scaffolding, and format conversions.
- Explaining unfamiliar code, since Ask mode can summarize a function or a stack trace.
- First drafts of small, well-described functions.
- Looking up syntax or library usage without leaving the editor.
It works poorly or needs close review for:
- Logic that depends on business rules the model has not seen.
- Security-sensitive code, such as authentication, input validation, and cryptography.
- Recent library versions. The model may suggest an API that has changed or no longer exists.
- Large changes made in one step, where a small mistake can spread across many files.
Common early errors
These problems account for most first-day confusion:
- No suggestions appear. Check that you are signed in, that your account has Copilot access, and that the language is not disabled in
github.copilot.enable. The status icon in the status bar often shows which of these applies. - Chat answers ignore your project. You probably did not give it context. Select the relevant code, attach the file with
#file, or add repository instructions. - Accepting a suggestion that doesn't compile. Inline suggestions are guesses based on nearby text. Treat them like code from an unknown contributor.
- Using Agent mode for a simple question. Ask mode is faster and cannot change your files, so it is safer for exploration.
- Expecting identical output each time. The model is not deterministic. The same prompt can yield different code on different runs.
Where this fits in the tutorial
The remaining chapters follow the order you would use to get started. You check your plan and access, install the extension, sign in, and try inline suggestions. Then you move to chat, modes, context, custom instructions, per-language settings, privacy, and troubleshooting. Each later chapter builds on the account and extension from the earlier ones, so a failure in the early steps will block everything after it.
Exercise
You open a Markdown file in VS Code, and Copilot shows no inline suggestions. Suggestions work fine in your Python files, and you are signed in. Name the most likely cause and where you would check it.
Show answer
The github.copilot.enable setting probably has "markdown": false, which turns off inline suggestions for Markdown while leaving other languages on. Open settings.json (user or workspace) and look at that setting. Also check whether a workspace setting or organization policy overrides your user setting.
Exercise
You want Copilot to explain a function and suggest improvements, but you don't want any of your files changed. Which chat mode should you use, and how can you make sure it looks at the right file?
Show answer
Use Ask mode, because it answers questions and shows code without editing your files. Attach the file with a reference such as #file:utils.ts in your prompt, or select the function in the editor before asking, so the answer is based on that code.