GitHub Copilot — Getting Started
GitHub Copilot is an AI pair programmer built directly into VS Code. In this lesson you will activate Copilot, understand how it works, and start using it for real code completion.
1What is GitHub Copilot?
GitHub Copilot is powered by OpenAI Codex / GPT-4o and trained on billions of lines of code. It generates whole-line and multi-line code suggestions as you type. It's available as a free tier (2,000 completions/month) or Pro ($10/month, unlimited).
2Activating Copilot in VS Code
Open the Extensions view, search for GitHub Copilot, and install it. When prompted, sign in with your GitHub account. You'll see the Copilot icon in the Status Bar when it's active.
✦ Copilot — active and suggesting ✦ Copilot (!) — error or not signed in ✦ ~ — paused for this file
3Using Ghost Text Completions
As you type, Copilot shows grey ghost text suggestions inline. Press Tab to accept, Esc to dismiss. Press Alt+] / Alt+[ to cycle through alternative suggestions. The more context you provide (function names, comments, types), the better the suggestions.
4Writing Better Prompts for Copilot
Copilot reads your entire file as context. You can guide it with comments:
// Parse a JWT token and return the payload as a typed object // Returns null if the token is invalid or expired function parseJwt<T>(token: string): T | null { // Copilot will complete this function...
5Accepting Partial Suggestions
You don't have to accept a whole suggestion. Press Ctrl+Right to accept just the next word of a suggestion. This is especially useful when Copilot gets the right idea but the exact wording needs adjusting.