GitHub Copilot Cheat Sheet

Last Updated: November 21, 2025

Essential Keyboard Shortcuts

Tab
Accept suggestion
Ctrl/Cmd + →
Accept next word of suggestion
Alt/Opt + ]
Next suggestion
Alt/Opt + [
Previous suggestion
Ctrl/Cmd + Enter
Open Copilot panel (up to 10 suggestions)
Esc
Dismiss suggestion
Alt/Opt + \
Trigger inline suggestion manually
Ctrl/Cmd + I
Open Copilot Chat inline

Effective Comment Prompts

// Function to validate email address
Generate function with clear purpose
// TODO: Add error handling for null values
Generate specific implementation
// Test: should return true for valid inputs
Generate unit tests
// API endpoint to fetch user data from database
Generate API routes
// SQL query to join users and orders tables
Generate database queries
// Regex pattern for phone number validation
Generate regex patterns

Copilot Chat Commands

/explain
Explain selected code
/fix
Suggest fixes for bugs in code
/tests
Generate unit tests for code
/doc
Generate documentation
/simplify
Simplify selected code
/optimize
Optimize code performance
@workspace
Ask about entire workspace
@terminal
Ask about terminal commands

Best Practices for Prompts

Technique Example Why It Works
Be specific // Create async function to fetch user by ID with error handling More context = better results
Include examples // Format: YYYY-MM-DD Copilot learns from patterns
Use descriptive names function calculateMonthlyPayment() { Names guide implementation
Break into steps // Step 1: Validate input
// Step 2: Process data
Clearer logic flow
Specify language features // Using async/await and try/catch Controls syntax style
Add context above // Given userList array of objects Informs data structures

Code Generation Patterns

Start typing function name
Copilot suggests entire implementation
Write one test case
Copilot generates more test cases
Create interface/type
Copilot suggests matching implementations
Write first array element
Copilot completes array pattern
Start conditional statement
Copilot suggests all branches
Import statement
Copilot suggests related imports

Language-Specific Tips

Language Best Use Cases Tip
JavaScript/TypeScript React components, API calls, async functions Specify TypeScript types in comments
Python Data processing, list comprehensions, pandas operations Use docstrings for function specs
Java POJO classes, builders, repository patterns Start with class signature and annotations
Go Error handling, struct methods, interfaces Define interfaces first for better suggestions
Rust Pattern matching, trait implementations, error types Specify lifetimes and ownership in comments
SQL Complex joins, window functions, CTEs Describe table schema in comments

Settings & Configuration

Settings > GitHub Copilot > Enable Auto-Completions
Toggle Copilot on/off
Settings > Copilot > Inline Suggest
Configure inline suggestions
.gitignore patterns
Copilot respects ignored files
Copilot: Block Suggestions Matching Public Code
Avoid copyright issues
Language-specific enable/disable
Control Copilot per file type

Advanced Techniques

Context from open tabs
Copilot uses other open files for context
Neighboring code patterns
Similar code in file guides suggestions
Chain multiple accepts
Accept → Tab → Tab for rapid generation
Iterate with rejections
Reject bad suggestions to refine next ones
Use consistent naming
Patterns improve across codebase
Comment out old code
Shows Copilot what to improve

Common Use Cases

Task Approach Example Prompt
Boilerplate code Type class/function signature class UserService {
Unit tests Use /tests or describe test case test('should validate email', () => {
Documentation Start JSDoc comment /**
* @param {string} userId
Refactoring Comment desired structure // Refactor to use async/await
Regex patterns Describe validation need // Regex for ISO 8601 date
Error handling Add try-catch skeleton try {
// [let Copilot fill]

Troubleshooting

No suggestions appearing
Check status bar icon, verify subscription, restart VS Code
Poor quality suggestions
Add more context, be more specific, check file type
Wrong language suggestions
Verify file extension, add language comment at top
Slow performance
Disable for large files, check network, reduce open tabs
Copilot blocked by policy
Check organization settings, contact admin
💡 Pro Tip: Copilot learns from your codebase context - keep related files open for better suggestions. Start with descriptive comments or function names, then let Copilot generate the implementation. Review and test all AI-generated code before committing!
← Back to DevOps & Cloud | Browse all categories | View all cheat sheets