GitHub Copilot Code Suggestions

Code suggestions are the core feature of GitHub Copilot. Every time you pause while typing, Copilot reads your code and offers a completion in grey text. This topic covers how to get better suggestions, how to navigate between them, and how to use them without slowing down your workflow.

How a Suggestion Is Triggered

Copilot watches for two signals before showing a suggestion:

  • You pause typing for about half a second
  • You press Enter to start a new line

Suggestions appear most reliably after a comment, at the start of a new function, or after a function signature. If you type very fast without pausing, suggestions may not appear. Slow down slightly at decision points and let Copilot catch up.

Three Levels of Suggestions

Copilot generates suggestions at three different scales depending on what you have written:

LEVEL 1 — SINGLE LINE COMPLETION
You type:   const userName =
Copilot:    const userName = req.body.username;

LEVEL 2 — MULTI-LINE BLOCK
You type:   function validateAge(age) {
Copilot:    function validateAge(age) {
                if (age < 0 || age > 120) {
                    return false;
                }
                return true;
            }

LEVEL 3 — ENTIRE FILE SCAFFOLD
You create: routes/products.js
Copilot:    Suggests full Express router setup:
            const express = require('express');
            const router = express.Router();
            router.get('/', ...);
            router.post('/', ...);
            module.exports = router;

The level of suggestion depends on how much context Copilot has. A fresh file with just a name gets a full scaffold. A file with 50 lines of code gets line-level completions that fit what you have already written.

Navigating Between Suggestions

When a suggestion appears, Copilot has already generated several alternatives behind the scenes. You can cycle through them:

KEYBOARD SHORTCUTS:
───────────────────────────────────────────────────
Next suggestion      Alt+]      (Windows/Linux)
                     Option+]   (Mac)

Previous suggestion  Alt+[      (Windows/Linux)
                     Option+[   (Mac)

See all suggestions  Ctrl+Enter (opens panel with up to 10)
───────────────────────────────────────────────────

Cycling through suggestions is useful when the first one is close but not exact. The second or third suggestion often fits better for less common patterns.

What Makes a Good Suggestion

Copilot produces better suggestions when your code gives it strong context signals. Here is a comparison:

WEAK CONTEXT → WEAK SUGGESTION:
function process(d) {
    // ...
}
Copilot: console.log(d);   ← generic, not useful

STRONG CONTEXT → STRONG SUGGESTION:
// Calculate the total sales tax for an order
// Tax rate is 8.5% for standard items
function calculateSalesTax(orderTotal, isExempt) {
    ←
Copilot:    if (isExempt) return 0;
            return orderTotal * 0.085;
→ Accurate and immediately usable

Three factors that strengthen suggestions:

  • Descriptive function and variable names
  • A comment just above the function explaining what it does
  • Existing code in the file that sets patterns (e.g., consistent error handling style)

Suggestion Types by Language

Copilot supports dozens of languages but performs differently across them. Its strongest performance is in the languages most represented in GitHub's open-source training data:

STRONGEST SUGGESTIONS:
  JavaScript / TypeScript
  Python
  Go
  Ruby
  Java
  C / C++
  C#
  PHP

GOOD SUGGESTIONS:
  Rust
  Swift
  Kotlin
  Scala

MODERATE SUGGESTIONS:
  Haskell
  Lua
  Elixir
  COBOL / older enterprise languages

If you work in a less common language, you can still get solid suggestions by providing detailed comments and keeping your code patterns consistent throughout the file.

Real Example: Building a Login Function

Here is how Copilot assists step by step when building a login endpoint in Node.js:

YOU WRITE (Step 1):
// POST /login
// Accepts email and password
// Returns JWT token on success or 401 on failure
router.post('/login', async (req, res) => {

COPILOT SUGGESTS (immediately after the opening brace):
    try {
        const { email, password } = req.body;
        const user = await User.findOne({ email });
        if (!user || !user.comparePassword(password)) {
            return res.status(401).json({ error: 'Invalid credentials' });
        }
        const token = jwt.sign({ userId: user._id }, process.env.JWT_SECRET);
        res.json({ token });
    } catch (error) {
        res.status(500).json({ error: 'Server error' });
    }
});

Copilot inferred the JWT library, error handling structure, and response format from the comment. The suggestion is production-ready with one small review.

When to Accept and When to Reject

Not every suggestion is correct. Use this quick decision guide:

ACCEPT when:
  ✓ The logic matches exactly what you need
  ✓ The naming fits your project's style
  ✓ The suggestion handles edge cases you would have written anyway

REJECT (keep typing) when:
  ✗ The variable names are wrong for your project
  ✗ The logic is almost right but uses a different approach
  ✗ The suggestion ignores a constraint you know about

MODIFY when:
  ~ Accept it, then edit the parts that need changing
  ~ This is faster than writing from scratch

Working with Repetitive Code Patterns

Copilot excels at repetitive code. If your file has three similar functions, it learns the pattern and generates the fourth one automatically. Write the first one yourself, and Copilot fills in the rest.

You write:
function getUser(id) {
    return db.query('SELECT * FROM users WHERE id = ?', [id]);
}

function getProduct(id) {
    return db.query('SELECT * FROM products WHERE id = ?', [id]);
}

You type:
function getOrder(

Copilot immediately suggests:
function getOrder(id) {
    return db.query('SELECT * FROM orders WHERE id = ?', [id]);
}

This pattern recognition is one of Copilot's most time-saving behaviors. Once you establish a code pattern in a file, Copilot repeats it accurately.

Disabling Suggestions for Specific File Types

Sometimes you do not want suggestions — for example, in configuration files or files containing sensitive templates. Click the Copilot icon in the status bar and select Disable Completions for [file type]. This turns off suggestions only for that file extension while keeping Copilot active everywhere else.

Code suggestions are the foundation of your Copilot workflow. The more you use them, the better you get at knowing when to accept, when to skip, and when to modify. Speed comes from building that judgment quickly.

Leave a Comment

Your email address will not be published. Required fields are marked *