AI Features¶
GitHub Copilot and AI assistants in VS Code.
GitHub Copilot¶
Overview¶
GitHub Copilot provides AI-powered code completions:
- Inline suggestions
- Multi-line completions
- Comment-to-code generation
- Code explanations
Installation¶
- Install extension:
GitHub.copilot - Sign in with GitHub
- Copilot subscription required
Configuration¶
{
"github.copilot.enable": {
"*": true,
"yaml": true,
"markdown": true,
"plaintext": false
},
"github.copilot.editor.enableAutoCompletions": true
}
Using Copilot¶
Inline Suggestions
- Start typing, suggestions appear as gray text
- Tab to accept
- Esc to dismiss
- Alt+] for next suggestion
- Alt+[ for previous suggestion
Multi-line Suggestions
Copilot suggests complete functions, classes, and code blocks.
Comment-Driven
Write a comment describing what you want:
Copilot generates the implementation.
Keyboard Shortcuts¶
| Key | Action |
|---|---|
| Tab | Accept suggestion |
| Esc | Dismiss suggestion |
| Alt+] | Next suggestion |
| Alt+[ | Previous suggestion |
| Alt+\ | Trigger suggestion |
| Ctrl+Enter | Open Copilot panel |
Disable for Specific Files¶
GitHub Copilot Chat¶
Installation¶
Install extension: GitHub.copilot-chat
Features¶
- Ask coding questions
- Explain code
- Generate tests
- Fix errors
- Refactor code
Opening Chat¶
- Cmd+Shift+I or
- Click Copilot icon in Activity Bar
Chat Commands¶
| Command | Action |
|---|---|
/explain | Explain selected code |
/fix | Fix problems in code |
/tests | Generate tests |
/doc | Generate documentation |
/clear | Clear chat history |
@workspace | Ask about workspace |
@vscode | Ask about VS Code |
@terminal | Ask about terminal |
Inline Chat¶
- Select code
- Cmd+I to open inline chat
- Type instruction
- Review and accept changes
Examples¶
Explain this function
@workspace How do I run tests?
/fix this code has a bug
/tests write tests for this class
Configuration¶
Alternative AI Extensions¶
Continue¶
Continue (continue.continue)
Open-source AI assistant:
- Works with any LLM (Claude, GPT, Ollama)
- Customizable prompts
- Context-aware completions
Configuration (~/.continue/config.json):
{
"models": [
{
"title": "Claude",
"provider": "anthropic",
"model": "claude-sonnet-4-20250514",
"apiKey": "YOUR_API_KEY"
}
],
"tabAutocompleteModel": {
"title": "Ollama",
"provider": "ollama",
"model": "codellama"
}
}
Codeium¶
Codeium (codeium.codeium)
Free AI code completion:
- No subscription required
- Multi-language support
- Chat interface
Tabnine¶
Tabnine (tabnine.tabnine-vscode)
AI assistant with local model option:
- Privacy-focused
- Team training available
Claude Integration (via Continue)¶
Setup¶
- Install Continue extension
- Configure with Anthropic API:
{
"models": [
{
"title": "Claude Sonnet",
"provider": "anthropic",
"model": "claude-sonnet-4-20250514",
"apiKey": "${ANTHROPIC_API_KEY}"
}
]
}
Environment Variable¶
Using Claude¶
- Cmd+L to open Continue chat
- Select code and ask questions
- Use
/editto modify code
Local AI with Ollama¶
Setup¶
- Install Ollama:
brew install ollama - Pull model:
ollama pull codellama - Configure Continue:
{
"models": [
{
"title": "CodeLlama",
"provider": "ollama",
"model": "codellama:13b"
}
],
"tabAutocompleteModel": {
"title": "Local Complete",
"provider": "ollama",
"model": "codellama:7b"
}
}
Best Practices¶
Security¶
{
"github.copilot.enable": {
"*.env*": false,
"*.pem": false,
"*.key": false,
"**/.ssh/*": false
}
}
Quality Suggestions¶
- Write clear comments
- Use descriptive variable names
- Follow consistent patterns
- Review all suggestions
When to Use AI¶
- Boilerplate code
- Standard implementations
- Code explanations
- Test generation
- Documentation
When Not to Use AI¶
- Security-critical code (review carefully)
- Business logic (validate thoroughly)
- Sensitive data handling
Troubleshooting¶
Copilot Not Working¶
- Check subscription status
- Sign out and sign in again
- Check extension is enabled
- Restart VS Code
Slow Suggestions¶
- Check network connection
- Reduce context size
- Disable for large files
No Suggestions Appearing¶
- Check file type is enabled
- Try Alt+\ to trigger manually
- Check Copilot status in status bar
Keyboard Reference¶
| Key | Action |
|---|---|
| Tab | Accept inline suggestion |
| Esc | Dismiss suggestion |
| Alt+] | Next suggestion |
| Alt+[ | Previous suggestion |
| Ctrl+Enter | Open suggestions panel |
| Cmd+Shift+I | Open Copilot Chat |
| Cmd+I | Inline chat (with selection) |