How to Use Copilot in VS Code
Using GitHub Copilot in Visual Studio Code allows you to write, debug, and refactor code significantly faster by pairing natural language prompts with contextual artificial intelligence. Whether you are building web applications, writing automation scripts, or learning a new programming language, integrating Copilot directly into your editor delivers real-time line completions, terminal command suggestions, and conversational assistance right where you work.
Getting started requires setting up the official extensions, connecting your active subscription or free-tier account, and understanding the core keyboard commands that control suggestions. This guide walks you through installing Copilot in VS Code, navigating inline code generation, using the interactive chat panel, and adjusting settings to match your daily development workflow.
Prerequisites and Installing the Extension
Before you begin, ensure you have an active GitHub account with access to GitHub Copilot (such as Copilot Individual, Copilot Business, Copilot Enterprise, or an approved GitHub Education plan). You also need the latest version of Visual Studio Code installed on your computer. Copilot works across Windows, macOS, and Linux without requiring separate platform-specific configurations.
To install the necessary components, open Visual Studio Code and follow these steps:
- Click the Extensions icon in the Activity Bar on the left side of the window, or press Ctrl+Shift+X on Windows and Linux (Cmd+Shift+X on macOS).
- In the search box at the top of the Extensions pane, type
GitHub Copilot. - Locate GitHub Copilot authored by GitHub and click Install. Visual Studio Code will automatically bundle or recommend GitHub Copilot Chat alongside it, which provides conversational code assistance in a dedicated sidebar.
- Wait for the installation status to change from Installing to Installed. If prompted, restart or reload the editor window to ensure the language server registers correctly.
If the extension fails to install, check your corporate proxy or network firewall. Some institutional networks block connections to the Visual Studio Marketplace or GitHub API domains, requiring you to configure VS Code proxy settings under Settings > Application > Proxy.
Authenticating Your GitHub Account
Once the extension is installed, you must link your GitHub account so VS Code can verify your subscription and load your personalized model preferences. If you skip this step, the Copilot status indicator will display a crossed-out icon or remain idle in your status bar.
To complete the sign-in procedure:
- Look at the bottom-right status bar of Visual Studio Code. You should see a small Copilot icon (a miniature robotic head). If you are not signed in, click the icon or wait for the prompt in the bottom-right corner reading Sign in to GitHub to use Copilot.
- Click Sign in to GitHub. Your default web browser will open an authentication screen on github.com.
- Enter your GitHub credentials and two-factor authentication code if prompted. Click Authorize Visual Studio Code to grant the required permissions.
- The browser will ask permission to redirect back to VS Code. Click Open Visual Studio Code.
- Return to the editor. A pop-up notification will confirm: GitHub Copilot is now active.
If your browser fails to redirect the token back to the desktop application, open the Command Palette using Ctrl+Shift+P (or Cmd+Shift+P), type GitHub Copilot: Sign In, and choose the option to paste an authorization device code manually.
Using Inline Code Suggestions
Inline completion is the foundational way to work with Copilot in VS Code. As you type code, comments, or function names, Copilot predicts the remainder of the line or an entire block, displaying it in faded gray text known as ghost text. The suggestion updates dynamically as you continue typing.
Mastering the basic keyboard controls ensures you stay in your coding flow without reaching for your mouse:
- Accept a suggestion: Press Tab to accept the entire suggested snippet.
- Accept word by word: Press Ctrl+Right Arrow (Windows) or Cmd+Right Arrow (macOS) to accept just the next word of the ghost text when you only want part of a solution.
- Cycle alternatives: Press Alt+] (macOS: Option+]) to see the next suggestion, or Alt+[ (Option+[) to view the previous one.
- Reject a suggestion: Press Esc or simply continue typing your own code.
To prompt Copilot deliberately, write a clear descriptive comment before your function. For example, typing // function to validate email addresses and check mx records followed by a line break prompts Copilot to synthesize the complete function body based on your intent.
Working with Copilot Chat and Inline Prompts
Beyond autocomplete, Copilot Chat brings an interactive conversational assistant into your workspace. You can summon Chat in two primary places: the dedicated sidebar panel for broad architectural questions, or the inline chat window directly inside your active file.
To use inline chat directly inside your code, place your cursor at the target position (or highlight an existing block of code) and press Ctrl+I on Windows/Linux or Cmd+I on macOS. A floating input box appears where you can issue direct requests, such as asking it to rewrite an imperative loop into a functional pipeline or add comprehensive error handling. Copilot generates a diff showing added and removed lines, allowing you to click Accept or Discard.
For broader queries, open the chat panel from the left sidebar or press Ctrl+Alt+I (Cmd+Option+I). Copilot Chat supports powerful slash commands and context variables that save time:
| Command or Variable | Purpose | Common Use Case |
|---|---|---|
/explain | Explains selected code in plain English | Understanding complex legacy algorithms or unfamiliar APIs |
/fix | Analyzes errors and suggests repairs | Resolving syntax errors, type mismatches, or runtime exceptions |
/tests | Generates unit tests | Scaffolding test suites using frameworks like Jest, PyTest, or NUnit |
@workspace | Searches your entire project repository | Finding where a specific database model or route handler is defined |
@terminal | Interprets CLI commands and terminal errors | Debugging build failures or syntax issues in shell commands |
Optimizing Performance and Providing Good Context
Copilot relies heavily on context to deliver accurate recommendations. It does not only read the line you are currently working on; it analyzes open editor tabs, preceding and succeeding lines, import statements, and active project files. If Copilot generates hallucinated methods or outdated syntax, the cause is usually insufficient context within your workspace.
To improve output accuracy across your codebase, keep these best practices in mind:
- Keep related tabs open: Keep your interface definitions, schema files, and relevant utility modules open in background tabs. Copilot inspects active editor buffers when synthesizing code.
- Use strong type definitions: In TypeScript, Python (with type hints), Go, or C#, well-defined types give Copilot strict boundaries, significantly reducing errors in generated code.
- Include top-level comments: If you are creating a new file from scratch, add a brief 2-3 line comment at the top explaining the module's role, dependencies, and expected outputs before writing code.
- Reference files directly in chat: In Copilot Chat, type
#file:filename.tsto feed an exact file as context into your query rather than relying on automatic discovery.
If you notice suggestions lagging, check your network latency. Because completions are processed on cloud servers, a high-ping connection or active VPN can introduce noticeable delays between keystrokes.
Configuring Settings, Languages, and Privacy
Visual Studio Code lets you customize exactly when and where Copilot activates. You may want to disable it for sensitive configuration files containing environment variables, or turn off automatic suggestions for specific markup languages while keeping it enabled for scripts.
To access Copilot settings, navigate to File > Preferences > Settings (or press Ctrl+, / Cmd+,) and type copilot in the search bar. Here you can tweak essential options:
- Enable or Disable by Language: Under
github.copilot.enable, you can add or remove specific language IDs. For instance, you can setmarkdown: falseorplaintext: falseif ghost text distracts you during note-taking. - Public Code Matching: In your GitHub account settings under Copilot, you can toggle whether Copilot is allowed to suggest solutions that match publicly available code on GitHub. Disabling this helps comply with strict enterprise licensing rules.
- Status Bar Controls: You can temporarily pause Copilot at any moment by clicking the Copilot icon in the status bar and selecting Disable for Workspace or Disable Globally. Click it again whenever you want to resume assistance.
The bottom line
Integrating Copilot in VS Code transforms everyday development by eliminating repetitive boilerplate, diagnosing stubborn errors, and guiding you through new libraries. By combining inline ghost text completions with conversational commands like /explain and /fix, you maintain momentum while keeping full control over every line committed to your project.
Frequently asked questions
Why is Copilot not offering suggestions in VS Code?
First, verify that the Copilot icon in the bottom-right status bar does not have a slash through it. Ensure you are signed into the correct GitHub account with an active Copilot subscription. Additionally, check that your file type is not disabled under Settings > Extensions > GitHub Copilot > Enable.
Can I use Copilot in VS Code for free?
GitHub offers free Copilot access for verified students, educators, and maintainers of popular open-source projects. For individual developers, GitHub provides free trials, though ongoing access generally requires an Individual, Business, or Enterprise paid plan.
How do I accept just one word of a Copilot completion?
When ghost text appears, press Ctrl+Right Arrow on Windows and Linux, or Cmd+Right Arrow on macOS. This accepts the suggestion word by word rather than inserting the entire snippet at once.
Does GitHub Copilot send my proprietary code to third parties?
Depending on your plan, telemetry and prompt handling differ. Copilot Business and Enterprise tiers do not retain user code snippets for model training. You can adjust telemetry sharing options within your GitHub organization settings and VS Code privacy settings.



