- Installing the JetBrains extension
- Seeing your first suggestion
- Choosing alternate suggestions
- Getting more suggestions
- Generating code from a comment
- More examples
- Keyboard shortcuts
- Enabling or disabling GitHub Copilot
- Learn More
-
We have tested with the following JetBrains IDEs: IntelliJ and PyCharm versions 2021.2 and above.
-
From the JetBrains marketplace, search for 'github copilot'. (You must include the 'github' to avoid other plug-ins with similar names.)
-
Click the 'Install' button.
-
Accept the Third-Party Plugins Privacy Notice.
-
Exit and restart the IDE.
-
In the Tools menu you will now see a GitHub Copilot option.
-
Login to GitHub Copilot using the device auth flow and authorized GitHub Copilot IntelliJ plugin with your GitHub Account in an external browser.
-
Read and agree to the GitHub Copilot additional telemetry terms.
-
Click
OK
.Now when you start editing, you should see GitHub Copilot suggestions.
If you receive the following message, you have not yet been added to the GitHub Copilot Technical Preview.
The Technical Preview is open to a limited number of testers. To join the waitlist, visit copilot.github.com.
Having problems installing? Visit the Feedback forum.
GitHub Copilot provides code suggestions for dozens of languages and a wide variety of frameworks, but it works especially well for Python, JavaScript, TypeScript, Ruby, Java, and Go. The following samples are in Java, but other languages will work similarly.
-
Create a new Java (.java) file.
-
Create a class by typing
class Test
Copilot will suggest a class body.
Press
tab
to accept the suggestion. -
Below the bracket of the
main
function, type the following function header:int calculateDaysBetweenDates(
-
GitHub Copilot will automatically suggest an entire function body in grayed text, as shown below. The exact suggestion may vary.
-
Press
Tab
to accept the suggestion.
GitHub Copilot will attempt to match your code's context and style. You can edit the suggested code as you choose.
For any given input, GitHub Copilot can provide multiple suggestions. As the developer you are always in charge; you can select which suggestion to use, or reject them all.
-
Remove the function you entered and type the following again:
int calculateDaysBetweenDates(
-
GitHub Copilot will again show you a suggested completion.
-
Instead of pressing
Tab
:- On macOS, press
Option
+]
for next orOption
+[
for previous. - On Windows or Linux, press
Alt
+]
for next orAlt
+[
for previous.
GitHub Copilot will cycle through other alternative suggestions.
- On macOS, press
-
When you see a suggestion you like, press
Tab
to accept it. -
If you don't like any of the suggestions, press
Esc
.
Sometimes, you may not want to use any of the initial suggestions. You can ask GitHub Copilot to return more.
-
Remove the function you entered and type the following again:
int calculateDaysBetweenDates(
-
GitHub Copilot will again show you a suggested completion.
-
Open GitHub Copilot.
- On macOS, press
Option
+Enter
. - On Windows or Linux, press
Alt
+Enter
.
Select "Open Copilot". GitHub Copilot will open a new tab and suggest multiple options, as shown below.
- On macOS, press
-
Pick a suggestion that you want to use, then click "Accept solution."
-
If you don't like any of the returned suggestions, just close the suggestions tab.
GitHub Copilot can understand significantly more context than most code assistants, and can generate entire functions from something as simple as a comment.
-
Remove the function you entered and type the following:
// find all images without alternate text // and give them a red border void process() {
-
GitHub Copilot will automatically suggest an implementation:
GitHub Copilot has even more capabilities. Check out the examples on copilot.github.com to see more, or the Gallery in this repository for the latest examples from us and the community.
Got an example of your own? We welcome you to share it on our Feedback forum.
The following lists the most common keyboard shortcuts relevant for GitHub Copilot. If you wish to rebind them, check out the configuration guide.
-
Accept an inline suggestion:
Tab
. -
Dismiss an inline suggestion:
Esc
. -
Show next inline suggestion:
Alt + ]
orOption + ]
. -
Show previous inline suggestion:
Alt + [
orOption + [
. -
Trigger inline suggestion:
Alt + \
orOption + \
. -
Open Copilot (up to 10 suggestions in separate pane):
Alt + Enter
orOption + Enter
then pick "Open Copilot".
There's a setting to turn on or off the automatic completions. You can find the setting at Preferences... > Languages & Frameworks > GitHub Copilot
.
You can also logout (or login) from Copilot from the Tools
/GitHub Copilot
menu.
To learn more about configuring GitHub Copilot, go to the documentation table of contents.