6 min read
Lesson 2 of 6
Mastering Inline Completions
From the course GitHub Copilot Mastery
Inline completions are Copilot's core feature — intelligent code suggestions that appear as ghost text as you type.
Triggering Great Completions
1. Comment-Driven Development
Write a descriptive comment, then let Copilot generate the code:
# Function that calculates compound interest with monthly contributions
# Parameters: principal, annual_rate, years, monthly_contribution
# Returns: final amount and total interest earned
def calculate_compound_interest(principal, annual_rate, years, monthly_contribution):
# Copilot generates the implementation
2. Function Signature First
Type the function name and parameters — Copilot infers the body:
function validateEmail(email: string): { valid: boolean; error?: string } {
// Copilot completes based on the signature
}
3. Pattern Recognition
Write one example, and Copilot continues the pattern:
users = [
{"name": "Alice", "role": "admin", "email": "[email protected]"},
# Copilot generates more realistic sample data
]
Keyboard Shortcuts
| Action | Shortcut |
|---|---|
| Accept suggestion | Tab |
| Reject suggestion | Esc |
| Next suggestion | Alt + ] |
| Previous suggestion | Alt + [ |
| Accept word-by-word | Ctrl + → |
| Open completions panel | Ctrl + Enter |
Tips for Better Completions
- Keep relevant files open in your editor — Copilot uses them as context
- Be descriptive in variable and function names
- Write clear type annotations (especially in TypeScript)
- Use the completions panel (Ctrl+Enter) to see 10+ alternatives
- Accept partial suggestions word-by-word with Ctrl+→
Key Takeaways
- •Write descriptive comments before code for better completions
- •Tab accepts, Esc rejects, Alt+] cycles alternatives
- •Keep relevant files open for better project context
- •Use Ctrl+Enter to see multiple alternative suggestions
0 of 6 lessons marked complete
Progress is kept in this browser only.