p:: AI f:: GitHub CLI
Getting code suggestions in your IDE with GitHub Copilot
- Getting code suggestions in your IDE with GitHub Copilot - GitHub Docs
- GitHub Copilot in VS Code cheat sheet
Key Combination | Action |
---|---|
Tab | Accept the suggestion |
Option (⌥) or Alt + ] | See next suggestion |
Option (⌥) or Alt + [ | See previous suggestion |
Ctrl + Enter | Show multiple suggestions in a new tab |
Command + → | Accept Next Word |
Asking GitHub Copilot questions in your IDE
- Asking GitHub Copilot questions in your IDE - GitHub Docs
- AI-powered chat conversations with GitHub Copilot
Key Combination | Action |
---|---|
Control + Command + i | Open the chat view |
Command + i | Start an inline chat |
Shift + Command + i | Quick chat dropdown |
- Smart actions: To submit prompts via the context menu, right click in your editor, select Copilot in the menu that appears, then select one of the actions. Smart actions can also be accessed via the sparkle icon that sometimes appears when you select a line of code.
Chat participants
-
@workspace
has context about the code in your workspace and can help you navigate it, finding relevant files or classes. -
@vscode
knows about commands and features in the VS Code editor itself, and can help you use them. -
@terminal
has context about the integrated terminal shell and its contents. -
@github
has knowledge about your GitHub repositories, issues, pull requests, and topics, and can also perform web searches using the Bing API.
Extensions can also contribute chat participants to provide specialized help for their domain. You can install these extensions from GitHub Marketplace and from Visual Studio Code Marketplace.
Slash commands
Command | Description |
---|---|
/explain | Explain the selected code |
/fix | Propose a fix for problems in the selected code |
/tests | Generate unit tests for the selected code |
/new | Scaffold code for a new workspace or new file |
/clear | Start a new chat |
Chat context
-
#codebase
: the contents of the current workspace. It includes information about the files and folders in your workspace, as well as any settings or configurations specific to that workspace. -
#file
: Include a specific file as context in the chat. -
#selection
: the visible source code in the active editor. -
#terminalLastCommand
: the active terminal’s last run command. -
#terminalSelection
: the active terminal’s selection. -
#editor
: the code in the active editor. The editor content is implicitly included in the Chat view context. -
#vscodeAPI
: use VS Code API references to answer questions about VS Code extension development.
Prompt Engineering for GitHub Copilot
-
Start general, then get specific
-
Give examples
- Unit tests can also serve as examples. Before writing your function, you can use Copilot to write unit tests for the function. Then, you can ask Copilot to write a function described by those unit tests.
-
Break complex tasks into simpler tasks
-
Avoid ambiguity
-
Indicate relevant code
- open any relevant files and close irrelevant files
-
Experiment and iterate
-
Keep history relevant
-
Follow good coding practices
- Use Copilot to help your code follow best practices. For example, ask Copilot to add comments or to break a large function into smaller functions.
-
Using extensions to integrate external tools with Copilot Chat - GitHub Docs