GitHub Copilot - Cheatsheet
Overview
Quick reference: Essential shortcuts, commands, and patterns for effective GitHub Copilot usage
Keyboard Shortcuts
VS Code - Basic Controls
- Tab - Accept suggestion
- Esc - Dismiss suggestion
- Alt + ] - Next suggestion
- Alt + [ - Previous suggestion
- Ctrl + Enter - Open Copilot panel
- Alt + \ - Trigger inline suggestion
VS Code - Advanced
- Ctrl + Shift + P โ "GitHub Copilot: ..."
- Ctrl + I - Start inline chat
- Ctrl + Shift + I - Start quick chat
- Alt + / - Toggle Copilot
- Ctrl + K Ctrl + I - Explain code
JetBrains IDEs
- Tab - Accept suggestion
- Esc - Dismiss suggestion
- Alt + \ - Trigger suggestion
- Alt + Enter - Show actions
- Ctrl + Shift + A - Find Copilot actions
- Alt + C - Open Copilot chat
Neovim
- Tab - Accept suggestion
- Ctrl + ] - Next suggestion
- Ctrl + [ - Previous suggestion
- Alt + \ - Trigger suggestion
- :Copilot - Access commands
Effective Prompting Patterns
Function Generation
// โ
Detailed function description
// Function to debounce API calls, waits for specified delay after last call
// Parameters: func (function), delay (ms), immediate (boolean)
// Returns: debounced function that can be cancelled
function debounce(func, delay, immediate = false) {
// Copilot generates implementation
}
// โ
With examples
// Convert temperature between Celsius and Fahrenheit
// Example: convertTemp(100, 'C', 'F') โ 212
// Example: convertTemp(32, 'F', 'C') โ 0
function convertTemp(value, from, to) {
// Implementation follows
}
Class Generation
# โ
Class with clear purpose and methods
# User management class with authentication and profile operations
# Methods: login, logout, update_profile, get_user_data
class UserManager:
def __init__(self, database):
# Copilot suggests initialization
def login(self, username, password):
# Authentication logic generated
def logout(self, user_id):
# Logout implementation
API Integration
# โ
Specific API requirements
# REST API client for JSONPlaceholder service
# Methods: get_posts, create_post, update_post, delete_post
# Handles authentication, rate limiting, and error responses
import requests
from typing import Dict, List, Optional
class JSONPlaceholderClient:
def __init__(self, base_url: str = "https://jsonplaceholder.typicode.com"):
# Implementation generated
Common Comment Patterns
Data Processing
# Parse CSV file and return as list of dictionaries
# Handle missing values and data type conversion
# Support for custom delimiter and encoding
# Filter dataframe by multiple conditions
# Remove duplicates and handle null values
# Sort by specified column with custom order
Web Development
// Express middleware for request logging
// Include timestamp, method, URL, IP address
// Write to file and console with rotation
// React component for user profile form
// Include validation, loading states
// Handle form submission and error display
Database Operations
-- SQL query to find users with recent activity
-- Join users, sessions, and activities tables
-- Filter by last 30 days, include user details
# MongoDB aggregation pipeline
# Group by category, calculate averages
# Sort by count descending, limit to top 10
Testing
# Unit tests for email validation function
# Test valid emails, invalid formats
# Edge cases: empty, null, special characters
// Integration test for user registration API
// Test success case, validation errors
// Mock external dependencies and database
Quick Commands
VS Code Command Palette
GitHub Copilot: Enable/Disable
GitHub Copilot: Open Completions Panel
GitHub Copilot: Generate Tests
GitHub Copilot: Explain This
GitHub Copilot: Fix This
GitHub Copilot: Generate Docs
GitHub Copilot: Toggle Inline Suggestions
Inline Chat Commands
/explain - Explain selected code
/fix - Fix problems in selection
/test - Generate unit tests
/doc - Generate documentation
/optimize - Optimize performance
/refactor - Improve code structure
Configuration Snippets
VS Code Settings
{
// Enable/disable Copilot
"github.copilot.enable": {
"*": true,
"yaml": false,
"plaintext": false,
"markdown": true
},
// Inline suggestions
"github.copilot.inlineSuggest.enable": true,
"github.copilot.inlineSuggest.count": 3,
// Editor integration
"editor.inlineSuggest.enabled": true,
"editor.inlineSuggest.showToolbar": "onHover",
// Advanced settings
"github.copilot.advanced": {
"secret_key": "your-key",
"length": 500,
"temperature": 0.1,
"top_p": 1,
"indentationMode": {
"python": "tab",
"javascript": "space"
}
}
}
Language-Specific Settings
{
"[python]": {
"github.copilot.enable": true,
"github.copilot.inlineSuggest.enable": true
},
"[javascript]": {
"github.copilot.enable": true,
"github.copilot.advanced.temperature": 0.2
},
"[markdown]": {
"github.copilot.enable": false
}
}
Troubleshooting
No Suggestions Appearing
- Check if Copilot is enabled (status bar icon)
- Verify GitHub authentication
- Restart editor
- Check language support
- Clear editor cache
Poor Quality Suggestions
- Write more descriptive comments
- Provide more context in surrounding code
- Break complex requests into smaller parts
- Use specific examples in comments
- Check indentation and syntax
Performance Issues
- Reduce suggestion count in settings
- Disable in large files temporarily
- Check network connectivity
- Clear suggestion cache
- Update extension to latest version
Authentication Problems
- Sign out and back in to GitHub
- Check subscription status
- Verify organization permissions
- Clear stored credentials
- Use personal access token if needed
Best Practices Checklist
Before Using Copilot
- โ Have a clear understanding of what you want to build
- โ Set up proper project structure and dependencies
- โ Configure Copilot settings for your workflow
- โ Understand your codebase conventions
While Using Copilot
- โ Write clear, descriptive comments before code
- โ Review each suggestion before accepting
- โ Test generated code thoroughly
- โ Refactor to match your code style
- โ Understand the logic being generated
After Using Copilot
- โ Run comprehensive tests
- โ Review for security vulnerabilities
- โ Check for licensing compliance
- โ Document generated functions properly
- โ Optimize performance if needed
Pricing & Plans
Individual ($10/month)
- Code completions
- Chat assistance
- CLI integration
- Mobile app access
Business ($19/user/month)
- Everything in Individual
- Policy management
- Organization-wide settings
- Audit logs
- IP indemnity
Enterprise ($39/user/month)
- Everything in Business
- Fine-tuned models
- Advanced security
- Priority support
- Usage analytics
Free for Students
- Verified students get free access
- Same features as Individual plan
- GitHub Student Developer Pack
- Educational institution verification
Resources & Links
- Official Documentation: docs.github.com/copilot
- VS Code Extension: Search "GitHub Copilot" in extensions
- JetBrains Plugin: plugins.jetbrains.com
- Community: GitHub Discussions
- Status Page: githubstatus.com