0% found this document useful (0 votes)
353 views

Getting Started With GitHub Copilot in A JetBrains IDE (Docs Github Com)

This document provides instructions for installing and using GitHub Copilot, an AI programming assistant, within JetBrains IDEs such as IntelliJ and PyCharm. It describes how to install the GitHub Copilot plugin, log in, and see code suggestions as you write comments and code in supported languages like Python, JavaScript, and Java.

Uploaded by

Owen Perrin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
353 views

Getting Started With GitHub Copilot in A JetBrains IDE (Docs Github Com)

This document provides instructions for installing and using GitHub Copilot, an AI programming assistant, within JetBrains IDEs such as IntelliJ and PyCharm. It describes how to install the GitHub Copilot plugin, log in, and see code suggestions as you write comments and code in supported languages like Python, JavaScript, and Java.

Uploaded by

Owen Perrin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

docs.github.

com
/en/copilot/getting-started-with-github-copilot/getting-started-with-github-copilot-in-a-jetbrains-ide

Getting started with GitHub Copilot in a JetBrains IDE

Learn how to install GitHub Copilot in a JetBrains IDE, and start seeing suggestions as you write
comments and code.

GitHub Copilot is available to GitHub customers with a personal account on GitHub.com and GitHub
Enterprise Cloud organizations owned by an enterprise account.

GitHub Copilot is free to use for verified students, teachers, and maintainers of popular open source
projects. If you are not a student, teacher, or maintainer of a popular open source project, you can try
GitHub Copilot for free with a one-time 60-day trial. After the free trial, you will need a paid subscription
for continued use. For more information, see "About billing for GitHub Copilot."

Try GitHub Copilot

About GitHub Copilot and JetBrains IDEs


GitHub Copilot provides autocomplete-style suggestions from an AI pair programmer as you code. For
more information, see "About GitHub Copilot".

If you use a JetBrains IDE, you can view and incorporate suggestions from GitHub Copilot directly within
the editor. This guide demonstrates how to use GitHub Copilot within a JetBrains IDE for macOS,
Windows, or Linux.

Prerequisites
To use GitHub Copilot you must have an active GitHub Copilot subscription. For more information,
see "About billing for GitHub Copilot."

To use GitHub Copilot in JetBrains, you must have a compatible JetBrains IDE installed. GitHub Copilot is
compatible with the following IDEs.

IntelliJ IDEA (Ultimate, Community, Educational)


Android Studio
AppCode
CLion
Code With Me Guest
DataGrip
DataSpell
GoLand
JetBrains Client

1/7
MPS
PhpStorm
PyCharm (Professional, Community, Educational)
Rider
RubyMine
WebStorm

For more information, see the JetBrains IDEs tool finder.

Installing the GitHub Copilot extension in your JetBrains IDE


To use GitHub Copilot in a JetBrains IDE, you must install the GitHub Copilot extension. The following
procedure will guide you through installation of the GitHub Copilot plugin in IntelliJ IDEA. Steps to install
the plugin in another supported IDE may differ.

1. In your JetBrains IDE, under the File menu for Windows or under the name of your IDE for Mac (for
example, PyCharm or IntelliJ), click Settings for Windows or Preferences for Mac.

2. In the left-side menu of the Settings/Preferences dialog box, click Plugins.

3. At the top of the Settings/Preferences dialog box, click Marketplace. In the search bar, search for
GitHub Copilot, then click Install.

4. After GitHub Copilot is installed, click Restart IDE.

2/7
5. After your JetBrains IDE has restarted, click the Tools menu. Click GitHub Copilot, then click

Login to GitHub.

6. In the "Sign in to GitHub" dialog box, to copy the device code and open the device activation
window, click Copy and Open.

7. A device activation window will open in your browser. Paste the device code, then click Continue.

To paste the code in Windows or Linux, press Ctrl+v.

3/7
To paste the code in macOS, press command+v.

8. GitHub will request the necessary permissions for GitHub Copilot. To approve these permissions,
click Authorize GitHub Copilot Plugin.

9. After the permissions have been approved, your JetBrains IDE will show a confirmation. To begin
using GitHub Copilot, click OK.

Seeing your first suggestion


GitHub Copilot provides suggestions for numerous languages and a wide variety of frameworks, but
Note:especially
works If you havewell
duplication detection
for Python, enabled
JavaScript, for GitHub
TypeScript, Copilot,
Ruby, youand
Go, C# mayC++.
receive
The limited suggestions,
following samples
or no
are suggestions,
in Java, when
but other using the
languages willcode
workexamples
similarly. provided. As an alternative, you can start by typing
your own code to see suggestions from GitHub Copilot. For more information on duplication detection,
see1."Enabling
In your JetBrains IDE,duplication
or disabling create a new Java (*.java) file.
detection."

2. In the Java file, create a class by typing class Test.


GitHub Copilot will automatically suggest a
class body in grayed text, as shown below. The exact suggestion may vary.

3. To accept the suggestion, press Tab.

4. To prompt GitHub Copilot to suggest a function body, type the following line below the bracket of
the main function. The exact suggestion may vary.

int calculateDaysBetweenDates(

4/7
5. To accept the suggestion, press Tab.

GitHub Copilot will attempt to match the context and style of your code. You can always edit the
suggested code.

Seeing alternative suggestions


For any given input, GitHub Copilot may offer multiple suggestions. You can select which suggestion to
use, or reject all suggestions.

1. In your JetBrains IDE, create a new Java (*.java) file.

2. To prompt GitHub Copilot to show you a suggestion, type the following line in the Java file.

int calculateDaysBetweenDates(

3. Optionally, you can see alternative suggestions, if any are available.

OS See next suggestion See previous suggestion


macOS Option+] Option+[
Windows Alt+] Alt+[
Linux Alt+] Alt+[

4. To accept a suggestion, press Tab. To reject all suggestions, press Esc.

Seeing multiple suggestions in a new tab


You may not want any of the initial suggestions GitHub Copilot offers. You can use a keyboard shortcut to
prompt GitHub Copilot to show you multiple suggestions in a new tab.

1. In your JetBrains IDE, create a new Java (*.java) file.


2. To prompt GitHub Copilot to show you a suggestion, type the following line in the Java file.

int calculateDaysBetweenDates(

3. Open a new tab with multiple additional suggestions.


On macOS, press Command+Shift+A, then click Open GitHub Copilot, or press
Command+Shift+\ to open the new tab immediately.

5/7
On Windows or Linux, press Ctrl+Enter, then click Open GitHub Copilot.

4. To accept a suggestion, above the suggestion, click Accept Solution. To reject all suggestions,
close the tab.

Generating code suggestions from comments


You can describe something you want to do using natural language within a comment, and GitHub
Copilot will suggest the code to accomplish your goal.

1. In your JetBrains IDE, create a new Java (*.java) file.


2. To prompt GitHub Copilot to suggest an implementation of a function in the Java file, type the
following lines.

// find all images without alternate text

// and give them a red border

void process () {

Enabling and disabling GitHub Copilot


You can enable or disable GitHub Copilot for all languages, or for individual languages. The GitHub
Copilot status icon in the bottom panel of your JetBrains IDE window indicates whether GitHub Copilot is

6/7
enabled or disabled. When enabled, the icon is highlighted. When disabled, the icon is grayed out.

1. To enable or disable GitHub Copilot, click the status icon in the bottom panel of the JetBrains
window.

2. If you are disabling GitHub Copilot, you will be asked whether you want to disable it globally, or for
the language of the file you are currently editing.

To disable suggestions from GitHub Copilot globally, click Disable Completions.


To disable suggestions from GitHub Copilot for the specified language, click Disable
Completions for LANGUAGE.

Further reading

7/7

You might also like