☕ Buy a Coffee
Home / Productivity & Coding

Set Up 'GitHub Copilot' for Auto-Complete Coding

Supercharge your IDE workflow with inline multi-line code generation, docstring generation, and automated unit test authoring.

Sachin Siju
Sachin Siju
Lead Systems Engineer & Tech Blogger
Jul 19, 2026 4 min read
Set Up 'GitHub Copilot' for Auto-Complete Coding

What GitHub Copilot Actually Does

GitHub Copilot is an AI pair-programmer that runs inline in your editor, suggesting single-line completions, whole functions, and even test files as you type, based on the surrounding code and comments. It's not a chatbot bolted onto your IDE — the core experience is ghost-text autocomplete that you accept with a keystroke, plus a chat panel for more conversational requests. This walkthrough sets it up in VS Code, the most common pairing.

Prerequisites

  • A GitHub account with an active Copilot subscription (Copilot Free gives a limited monthly quota of completions and chat requests; Copilot Pro/Pro+/Business/Enterprise remove or raise those limits).
  • Visual Studio Code, kept up to date.

Installing the Extension

  1. Open VS Code and go to the Extensions view (Ctrl+Shift+X).
  2. Search for GitHub Copilot and install it — this also pulls in the GitHub Copilot Chat extension as a dependency.
  3. Click Sign in to GitHub in the prompt that appears (or in the Accounts icon at the bottom-left of VS Code) and authorize VS Code in the browser window that opens.
  4. If your GitHub account doesn't already have Copilot enabled, VS Code will prompt you to start a free trial or confirm your existing subscription at github.com/settings/copilot.
Tip: If you're on a company GitHub organization account, Copilot access might be centrally managed. Check with your GitHub org admin if the sign-in flow says Copilot isn't enabled for your account — it's usually a policy toggle on the org's Copilot settings page, not something you can self-enable.

Getting Inline Suggestions

Once signed in, just start typing in any supported file — Copilot shows suggestions as greyed-out "ghost text" ahead of your cursor. Key bindings you'll use constantly:

  • Tab — accept the full suggestion.
  • Ctrl+ — accept just the next word of the suggestion, useful when you agree with the start but want to steer the rest yourself.
  • Alt+] / Alt+[ — cycle to the next/previous alternative suggestion.
  • Esc — dismiss the current suggestion.

Writing a descriptive function signature or a comment above where you're about to code dramatically improves suggestion quality, since Copilot is essentially predicting what comes next based on that context:

# Parse a CSV of server hostnames and return only those that respond to ping
def get_reachable_hosts(csv_path: str) -> list[str]:

Typing that signature and comment, then hitting Enter, is usually enough for Copilot to draft a complete, reasonable implementation.

Generating Docstrings and Comments

Place your cursor inside an existing function and open the docstring convention for your language — in Python, typing """ right after a function definition and pausing will typically trigger Copilot to draft a full docstring including parameter descriptions and return type, based on reading the function body. If it doesn't trigger automatically, use the Copilot Chat panel instead: select the function, right-click, and choose Copilot → Generate Docs.

Automated Unit Test Generation

Select a function (or open the file with it in focus), then either:

  • Right-click the selection and choose Copilot → Generate Tests, or
  • Open the Copilot Chat panel (Ctrl+Alt+I) and type /tests with the function selected.

Copilot will infer your test framework from the project (pytest, Jest, xUnit, etc. based on existing dependencies and test files) and generate a new test file or append to an existing one covering typical inputs, edge cases, and error conditions it can infer from the function signature.

import pytest
from hosts import get_reachable_hosts

def test_get_reachable_hosts_empty_file(tmp_path):
    csv_file = tmp_path / "empty.csv"
    csv_file.write_text("")
    assert get_reachable_hosts(str(csv_file)) == []

def test_get_reachable_hosts_invalid_path():
    with pytest.raises(FileNotFoundError):
        get_reachable_hosts("does_not_exist.csv")

Treat generated tests as a starting scaffold — review that the assertions actually reflect correct expected behavior rather than just what the current (possibly buggy) implementation happens to return.

Tuning Suggestion Behavior

Open Settings (Ctrl+,) and search "Copilot" for useful adjustments:

  • github.copilot.enable — toggle Copilot on/off per language (e.g., disable it for Markdown or plaintext files where you don't want autocomplete noise).
  • editor.inlineSuggest.enabled — global on/off switch for inline ghost-text suggestions.

Working with Copilot Chat

For anything beyond inline completion — explaining a block of code, refactoring across a selection, or asking "why does this throw a null reference here" — use the chat panel rather than trying to coax it out of inline suggestions. Type /explain, /fix, or /tests with a selection active for the most reliable results, since these slash commands route to purpose-built prompts rather than a generic chat response.

Warning: Copilot suggestions are trained on public code and can occasionally reproduce patterns with security issues (SQL string concatenation instead of parameterized queries, weak default crypto settings) or outdated API usage. Review generated code the same way you'd review a pull request from a junior contributor — especially around authentication, database queries, and anything handling user input.

Wrap-Up

Copilot setup is genuinely just sign in and start typing, but getting real value out of it comes from writing descriptive comments and signatures before the code you want generated, leaning on /tests and /explain for the heavier lifting, and reviewing what it produces with the same scrutiny you'd apply to any other contributor's code.

Featured Infrastructure Partner

Deploy on High-Performance Hostinger Cloud

Get up to 75% OFF + free domain & SSL. Powering xube.me's sub-second response times.

Claim Discount ↗

Discussion & Insights

Related Technical Essays