Accepting, Rejecting, and Cycling Through Suggestions
Efficiently managing Copilot's suggestions is essential for a smooth workflow. This lesson covers the keyboard shortcuts, techniques, and strategies for working with suggestions effectively.
Understanding Suggestion Types
Copilot provides several types of suggestions:
Inline Ghost Text
The most common type - gray text that appears as you type:
function greet(name) {
return `Hello, ${name}!`; // ← This appears as gray ghost text
}
Multi-Line Completions
Copilot often suggests entire blocks of code:
def calculate_statistics(numbers):
# Copilot might suggest all of this at once:
if not numbers:
return None
total = sum(numbers)
count = len(numbers)
average = total / count
return {
'sum': total,
'count': count,
'average': average,
'min': min(numbers),
'max': max(numbers)
}
Copilot Panel Suggestions
Opening the Copilot panel shows multiple alternative completions side by side.
Essential Keyboard Shortcuts
Master these shortcuts to work efficiently:
VS Code Shortcuts
| Action | Windows/Linux | macOS | Description |
|---|---|---|---|
| Accept full suggestion | Tab | Tab | Accept the entire suggestion |
| Accept word | Ctrl+Right | Cmd+Right | Accept one word at a time |
| Accept line | Ctrl+End | Cmd+End | Accept current line only |
| Dismiss | Escape | Escape | Dismiss current suggestion |
| Next suggestion | Alt+] | Option+] | Cycle to next alternative |
| Previous suggestion | Alt+[ | Option+[ | Cycle to previous alternative |
| Open panel | Ctrl+Enter | Ctrl+Enter | Show all suggestions in panel |
| Trigger suggestion | Alt+\ | Option+\ | Manually trigger Copilot |
JetBrains Shortcuts
| Action | Shortcut |
|---|---|
| Accept suggestion | Tab |
| Dismiss | Escape |
| Next suggestion | Alt+] |
| Previous suggestion | Alt+[ |
| Show all suggestions | Alt+Enter |
Accepting Suggestions Strategically
Full Accept with Tab
Use Tab when the entire suggestion is correct:
// Type this comment:
// Function to check if a number is prime
// Copilot suggests:
function isPrime(n) {
if (n <= 1) return false;
for (let i = 2; i * i <= n; i++) {
if (n % i === 0) return false;
}
return true;
}
// Press Tab to accept all of it
Partial Accept with Word-by-Word
When only the beginning is correct, accept word by word:
# Copilot suggests: user_data = fetch_from_database(user_id)
# But you want: user_data = fetch_from_api(user_id)
# Press Ctrl+Right twice to accept "user_data = fetch_from_"
# Then type "api" yourself
Accept Line Only
For multi-line suggestions where only the first line is useful:
// Copilot suggests multiple lines, but you only want the first
const config = {
apiKey: process.env.API_KEY, // ← Accept only this line
baseUrl: 'https://api.example.com', // ← You want something different
}
Cycling Through Alternatives
Copilot often has multiple suggestions. Cycle through them to find the best one:
// For a sorting function, Copilot might offer:
// Suggestion 1 (Alt+]):
const sorted = arr.sort((a, b) => a - b);
// Suggestion 2 (Alt+]):
const sorted = [...arr].sort((a, b) => a - b); // Non-mutating
// Suggestion 3 (Alt+]):
const sorted = arr.slice().sort((a, b) => a - b); // Also non-mutating
// Choose the one that fits your needs
Using the Suggestions Panel
Press Ctrl+Enter to open a panel showing up to 10 suggestions side by side:
# For: def format_date(date):
# The panel might show:
# Suggestion 1
def format_date(date):
return date.strftime('%Y-%m-%d')
# Suggestion 2
def format_date(date):
return date.isoformat()
# Suggestion 3
def format_date(date):
return f"{date.month}/{date.day}/{date.year}"
# Click on the best option or use number keys
Manually Triggering Suggestions
Sometimes Copilot doesn't show suggestions automatically. Trigger them manually:
- Position your cursor where you want the suggestion
- Press
Alt+\(Windows/Linux) orOption+\(macOS) - Wait for Copilot to generate suggestions
This is useful when:
- Copilot's automatic trigger didn't fire
- You're at the end of a file with no context
- You want fresh suggestions after editing
Practical Workflows
The "Comment, Wait, Accept" Workflow
# 1. Write a detailed comment
# Calculate the distance between two GPS coordinates using the Haversine formula
# Parameters: lat1, lon1, lat2, lon2 (all in degrees)
# Returns: distance in kilometers
# 2. Press Enter and wait for suggestion
# 3. Review the suggestion carefully
# 4. Accept with Tab or cycle through alternatives
def haversine_distance(lat1, lon1, lat2, lon2):
from math import radians, sin, cos, sqrt, atan2
R = 6371 # Earth's radius in kilometers
lat1, lon1, lat2, lon2 = map(radians, [lat1, lon1, lat2, lon2])
dlat = lat2 - lat1
dlon = lon2 - lon1
a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
c = 2 * atan2(sqrt(a), sqrt(1-a))
return R * c
The "Scaffold, Then Fill" Workflow
// 1. Let Copilot generate the structure
class UserService {
constructor(database) {}
async createUser(userData) {}
async getUserById(id) {}
async updateUser(id, updates) {}
async deleteUser(id) {}
}
// 2. Go method by method and let Copilot fill in implementations
// 3. Accept or modify each suggestion as needed
The "Test-First" Workflow
// 1. Write the test first
describe('formatCurrency', () => {
it('should format positive numbers with dollar sign', () => {
expect(formatCurrency(1234.56)).toBe('$1,234.56');
});
it('should handle negative numbers', () => {
expect(formatCurrency(-99.99)).toBe('-$99.99');
});
});
// 2. Now implement - Copilot has context from your tests
function formatCurrency(amount: number): string {
// Copilot suggests implementation matching your test expectations
}
When to Reject Suggestions
Not every suggestion is worth accepting. Reject when:
The Logic is Wrong
# Comment: Return the second largest number in a list
def second_largest(numbers):
# Bad suggestion - doesn't handle duplicates correctly:
# return sorted(numbers)[-2]
# Reject and let it suggest again, or write your own:
unique = list(set(numbers))
unique.sort(reverse=True)
return unique[1] if len(unique) > 1 else None
It Uses Deprecated APIs
// Copilot might suggest old patterns:
// componentWillMount() { ... } ← Deprecated in React
// Reject and guide it to modern patterns:
// Using React hooks for initialization
useEffect(() => {
// initialization code
}, []);
It's Overly Complex
# For a simple task, reject complex suggestions:
# Complex: Using recursion with memoization for a simple sum
# Accept: Simple loop or built-in function
total = sum(numbers)
Tips for Faster Workflow
1. Keep Typing If Wrong
Don't wait for bad suggestions - just keep typing. Copilot will update its suggestions based on what you've typed.
2. Use Escape Liberally
If a suggestion appears and distracts you, quickly press Escape and continue your thought.
3. Trust Partial Accepts
Word-by-word acceptance is powerful. Get comfortable using Ctrl+Right to take just what you need.
4. Open Related Files
Better context leads to better suggestions. Keep relevant files open in your editor.
Summary
Efficiently working with Copilot suggestions is about:
- Using the right acceptance method - Full, partial, or line-by-line
- Cycling through alternatives - Don't settle for the first suggestion
- Using the panel for complex completions with multiple options
- Manually triggering when automatic suggestions don't appear
- Knowing when to reject - Bad logic, deprecated APIs, or unnecessary complexity
Master these techniques, and you'll find yourself in a productive flow with Copilot, accepting good suggestions quickly and moving past bad ones without breaking your concentration.
Next, you'll learn about Copilot Chat - a powerful feature for having conversations about your code.

