24 KiB
title | shortTitle | intro | product | redirect_from | versions | defaultTool | topics | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Getting started with GitHub Copilot | Getting started | You can start using {% data variables.product.prodname_copilot %} by installing the extension in your preferred environment. | {% data reusables.gated-features.copilot %} |
|
|
vscode |
|
{% data reusables.copilot.copilot-cta-button %}
{% jetbrains %}
About {% data variables.product.prodname_copilot %} and JetBrains IDEs
{% data reusables.copilot.procedural-intro %}
If you use a JetBrains IDE, you can view and incorporate suggestions from {% data variables.product.prodname_copilot %} directly within the editor. This guide demonstrates how to use {% data variables.product.prodname_copilot %} within a JetBrains IDE for macOS, Windows, or Linux.
Prerequisites
{% data reusables.copilot.subscription-prerequisite %}
-
To use {% data variables.product.prodname_copilot %} in JetBrains, you must have a compatible JetBrains IDE installed. {% data variables.product.prodname_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
- MPS
- PhpStorm
- PyCharm (Professional, Community, Educational)
- Rider
- RubyMine
- RustRover
- WebStorm
For more information, see the JetBrains IDEs tool finder.
Installing the {% data variables.product.prodname_copilot %} extension in your JetBrains IDE
To use {% data variables.product.prodname_copilot %} in a JetBrains IDE, you must install the {% data variables.product.prodname_copilot %} extension. The following procedure will guide you through installation of the {% data variables.product.prodname_copilot %} plugin in IntelliJ IDEA. Steps to install the plugin in another supported IDE may differ.
-
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.
-
In the left-side menu of the Settings/Preferences dialog box, click Plugins.
-
At the top of the Settings/Preferences dialog box, click Marketplace. In the search bar, search for {% data variables.product.prodname_copilot %}, then click Install.
-
After {% data variables.product.prodname_copilot %} is installed, click Restart IDE.
-
After your JetBrains IDE has restarted, click the Tools menu. Click {% data variables.product.prodname_copilot %}, then click Login to {% data variables.product.prodname_dotcom %}.
-
In the "Sign in to {% data variables.product.prodname_dotcom %}" dialog box, to copy the device code and open the device activation window, click Copy and Open.
-
A device activation window will open in your browser. Paste the device code, then click Continue.
-
{% data variables.product.prodname_dotcom %} will request the necessary permissions for {% data variables.product.prodname_copilot %}. To approve these permissions, click Authorize {% data variables.product.prodname_copilot %} Plugin.
-
After the permissions have been approved, your JetBrains IDE will show a confirmation. To begin using {% data variables.product.prodname_copilot %}, click OK.
Seeing your first suggestion
{% data reusables.copilot.code-examples-limitations %}
{% data reusables.copilot.supported-languages %} The following samples are in Java, but other languages will work similarly.
{% data reusables.copilot.create-java-file %}
- In the Java file, create a class by typing
class Test
. {% data variables.product.prodname_copilot %} will automatically suggest a class body in grayed text. The exact suggestion may vary. {% data reusables.copilot.accept-suggestion %} - To prompt {% data variables.product.prodname_copilot %} to suggest a function body, type the following line below the bracket of the
main
function. The exact suggestion may vary. {% indented_data_reference reusables.copilot.java-int-snippet spaces=3 %} {% data reusables.copilot.accept-suggestion %}
{% data variables.product.prodname_copilot %} will attempt to match the context and style of your code. You can always edit the suggested code.
Seeing alternative suggestions
{% data reusables.copilot.alternative-suggestions %}
{% data reusables.copilot.create-java-file %}
- To prompt {% data variables.product.prodname_copilot %} to show you a suggestion, type the following line in the Java file.
{% indented_data_reference reusables.copilot.java-int-snippet spaces=3 %}
{% data reusables.copilot.see-alternative-suggestions %}
OS See next suggestion See previous suggestion macOS Option+] Option+[ Windows Alt+] Alt+[ Linux Alt+] Alt+[ {% data reusables.copilot.accept-or-reject-suggestion %}
Seeing multiple suggestions in a new tab
{% data reusables.copilot.suggestions-new-tab %}
{% data reusables.copilot.create-java-file %}
-
To prompt {% data variables.product.prodname_copilot %} to show you a suggestion, type the following line in the Java file. {% indented_data_reference reusables.copilot.java-int-snippet spaces=3 %}
-
Open a new tab with multiple additional suggestions.
- On macOS, press Command+Shift+A, then click Open GitHub Copilot, or press Command+Shift+</kbd> to open the new tab immediately.
- On Windows or Linux, press Ctrl+Enter, then click Open GitHub Copilot.
-
To accept a suggestion, above the suggestion, click Accept Solution. To reject all suggestions, close the tab.
Generating code suggestions from comments
{% data reusables.copilot.generating-suggestions-from-comments %}
{% data reusables.copilot.create-java-file %}
-
To prompt {% data variables.product.prodname_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 {% data variables.product.prodname_copilot %}
You can enable or disable {% data variables.product.prodname_copilot %} for all languages, or for individual languages. The {% data variables.product.prodname_copilot %} status icon in the bottom panel of your JetBrains IDE window indicates whether {% data variables.product.prodname_copilot %} is enabled or disabled. When enabled, the icon is highlighted. When disabled, the icon is grayed out.
-
To enable or disable {% data variables.product.prodname_copilot %}, click the status icon in the bottom panel of the JetBrains window.
-
If you are disabling {% data variables.product.prodname_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 {% data variables.product.prodname_copilot %} globally, click Disable Completions.
- To disable suggestions from {% data variables.product.prodname_copilot %} for the specified language, click Disable Completions for LANGUAGE.
Further reading
- The {% data variables.product.prodname_copilot %} website
- About {% data variables.product.prodname_copilot_for_individuals %}
{% endjetbrains %}
{% visualstudio %}
About {% data variables.product.prodname_copilot %} and {% data variables.product.prodname_vs %}
{% data reusables.copilot.procedural-intro %}
If you use {% data variables.product.prodname_vs %}, you can view and incorporate suggestions from {% data variables.product.prodname_copilot %} directly within the editor. This guide demonstrates how to use {% data variables.product.prodname_copilot %} within {% data variables.product.prodname_vs %} for Windows.
Prerequisites
{% data reusables.copilot.subscription-prerequisite %}
- To use {% data variables.product.prodname_copilot %} in {% data variables.product.prodname_vs %}, you must have {% data variables.product.prodname_vs %} 2022 17.6 or later installed. For more information, see the Visual Studio IDE documentation.
{% data reusables.copilot.vs-for-mac-note %}
Installing the {% data variables.product.prodname_vs %} extension
To use {% data variables.product.prodname_copilot %}, you must first install the {% data variables.product.prodname_vs %} extension.
{% data reusables.copilot.vs-extensions %}
-
In the "Manage Extensions" window, click Visual Studio Marketplace, search for the {% data variables.product.prodname_copilot %} extension, then click Download.
-
Optionally, to check that {% data variables.product.prodname_copilot %} is installed and enabled, go back to Manage Extensions, click Installed to view your currently installed extensions, then click {% data variables.product.prodname_copilot %} to see status information.
-
Open or create a new project in {% data variables.product.prodname_vs %}.
-
In the "Microsoft {% data variables.product.prodname_vs %}" dialog box, to copy your device activation code, click OK.
-
A device activation window will open in your browser. Paste the device code, then click Continue.
-
{% data variables.product.prodname_dotcom %} will request the necessary permissions for {% data variables.product.prodname_copilot %}. To approve these permissions, click Authorize {% data variables.product.prodname_copilot %} Plugin.
-
After you approve the permissions, {% data variables.product.prodname_vs %} will show a confirmation.
Seeing your first suggestion
{% data reusables.copilot.code-examples-limitations %} {% data reusables.copilot.supported-languages %} The following samples are in C#, but other languages will work similarly.
{% data reusables.copilot.create-c-file %}
-
In the C# file, type the following function signature. {% data variables.product.prodname_copilot %} will automatically suggest an entire function body in grayed text, as shown below. The exact suggestion may vary.
int CalculateDaysBetweenDates(
{% data reusables.copilot.accept-suggestion %}
Seeing alternative suggestions
{% data reusables.copilot.alternative-suggestions %} {% data reusables.copilot.create-c-file %}
-
In the C# file, type the following function signature. {% data variables.product.prodname_copilot %} will show you a suggestion.
int CalculateDaysBetweenDates(
-
If alternative suggestions are available, you can see these alternatives by pressing Alt+. (or Alt+,).
-
Optionally, you can hover over the suggestion to see the {% data variables.product.prodname_copilot %} command palette for choosing suggestions. {% data reusables.copilot.accept-or-reject-suggestion %}
Generating code suggestions from comments
{% data reusables.copilot.generating-suggestions-from-comments %}
{% data reusables.copilot.create-c-file %}
-
In the C# file, type the following comment. {% data variables.product.prodname_copilot %} will suggest an implementation of the function.
using System.Xml.Linq; var doc = XDocument.Load("index.xhml"); // find all images
{% data reusables.copilot.accept-suggestion %}
{% data reusables.copilot.enabling-or-disabling-vs %}
{% endvisualstudio %}
{% vscode %}
About {% data variables.product.prodname_copilot %} and {% data variables.product.prodname_vscode %}
{% data reusables.copilot.procedural-intro %}
If you use {% data variables.product.prodname_vscode %}, you can view and incorporate suggestions from {% data variables.product.prodname_copilot %} directly within the editor. This guide demonstrates how to use {% data variables.product.prodname_copilot %} within {% data variables.product.prodname_vscode %} for macOS, Windows, or Linux.
Prerequisites
{% data reusables.copilot.subscription-prerequisite %}
- To use {% data variables.product.prodname_copilot %} in {% data variables.product.prodname_vscode %}, you must have {% data variables.product.prodname_vscode %} installed. For more information, see the {% data variables.product.prodname_vscode %} download page.
Installing the {% data variables.product.prodname_vscode %} extension
To use {% data variables.product.prodname_copilot %}, you must first install the {% data variables.product.prodname_vscode %} extension.
-
In the {% data variables.product.prodname_vscode_marketplace %}, go to the {% data variables.product.prodname_copilot %} extension page and click Install.
-
A popup will appear, asking to open {% data variables.product.prodname_vscode %}. Click Open {% data variables.product.prodname_vscode %}.
-
In the "Extension: {% data variables.product.prodname_copilot %}" tab in {% data variables.product.prodname_vscode %}, click Install.
-
If you have not previously authorized {% data variables.product.prodname_vscode %} in your {% data variables.product.prodname_dotcom %} account, you will be prompted to sign in to {% data variables.product.prodname_dotcom %} in {% data variables.product.prodname_vscode %}.
-
If you have previously authorized {% data variables.product.prodname_vscode %} for your account on {% data variables.product.prodname_dotcom %}, {% data variables.product.prodname_copilot %} will be automatically authorized.
-
If you don't get the prompt to authorize, click the bell icon in the bottom panel of the {% data variables.product.prodname_vscode %} window.
-
-
In your browser, {% data variables.product.prodname_dotcom %} will request the necessary permissions for {% data variables.product.prodname_copilot %}. To approve these permissions, click Authorize {% data variables.product.prodname_vscode %}.
-
To confirm the authentication, in {% data variables.product.prodname_vscode %}, in the "{% data variables.product.prodname_vscode %}" dialog box, click Open.
Seeing your first suggestion
{% data reusables.copilot.code-examples-limitations %}
{% data reusables.copilot.supported-languages %} The following samples are in JavaScript, but other languages will work similarly.
{% data reusables.copilot.create-js-file %}
-
In the JavaScript file, type the following function header. {% data variables.product.prodname_copilot %} will automatically suggest an entire function body in grayed text, as shown below. The exact suggestion may vary.
function calculateDaysBetweenDates(begin, end) {
{% data reusables.copilot.accept-suggestion %}
Seeing alternative suggestions
{% data reusables.copilot.alternative-suggestions %}
{% data reusables.copilot.create-js-file %}
-
In the JavaScript file, type the following function header. {% data variables.product.prodname_copilot %} will show you a suggestion.
function calculateDaysBetweenDates(begin, end) {
{% data reusables.copilot.see-alternative-suggestions %}
OS | See next suggestion | See previous suggestion |
---|---|---|
macOS | Option (⌥) or Alt+] | Option (⌥) or Alt+[ |
Windows | Alt+] | Alt+[ |
Linux | Alt+] | Alt+[ |
- Alternatively, you can hover over the suggestion to see the {% data variables.product.prodname_copilot %} command palette for choosing suggestions. {% data reusables.copilot.accept-or-reject-suggestion %}
Seeing multiple suggestions in a new tab
{% data reusables.copilot.suggestions-new-tab %}
{% data reusables.copilot.create-js-file %}
-
In the JavaScript file, type the following function header. {% data variables.product.prodname_copilot %} will show you a suggestion.
function calculateDaysBetweenDates(begin, end) {
-
To open a new tab with multiple additional options, press Ctrl+Enter.
-
To accept a suggestion, above the suggestion, click Accept Solution. To reject all suggestions, close the tab.
Generating code suggestions from comments
{% data reusables.copilot.generating-suggestions-from-comments %}
{% data reusables.copilot.create-js-file %}
-
In the JavaScript file, type the following comment. {% data variables.product.prodname_copilot %} will suggest an implementation of the function.
// find all images without alternate text // and give them a red border function process() {
Using a framework
You can also use {% data variables.product.prodname_copilot %} to generate suggestions for APIs and frameworks. The following example uses {% data variables.product.prodname_copilot %} to create a simple Express server that returns the current time.
{% data reusables.copilot.create-js-file %}
-
In the JavaScript file, type the following comment and then press Enter. {% data variables.product.prodname_copilot %} will suggest an implementation of the Express app.
// Express server on port 3000
-
To accept each line, press Tab, then Enter.
-
Type the following comment and then press Enter. {% data variables.product.prodname_copilot %} will suggest an implementation for the default handler.
// Return the current time
-
To accept each line, press Tab.
{% data reusables.copilot.enabling-or-disabling-in-vsc %}
{% endvscode %}
{% vimneovim %}
About {% data variables.product.prodname_copilot %} and Vim/Neovim
{% data reusables.copilot.procedural-intro %}
If you use Vim/Neovim, you can view and incorporate suggestions from {% data variables.product.prodname_copilot %} directly within the editor.
Prerequisites
{% data reusables.copilot.subscription-prerequisite %}
- To use {% data variables.product.prodname_copilot %} in Vim/Neovim you must have Vim version 9.0.0185 / Neovim version 0.6 or above and Node.js version 17 or below installed. For more information, see the Vim / Neovim documentation and the Node.js website.
Installing the Vim/Neovim extension on macOS
{% data reusables.copilot.install-copilot-in-vimneovim %}
-
To install {% data variables.product.prodname_copilot %} with Vim's built-in plugin manager, enter the following command in Terminal:
git clone https://github.com/github/copilot.vim \ ~/.vim/pack/github/start/copilot.vim
-
To install {% data variables.product.prodname_copilot %} with Neovim's built-in plugin manager, enter the following command in Terminal:
git clone https://github.com/github/copilot.vim \ ~/.config/nvim/pack/github/start/copilot.vim
{% data reusables.copilot.config-enable-copilot-in-vimneovim %}
Installing the Vim/Neovim extension on Windows
{% data reusables.copilot.install-copilot-in-vimneovim %}
-
To install {% data variables.product.prodname_copilot %} with Vim's built-in plugin manager, enter the following command in Git Bash:
git clone https://github.com/github/copilot.vim.git \ $HOME/vimfiles/pack/github/start/copilot.vim
-
To install {% data variables.product.prodname_copilot %} with Neovim's built-in plugin manager, enter the following command in Git Bash:
git clone https://github.com/github/copilot.vim.git \ $HOME/AppData/Local/nvim/pack/github/start/copilot.vim
{% data reusables.copilot.config-enable-copilot-in-vimneovim %}
Installing the Vim/Neovim extension on Linux
{% data reusables.copilot.install-copilot-in-vimneovim %}
-
To install {% data variables.product.prodname_copilot %} with Vim's built-in plugin manager, enter the following command:
git clone https://github.com/github/copilot.vim \ ~/.vim/pack/github/start/copilot.vim
-
To install {% data variables.product.prodname_copilot %} with Neovim's built-in plugin manager, enter the following command:
git clone https://github.com/github/copilot.vim \ ~/.config/nvim/pack/github/start/copilot.vim
{% data reusables.copilot.config-enable-copilot-in-vimneovim %}
Learning to use {% data variables.product.prodname_copilot %} in Vim/Neovim
For guidance on using {% data variables.product.prodname_copilot %} in Vim/Neovim, you can view the plugin documentation. To see the documentation, open Vim/Neovim and run the following command:
:help copilot
{% endvimneovim %}
Next steps
{% data reusables.copilot.next-steps %}
- {% data variables.product.prodname_copilot %}: See practical examples of how {% data variables.product.prodname_copilot %} can help you work.
- AUTOTITLE: These guides provide details on how to configure {% data variables.product.prodname_copilot %} to your personal preferences.
- AUTOTITLE: Learn more about billing for {% data variables.product.prodname_copilot %}.
- AUTOTITLE: These guides provide information for troubleshooting {% data variables.product.prodname_copilot %}.