GitHub Copilot in VS Code cheat sheet #950
Labels
code-generation
code generation models and tools like copilot and aider
github
gh tools like cli, Actions, Issues, Pages
Jupyter-Notebook
Jupyter Interactive Notebooks and related content
programming-languages
Topics related to programming languages and their features.
python
Python code, tools, info
software-engineering
Best practice for software engineering
GitHub Copilot in VS Code cheat sheet
Snippet
GitHub Copilot in Visual Studio Code provides AI-powered features to help you write code faster and with less effort. This cheat sheet provides a quick overview of the features for GitHub Copilot in Visual Studio Code.
You can access GitHub Copilot in VS Code through the Chat view, directly in the editor, from the integrated terminal, and via AI-powered enhancements in the VS Code user interface.
The team is continuously working on improving Copilot in VS Code and adding new features. Items in the cheat sheet marked with 🚧 are experimental features. Try them out and share your feedback in our issues.
Chat with GitHub Copilot
Use natural language to chat with GitHub Copilot and get help with coding tasks. For example, ask Copilot to explain a block of code or a programming concept. Get more information about using Copilot Chat.
Ctrl+Alt+I
Ctrl+Shift+Alt+I
Ctrl+Shift+Alt+L
Ctrl+I
@
in chat or select 🚧 to view the list of chat participants, which are domain experts that can help you in a specific area. Extensions can also contribute additional participants.Example:
@workspace how is auth implemented?
/
/explain
Tips:
@
participants to get more precise and relevant answers.Code editing session (Preview)
Use Copilot Edits to start a code editing session where you can iterate quickly on AI-generated code edits that are applied directly across multiple files in your workspace.
Ctrl+Shift+Alt+I
Tips:
Generate code from chat
Copilot can generate code blocks in response to your chat prompts. Quickly apply the generated code in your project or insert it in a new file. For example, ask Copilot to optimize an algorithm in your code.
Tips:
Attach context to your chat prompt
When you send a chat prompt to Copilot, you can attach context to help Copilot understand your question better. For example, add the current editor selection, a file, or a symbol to your chat prompt. Get more information about best practices for using Copilot.
Ctrl+/
)#codebase
#editor
#selection
#terminalSelection
#terminalLastCommand
#VSCodeAPI
#file
#<filename>
#
, followed by a filename, to get filename suggestions for workspace files and attach as context.Tips:
Copilot in the editor
As you're coding in the editor, you can use Copilot to generate code completions as you're typing. Invoke Inline Chat to ask questions and get help from Copilot, while staying in the flow of coding. For example, ask Copilot to generate unit tests for a function or method. Get more information about code completions and Inline Chat.
Example:
# write a calculator class with methods for add, subtract, and multiply. Use static methods.
Ctrl+I
F2
Tips:
Customize AI code generation
Copilot can generate responses that match the coding style, tools, and developer workflow of your team or project, provided it has the right context. You can provide custom instructions to help Copilot adjust to your preferences, so that you don't have to provide these details every time you make a Copilot request. These custom instructions are automatically added to your requests. Get more information about customizing Copilot in VS Code.
.gitHub/copilot-instructions.md
file in your workspace. These common instructions supplement your own personal code-generation instructions.Tips:
Review code (Preview)
Copilot can do a quick review pass of a code block or perform a review of uncommitted changes in your workspace. Review feedback shows up as comments in the editor, where you can apply the suggestions.
Generate tests
Copilot can generate tests for functions and methods in your codebase. Get more information about slash commands in Chat.
/tests
/setupTests
/fixTestFailure
Tips:
Generate documentation
Generate code documentation for functions and methods in your codebase. Get more information about slash commands in Chat.
/docs
Debug and fix problems
Use Copilot to help fix coding problems and to get help with configuring and starting debugging sessions in VS Code.
/fix
/fixTestFailure
/startDebugging
launch.json
debug configuration file and start a debugging session from the Chat view. Get more information.Tips:
Scaffold a new project
Copilot can help you create a new project by generating a scaffold of the project structure, or generate a notebook based on your requirements.
/new
/new
command in the Chat view to scaffold a new project or a new file. Use natural language to describe the type of project/file you need, and preview the scaffolded content before creating it.Example:
/new Express app using typescript and svelte
/newNotebook
/newNotebook
command in the Chat view to generate a new Jupyter notebook based on your requirements. Use natural language to describe what the notebook should contain.Example:
/newNotebook get census data and preview key insights with Seaborn.
Source control and issues
Copilot can analyze the changes in your commits and pull requests and provide suggestions for commit messages and pull request descriptions.
@github
@github
participant in chat to ask about issues, pull requests, and more across your repositories. Get more information about the available GitHub skills.Example:
@github What are all of the open PRs assigned to me?
,@github Show me the recent merged pr's from @dancing-mona
Search
Use Copilot to get more relevant search results in the Search view.
Terminal
Get help about shell commands and how to resolve errors when running commands in the terminal.
Ctrl+I
Example:
how many cores on this machine?
@terminal
@terminal
participant in the Chat View to ask questions about the integrated terminal or shell commands.Example:
@terminal list the 5 largest files in this workspace
@terminal /explain
/explain
command in the Chat View to explain something from the terminal.Example:
@terminal /explain top shell command
Python and Notebook support
You can use Copilot Chat to help you with Python programming tasks in the Native Python REPL and in Jupyter notebooks.
Ctrl+I
#
Ctrl+I
VS Code commands and APIs
You can use Copilot to get help about VS Code features, settings, and the VS Code extension APIs. Get more information about chat participants.
@vscode
@vscode
chat participant to ask questions about VS Code by using natural language.Example:
@vscode how to enable word wrapping?
@vscode /runCommand
/runCommand
with the@vscode
chat participant to run a VS Code command.Example:
@vscode /runCommand enable developer mode
@vscode /search
/search
with the@vscode
chat participant to generate a VS Code search.Example:
@vscode /search python files without imports
Tips:
#vscodeAPI
chat variable if you're asking about the VS Code extension API.Next steps
Suggested labels
None
The text was updated successfully, but these errors were encountered: