Using Copilot in VS Code¶
Copilot is an AI-powered code completion tool developed by GitHub. It can assist you in writing code by providing suggestions and autocompletions based on the context of your code. Here’s how to use Copilot in VS Code:
Click on the
Extensionsicon on the side of the windowSearch for
Copilotand click on the “Install” button.
- … image:: _static/copilot_extension.png
- alt:
GitHub Copilot Extension in VS Code
- width:
500px
- align:
center
You will be prompted to sign in to your GitHub account
Copilot will provide suggestions and autocompletions as you type. You can accept the suggestions by pressing Tab or Enter
You can also trigger Copilot suggestions manually by pressing Ctrl + Space
You can also chat with Copilot by opening the Copilot chat with Ctrl + I
Suggestions will also appear in the left gutter of the editor for a certain line. You can click on the suggestion in the gutter to accept it.
If the line is out of view, you can click on the suggestion in the gutter to scroll to the line and accept the suggestion.
Suggestions may also appear under a certain word in different colors. Green means additional code, blue means replacement code, and red means deletion of code. You can click on the suggestion to accept it.
Why Use Copilot?¶
Copilot is free up to a specific number of suggestions per day. After that, you will need to subscribe to GitHub Copilot for continued access to its features. However, you are recommended to use Copilot for the following reasons:
If you use another chat-based AI tool, you will need to switch between the code editor and the browser to get and copy/paste suggestions. This can be time-consuming and disrupt your workflow. With Copilot integrated into VS Code, you can get suggestions without leaving your code editor, making it more efficient and seamless.
Copilot can provide more context-aware suggestions since it is integrated into the code editor and can analyze your code in real-time. You need to explain the context of your code to a chat-based AI tool, which is time-consuming.