Saltar para o conteúdo

Este guia ainda não está disponível em português, por isso mostramos a versão original em inglês.

Microsoft

How to Set Up and Use GitHub Copilot in VS Code

GitHub Copilot is an AI coding assistant built into Visual Studio Code. Install VS Code, select the Copilot icon in the Status Bar, choose Use AI Features and sign in with GitHub; without a subscription you get the free Copilot Free plan. Copilot then suggests code as you type (press Tab to accept), answers questions in the Chat view, and can make multi-file changes that you review before keeping.

Updated
Time
15 minutes
Difficulty
Medium
Applies to
Windows, Mac, Linux

By Published Oct 8, 2026

Quick answer

  1. 1 Install Visual Studio Code from code.visualstudio.com.
  2. 2 Select the Copilot icon in the Status Bar and choose Use AI Features.
  3. 3 Sign in with your GitHub account (Copilot Free is applied if you have no plan).
  4. 4 Type code or a comment; press Tab to accept a grey suggestion, Esc to dismiss.
  5. 5 Open the Chat view (Ctrl+Alt+I, or Ctrl+Cmd+I on Mac) to ask questions or request changes.
  6. 6 Review every change Copilot makes, then Keep or Undo it.
On this page
  1. Before you start
  2. Install VS Code and sign in to Copilot
  3. Use inline suggestions as you type
  4. Ask questions and make changes in Chat
  5. Use inline chat for quick edits
  6. Troubleshooting
  7. Frequently asked questions

Before you start

  • Visual Studio Code (Windows, Mac or Linux)
  • A free GitHub account
  • An internet connection

Method 1 Install VS Code and sign in to Copilot

Students, teachers and maintainers of popular open-source projects may qualify for free Copilot Pro through GitHub Education or GitHub’s open-source programme.

  1. Step 1: Install Visual Studio Code

    Download VS Code from code.visualstudio.com and install it. If you already have it, update to the latest version (Help > Check for Updates on Windows and Linux, Code > Check for Updates on Mac).

  2. Step 2: Create a GitHub account

    If you don’t have one, sign up for free at github.com. Turn on two-factor authentication to protect your code.

  3. Step 3: Turn on AI features

    In VS Code, hover over the Copilot icon in the Status Bar (bottom of the window) and select Use AI Features.

  4. Step 4: Sign in

    Choose to sign in with GitHub, approve the request in your browser, and return to VS Code. If you don’t already have a Copilot subscription, you’re signed up to Copilot Free, which includes a monthly allowance of suggestions and chat.

Method 2 Use inline suggestions as you type

  1. Step 1: Start typing

    Open a code file and start writing a function, or type a descriptive comment such as // function that validates an email address. Copilot shows a suggestion in grey text.

  2. Step 2: Accept or dismiss

    Press Tab to accept the whole suggestion, Esc to dismiss it, or Ctrl+Right Arrow (Cmd+Right Arrow on Mac) to accept it one word at a time.

  3. Step 3: See other options

    Hover over the suggestion to switch between alternatives when Copilot offers more than one.

  4. Step 4: Follow next edit suggestions

    After you change something, Copilot may suggest a related edit elsewhere in the file, such as renaming a variable everywhere. Press Tab to jump to it and Tab again to accept.

Method 3 Ask questions and make changes in Chat

  1. Step 1: Open the Chat view

    Press Ctrl+Alt+I (Ctrl+Cmd+I on Mac) or select the chat icon at the top of the window.

  2. Step 2: Ask about your code

    Ask things like “Explain what this file does”, “Why does this function return undefined?” or “What’s the best way to read a CSV file in Python?” Add context by typing # to reference a file or selection, or drag files into the chat.

  3. Step 3: Let the agent make changes

    Ask for a task such as “Add input validation to the signup form and write tests for it.” In Agent mode, Copilot plans the work, edits several files and can run terminal commands, asking your permission first.

  4. Step 4: Plan bigger tasks

    For larger features, choose Plan (where available) or ask the agent to propose an approach before editing, then approve the plan.

  5. Step 5: Review and keep

    Changed files are highlighted. Review the differences, then select Keep or Undo for each change.

Method 4 Use inline chat for quick edits

  1. Step 1: Select some code

    Highlight a function or block in the editor.

  2. Step 2: Open inline chat

    Press Ctrl+I (Cmd+I on Mac) and type an instruction, such as “Convert this to async/await” or “Add comments explaining each step.”

  3. Step 3: Accept or discard

    Copilot shows the change in place. Accept it, or discard it and try a clearer instruction.

Handy Copilot requests
Goal Try asking
Understand code Explain this function line by line for a beginner
Fix an error Here’s the error from the terminal. Find the cause and fix it
Write tests Write unit tests for this file covering edge cases
Improve code Refactor this to be more readable without changing its behaviour
Documentation Write a README section explaining how to install and run this project
Commit message Generate a commit message for my staged changes (sparkle icon in Source Control)

Troubleshooting

No suggestions appear

Check the Copilot icon in the Status Bar: make sure you’re signed in and suggestions aren’t disabled for this language. Check you haven’t used up your Copilot Free allowance for the month.

Sign-in doesn’t complete

Allow VS Code to open the browser link, make sure you’re signed in to the right GitHub account, then return to VS Code. Behind a company proxy or firewall, ask IT to allow GitHub Copilot.

“You’ve reached your monthly limit”

Copilot Free has monthly limits. Wait for the reset date, or upgrade to a paid plan in your GitHub settings.

Copilot keeps suggesting the wrong thing

Write a clearer comment describing what you want, open related files so it has more context, or ask in Chat with specific files referenced using #.

Frequently asked questions

Is GitHub Copilot free?

Yes, Copilot Free gives individual developers a monthly allowance of code suggestions and chat at no cost. Paid plans offer more usage and extra models.

Which languages does Copilot support?

It works with almost every popular language, including Python, JavaScript, TypeScript, Java, C#, C++, Go, PHP and Ruby, plus HTML, CSS and SQL.

Does Copilot use my code to train models?

You can control how GitHub uses your data in your Copilot settings on github.com. Business and Enterprise plans don’t use customers’ code for training.

Can beginners use Copilot to learn programming?

Yes, especially for explanations. But try to write code yourself first and use Copilot to check and explain it; accepting every suggestion without understanding it slows your learning.

Summary

Install VS Code, select the Copilot icon, choose Use AI Features and sign in with GitHub to get Copilot Free. Press Tab to accept inline suggestions, use the Chat view or Ctrl+I to ask questions and request changes, and let the agent handle larger tasks. Review every change, test it, and keep secrets out of your prompts.

Written by

James Chambo

Founder

James is the Founder and Senior Editor of OnlineHow with more than 20 years of experience in internet publishing.