Sub topic 6
Ask questions in the Chat view
This chapter covers the Copilot Chat view in Visual Studio Code. It explains how to open it, how a request becomes an answer, and what to do when answers are poor. It assumes you have already installed the Copilot extension and signed in with GitHub. It also assumes you can use the Command Palette and the Extensions view. Modes, inline chat, and custom instructions each get their own chapter, so this one stays on the Chat view itself.
What the Chat view is
The Chat view is a conversation panel inside VS Code. You type a request in natural language, and Copilot replies with text, code blocks, and links to files. Unlike inline suggestions, which appear as you type, chat is request and response. You decide when to ask, and you can ask follow-up questions that build on earlier answers.
Typical uses:
- Explaining unfamiliar code or an error message.
- Asking how a language feature or library works.
- Generating a snippet, such as a regular expression or a SQL query.
- Planning a change before you make it.
Chat can produce wrong answers with confidence. Treat every reply as a draft that you read and check, especially code that touches data, security, or deployment.
Open the Chat view
You can open the view in several ways:
- Select the Copilot icon in the title bar and choose to open Chat.
- Run Chat: Open Chat from the Command Palette.
- Use the keyboard shortcut. The default is
Ctrl+Alt+Ion Windows and Linux, andCtrl+Cmd+Ion macOS.
By default the view opens in the Secondary Side Bar on the right. That placement lets you keep the Explorer on the left, the editor in the middle, and the conversation on the right. You can drag the view to another location, or open a chat in the editor area or a separate window if you want more room.
Menu names and default shortcuts change between VS Code releases. If a shortcut does nothing, search the Command Palette for "Chat" and check Keyboard Shortcuts for the current binding.
Anatomy of the Chat view
The view has a few parts you will use constantly.
| Part | What it does |
|---|---|
| Conversation area | Shows your requests and Copilot's replies in order |
| Input box | Where you type a request and press Enter to send it |
| Mode picker | Selects Ask, Edit, or Agent (covered in a later chapter) |
| Model picker | Selects which language model answers, if your plan offers a choice |
| Attach button | Adds files, selections, and other context to a request |
| New Chat button | Starts a fresh conversation with no earlier history |
For this chapter, set the mode to Ask. Ask mode answers questions and shows suggested code, but it does not change your files on its own.
How a request becomes an answer
Understanding the flow helps you write better requests and explains several common errors.
Three points follow from this flow:
- The model never sees your whole project by default. The extension adds only some context, such as the active file, your selection, and anything you attach. If the answer ignores a file, the file probably was not in the prompt.
- Conversation history travels with each request. Follow-ups work because earlier turns are included. Long conversations use more of the model's limited context window, and older details can be dropped or ignored.
- The request goes over the network to a service. If you are offline or a proxy blocks the connection, chat fails even though the extension is installed. The troubleshooting chapter covers this.
Your first questions
Open a project folder and a source file. Select a function in the editor, then ask a question about it. A selection is automatically used as context, so you can refer to it loosely.
What does this function do, and what happens if the input is empty?Good first requests share a few traits. They name a specific task, mention the language or framework when it matters, and say what form of answer you want. Compare these:
| Weak request | Stronger request |
|---|---|
| `fix this` | `This function throws a KeyError when "id" is missing. Explain why and show a fix that returns None instead.` |
| `write tests` | `Write pytest tests for parse_date covering valid dates, an empty string, and an invalid month.` |
| `explain the code` | `Explain this function in three short bullets for someone new to the project.` |
You can also ask general programming questions that do not involve your files, such as how a Git rebase differs from a merge. Chat is scoped to software development topics, so unrelated questions may be declined.
Work with code in replies
Code in a reply appears in a block with controls along its top edge. The exact set varies by version, but you will usually see these actions:
- Copy places the code on your clipboard.
- Insert at Cursor pastes the code where your cursor sits in the active editor.
- Insert into New File creates a new file from the block.
- Run in Terminal, shown for shell commands, sends the command to the integrated terminal.
Read a command before you run it. A suggested rm, git reset --hard, or database command can destroy data, and Copilot does not know your environment. Run in Terminal puts the command in the terminal for you, but you still choose whether to execute it.
In Ask mode, nothing is written to your files until you insert code yourself. That makes Ask the safest mode for learning and exploration.
Slash commands and participants
The input box accepts a few shortcuts that make requests shorter and more predictable.
- Slash commands start with
/and run a common task. Examples include/explain,/fix,/tests, and/doc. Type/in the input box to see the list available in your version. - Chat participants start with
@and direct a question to a specialist. For example,@workspaceasks about your project as a whole, and@vscodeasks about editor features and settings. - Chat variables start with
#and attach specific context. The next chapter covers these in detail, but one example is useful now.
Explain what #file:utils.ts does and suggest one way to simplify it.The #file:utils.ts reference attaches that file's contents to the request, so the answer is based on the real code and not a guess from the file name. The available participants and commands depend on your VS Code and extension versions, and your administrator may restrict some of them.
Manage conversations
Each chat is a separate conversation with its own history. A few habits keep answers focused:
- Start a new chat for a new task. Click New Chat when you switch topics. Leftover history from an unrelated task can pull the answer in the wrong direction.
- Refine instead of repeating. If an answer is close, reply with a correction such as "Use async/await instead of callbacks." The model keeps the earlier turn in view.
- Edit an earlier request. You can usually edit a previous message and resend it, which replaces the later turns. This is cleaner than piling on corrections.
- Reopen past chats. Use the chat history control in the view to return to earlier conversations.
If the conversation becomes long and answers drift, that is a sign to start over and paste in only the essential context.
Common problems and fixes
| Symptom | Likely cause | What to try |
|---|---|---|
| Chat view is missing or the icon is absent | Extension not installed, disabled, or VS Code is out of date | Check the Extensions view and update VS Code |
| "Sign in to use Copilot" appears | No active GitHub session in VS Code | Use the Accounts menu to sign in again |
| Reply stops partway or shows a network error | Connection or proxy interruption | Retry, then check network settings |
| Answer ignores your code | The file was not in the prompt | Select the code or attach the file with `#file` |
| Answer is generic or outdated | Question too vague, or model limits | Add details, name the version, and start a new chat |
| A model you expect is not listed | Your plan or organization policy does not include it | Check your plan and organization settings |
| Request is refused for a file | Content exclusion applies to that file | Ask your administrator about exclusion rules |
When an answer is wrong, do not argue with the model for many turns. Quote the exact error or wrong line, say what you expected, and ask for a revision. If that fails twice, start a new chat with a clearer description.
Privacy and what you send
Chat sends your request, the conversation history, and the attached context to the Copilot service. That can include code from open files and selections. Do not paste secrets such as API keys, passwords, or customer data into a chat. Privacy settings and content exclusion, which control what Copilot may process, are covered in a later chapter.
Exercise
You select a function in the editor and ask "why does this crash?" The reply talks about a different function in another file. Give two likely reasons and one fix for each.
Show answer
First, the model only received the selection and the active file, so it never saw the code that actually causes the crash. Fix: attach the other file with a reference such as #file:name.ext. Second, earlier turns in a long conversation steered the answer toward an unrelated topic. Fix: click New Chat and restate the problem with the exact error message and the relevant code.
Exercise
Why is Ask mode a sensible choice when you are exploring an unfamiliar codebase, and what must you still do before running a shell command from a reply?
Show answer
Ask mode answers questions and shows code but does not edit your files, so exploring cannot change the project by accident. Before running a shell command, read it and confirm you understand what it does and what it affects, because Copilot does not know your environment and a command can delete or overwrite data.