Getting Started with GitHub Copilot in Visual Studio Code

Getting Started with GitHub Copilot in Visual Studio Code

đź”– Prerequisites

  1. Visual Studio Code installed (version ≥1.70)
  2. GitHub account (free tier works; subscription required after trial)
  3. Basic familiarity with the VS Code interface (panels, Command Palette)

1. Install the GitHub Copilot Extension in VS Code

  1. Open VS Code.
  2. Click the Extensions icon (or press Ctrl+Shift+X).
  3. Search for "GitHub Copilot" and select the official extension by GitHub.
  4. Click Install, then Reload when prompted.
VS Code Extensions panel showing GitHub Copilot install
Screenshot of installed GitHub Copilot

2. Authenticate Copilot with Your GitHub Account

  1. In VS Code, open the Command Palette (Ctrl+Shift+P).
  2. Type and select "GitHub Copilot: Sign In".
  3. A browser window will open—log in with your GitHub credentials.
  4. Authorize the Copilot extension to access your account.
  5. Return to VS Code; you should see Copilot: Connected in the status bar.
✏️ Note: A GitHub Copilot subscription is required beyond the free trial.

3. Trigger Your First Copilot Suggestions in VS Code

  1. Open (or create) a code file—e.g., index.js for JavaScript or main.py for Python.
  2. Copilot will display a ghosted suggestion inline. Press Tab to accept it.
  3. Review the generated code and customize as needed.

Start typing a function signature or comment. For example:

// Function to fetch user data from an API and log the names
async function fetchAndLogUsers() {
  
}
✏️ Noob tip: Use comments (// or #) to guide Copilot on what you want it to build.

4. Explore Inline Suggestions & Copilot Chat

  • Inline Suggestions: Continue typing, and Copilot offers completions.
  • Open Copilot Chat: Press Ctrl+Shift+P and select "Copilot: Chat" to ask Copilot questions in natural language.
🚀 Pro tip: Use the chat to get explanations or scaffold larger code blocks.

5. Customize Copilot Settings

  1. Open VS Code Settings (Ctrl+,).
  2. Search for "Copilot".
  3. Adjust options such as:
    • Enable/Disable inline suggestions
    • Suggestion frequency
    • Exclude languages where you don’t want Copilot
🛠️ Tip: You can enable Copilot per workspace or globally.

6. Best Practices

  • Review suggestions carefully—Copilot can propose insecure or inefficient code.
  • Use comments to get more accurate, context-specific suggestions.
  • Combine Copilot with tests: scaffold tests first, then let Copilot implement functions.

Frequently Asked Questions

Q1: Do I need a paid Copilot subscription?
A: You get a 60-day free trial. After that, a paid plan is required to continue using Copilot.

Q2: Which file types does Copilot support in VS Code?
A: Copilot works with most common languages (JavaScript, Python, TypeScript, Go, etc.). Use comments to guide suggestions in less common file types.

Q3: Can I disable Copilot in specific projects?
A: Yes—open the workspace settings and uncheck Copilot: Enable.