Introduction
GitHub Copilot provides coding suggestions as you type in your editor. You can also ask Copilot coding-related questions, such as how best to code something, how to fix a bug, or how someone else's code works. For full details of what Copilot can do, see What is GitHub Copilot?.
Instructions for using Copilot differ depending on where you are using it. This version of the quickstart is for JetBrains IDEs. Click the tabs above for instructions on using Copilot in other environments.
Prerequisites
-
Subscription to Copilot. To use GitHub Copilot in Visual Studio, you must have an active GitHub Copilot subscription. For information about how to get access to Copilot, see What is GitHub Copilot?.
-
A compatible JetBrains IDE. Copilot is supported in a large number of JetBrains IDEs. For a full list, see Asking GitHub Copilot questions in your IDE.
-
GitHub Copilot plugin. See the GitHub Copilot plugin in the JetBrains Marketplace. For installation instructions, see Installing the GitHub Copilot extension in your environment.
-
Log in to GitHub in your JetBrains IDE. For authentication instructions, see Installing the GitHub Copilot extension in your environment.
Chat with GitHub Copilot
After you've installed the GitHub Copilot plugin, you can ask Copilot coding-related questions.
Note
If you have access to GitHub Copilot via your organization or enterprise, you won't be able to use GitHub Copilot Chat if your organization owner or enterprise administrator has disabled chat. See Managing policies for Copilot in your organization.
-
Open an existing code file.
-
Open the Copilot Chat window by clicking the Copilot Chat icon at the right side of the JetBrains IDE window.
-
In the Copilot Chat window, type
what does this file do
then press Enter.Copilot's answer is displayed below your question.
-
Select a line of code in the editor.
-
In the Copilot Chat window, type
explain this line
then press Enter.
Get your first code completion suggestion
The following example uses JavaScript, however other languages will work similarly. GitHub Copilot provides suggestions for numerous languages and a wide variety of frameworks, but works especially well for Python, JavaScript, TypeScript, Ruby, Go, C# and C++. GitHub Copilot can also assist in query generation for databases, generating suggestions for APIs and frameworks, and can help with infrastructure as code development.
-
In your JetBrains editor, create a new JavaScript (*.js) file.
-
In the JavaScript file, type the following function header.
JavaScript function calculateDaysBetweenDates(begin, end) {
function calculateDaysBetweenDates(begin, end) {
GitHub Copilot will automatically suggest an entire function body in grayed text. The exact suggestion may vary.
-
To accept the suggestion, press Tab.
Next steps
- Find out more about Copilot code completion - See Getting code suggestions in your IDE with GitHub Copilot.
- Find out more about GitHub Copilot Chat - See Asking GitHub Copilot questions in your IDE and Asking GitHub Copilot questions in GitHub.
- Learn how to write effective prompts - See Prompt engineering for Copilot Chat.
- Use Copilot on your mobile device - See Asking GitHub Copilot questions in GitHub Mobile.
- Use Copilot on the command line - See Using GitHub Copilot in the command line.
- Configure Copilot in your editor - You can enable or disable GitHub Copilot from within your editor, and create your own preferred keyboard shortcuts for Copilot. See Configuring GitHub Copilot in your environment.