Skip to main content

Getting code suggestions in your IDE with GitHub Copilot

Use GitHub Copilot to get code suggestions in your editor.

Start a free trial

About GitHub Copilot and JetBrains IDEs

This guide demonstrates how to get coding suggestions from GitHub Copilot in a JetBrains IDE. To see instructions for other popular coding environments, use the tool switcher at the top of the page.

The examples in this guide use Java, however other languages will work similarly. GitHub Copilot fournit des suggestions pour de nombreux langages et un large éventail d’infrastructures, mais fonctionnent particulièrement bien pour Python, JavaScript, TypeScript, Ruby, Go, C# et C++. GitHub Copilot peut également aider à générer des requêtes pour les bases de données ou des suggestions pour les API et cadres. Il peut aider aussi au développement d’une infrastructure en tant que code.

Prerequisites

  • Subscription to Copilot. To use GitHub Copilot in JetBrains, you must have an active GitHub Copilot subscription. Pour plus d'informations sur l'obtention de l’accès à Copilot, consultez « About GitHub Copilot ».

  • Compatible JetBrains IDE. 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
    • MPS
    • PhpStorm
    • PyCharm (Professional, Community, Educational)
    • Rider
    • RubyMine
    • RustRover
    • WebStorm

    Consultez le l’outil de recherche pour trouver les IDE JetBrains à télécharger.

  • Plug-in GitHub Copilot. Consultez le plug-in GitHub Copilot dans la place de marché JetBrains. Pour obtenir des instructions d’installation, consultez « Installation de l’extension GitHub Copilot dans votre environnement ».

  • Connectez-vous à GitHub dans votre IDE JetBrains. Pour obtenir des instructions d’authentification, consultez « Installation de l’extension GitHub Copilot dans votre environnement ».

Getting code suggestions

GitHub Copilot offers coding suggestions as you type. For example, in a Java file, create a class by typing class Test.

GitHub Copilot will automatically suggest a class body in grayed text. Pour accepter la suggestion, appuyez sur Tab.

You can also describe something you want to do using natural language within a comment, and Copilot will suggest the code to accomplish your goal. For example, type this comment in a Java file:

Java
// find all images without alternate text
// and give them a red border
void process () {

GitHub Copilot will automatically suggest code. Pour accepter la suggestion, appuyez sur Tab.

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

Tip

If you receive limited or no suggestions from Copilot, you may have duplication detection enabled. For more information about duplication detection, see "Gestion des stratégies de Copilot en tant qu’abonné individuel."

Showing alternative suggestions

Pour n’importe quelle entrée donnée, GitHub Copilot peut proposer plusieurs suggestions. Vous pouvez sélectionner la suggestion à utiliser ou rejeter toutes les suggestions.

For example, type the following line in a Java file, and press Enter:

Java
private int calculateDaysBetweenDates(Date date1,

GitHub Copilot will show you a suggestion.

Now hover over the suggestion to show the GitHub Copilot control for choosing suggestions. To display next or previous suggestions, click the forward or back arrow button in the control.

You can also use keyboard shortcuts to show alternative suggestions:

OSSee next suggestionSee previous suggestion
macOSOption+]Option+[
Windows or LinuxAlt+]Alt+[

Pour accepter une suggestion, cliquez sur « Accepter » dans la palette de commandes Copilot ou appuyez sur Tab. Pour rejeter toutes les suggestions, appuyez sur Échap.

Showing multiple suggestions in a new tab

Si vous ne souhaitez pas utiliser les suggestions initiales proposées par GitHub Copilot, vous pouvez afficher plus de suggestions dans un nouvel onglet.

For example, type the following line in a Java file:

Java
private int calculateDaysBetweenDates(Date date1,

GitHub Copilot will show you a suggestion.

To open a new tab with multiple additional suggestions, use the following keyboard shortcut, then click Open GitHub Copilot:

OSOpen multiple suggestions
macOSCommand+Shift+A
Windows or LinuxCtrl+Enter

To accept a suggestion, below the suggestion, click Accept suggestion NUMBER. To reject all suggestions, close the tab.

Accepting partial suggestions

If you don't want to accept an entire suggestion from GitHub Copilot, you can accept the next word or the next line of a suggestion.

For example, type the following line in a Java file:

Java
private int calculateDaysBetweenDates(Date date1,

GitHub Copilot will show a suggestion in grayed text. The exact suggestion may vary.

Now hover over the suggestion to show the GitHub Copilot control for choosing suggestions. To accept only the next word of the suggestion, click Accept Word in the control.

Alternatively, you can use a keyboard shortcut to accept the next word of a suggestion:

OSAccept Next WordAccept Next Line
macOSCommand+Command+Control+
Windows or LinuxControl+Control+Alt+

If you want to accept the next line of a suggestion, you will need to set a custom keyboard shortcut for the command editor.action.inlineSuggest.acceptNextLine. For more information on setting custom keyboard shortcuts, see "Configuration de GitHub Copilot dans votre environnement."

About GitHub Copilot and Visual Studio

This guide demonstrates how to get coding suggestions from GitHub Copilot in Visual Studio for Windows. To see instructions for other popular coding environments, use the tool switcher at the top of the page.

The examples in this guide use C#, however other languages will work similarly. GitHub Copilot fournit des suggestions pour de nombreux langages et un large éventail d’infrastructures, mais fonctionnent particulièrement bien pour Python, JavaScript, TypeScript, Ruby, Go, C# et C++. GitHub Copilot peut également aider à générer des requêtes pour les bases de données ou des suggestions pour les API et cadres. Il peut aider aussi au développement d’une infrastructure en tant que code.

Prerequisites

  • Subscription to Copilot. To use GitHub Copilot in Visual Studio, you must have an active GitHub Copilot subscription. Pour plus d'informations sur l'obtention de l’accès à Copilot, consultez « About GitHub Copilot ».

  • Version compatible de Visual Studio. Pour utiliser GitHub Copilot dans Visual Studio, vous devez avoir installé la version 2022 17.8 ou ultérieure de Visual Studio pour Windows. Pour plus d’informations, consultez « Installer Visual Studio » dans la documentation Microsoft.

  • Extension GitHub Copilot pour Visual Studio. Pour obtenir des instructions sur l’installation de l’extension Copilot, consultez « Installer GitHub Copilot dans Visual Studio » dans la documentation Microsoft.

  • Ajoutez votre compte GitHub à Visual Studio. Consultez Ajouter vos comptes GitHub à votre trousseau Visual Studio dans la documentation Microsoft.

Getting code suggestions

GitHub Copilot offers coding suggestions as you type. For example, type this function signature in a C# file:

C#
int CalculateDaysBetweenDates(

GitHub Copilot will automatically suggest an entire function body in grayed text. Pour accepter la suggestion, appuyez sur Tab.

You can also describe something you want to do using natural language within a comment, and Copilot will suggest the code to accomplish your goal. For example, type this comment in the C# file:

C#
using System.Xml.Linq;

var doc = XDocument.Load("index.xhml");

// find all images

GitHub Copilot will suggest an implementation of the function. Pour accepter la suggestion, appuyez sur Tab.

Tip

If you receive limited or no suggestions from Copilot, you may have duplication detection enabled. For more information about duplication detection, see "Gestion des stratégies de Copilot en tant qu’abonné individuel."

Showing alternative suggestions

Pour n’importe quelle entrée donnée, GitHub Copilot peut proposer plusieurs suggestions. Vous pouvez sélectionner la suggestion à utiliser ou rejeter toutes les suggestions.

For example, type this function signature in a C# file:

C#
int CalculateDaysBetweenDates(

GitHub Copilot will show you a suggestion.

Now hover over the suggestion to show the GitHub Copilot control for choosing suggestions. To display next or previous suggestions, click the forward or back arrow button in the control.

Alternatively, you can show alternate suggestions by pressing Alt+. (or Alt+,) on your keyboard.

Pour accepter une suggestion, cliquez sur « Accepter » dans la palette de commandes Copilot ou appuyez sur Tab. Pour rejeter toutes les suggestions, appuyez sur Échap.

About GitHub Copilot and Visual Studio Code

This guide demonstrates how to get coding suggestions from GitHub Copilot in Visual Studio Code. To see instructions for other popular coding environments, use the tool switcher at the top of the page.

The examples in this guide use JavaScript, however other languages will work similarly. GitHub Copilot fournit des suggestions pour de nombreux langages et un large éventail d’infrastructures, mais fonctionnent particulièrement bien pour Python, JavaScript, TypeScript, Ruby, Go, C# et C++. GitHub Copilot peut également aider à générer des requêtes pour les bases de données ou des suggestions pour les API et cadres. Il peut aider aussi au développement d’une infrastructure en tant que code.

Prerequisites

  • Subscription to Copilot. To use GitHub Copilot in Visual Studio Code, you must have an active GitHub Copilot subscription. Pour plus d'informations sur l'obtention de l’accès à Copilot, consultez « About GitHub Copilot ».

  • Visual Studio Code. To use GitHub Copilot in Visual Studio Code, you must have Visual Studio Code installed. For more information, see the Visual Studio Code download page.

  • Copilot extension for Visual Studio Code. To use GitHub Copilot in Visual Studio Code, you must install the GitHub Copilot extension. For more information, see "Set up GitHub Copilot in Visual Studio Code" in the Visual Studio Code documentation.

Getting code suggestions

GitHub Copilot offers coding suggestions as you type. For example, type this function header in a JavaScript file:

JavaScript
function calculateDaysBetweenDates(begin, end) {

GitHub Copilot will automatically suggest the rest of the function. Pour accepter la suggestion, appuyez sur Tab.

You can also describe something you want to do using natural language within a comment, and Copilot will suggest the code to accomplish your goal. For example, type this comment in a JavaScript file:

JavaScript
// write a function to
// find all images without alternate text
// and give them a red border

GitHub Copilot will automatically suggest code. Pour accepter la suggestion, appuyez sur Tab.

Tip

If you receive limited or no suggestions from Copilot, you may have duplication detection enabled. For more information about duplication detection, see "Gestion des stratégies de Copilot en tant qu’abonné individuel."

Showing alternative suggestions

Pour n’importe quelle entrée donnée, GitHub Copilot peut proposer plusieurs suggestions. Vous pouvez sélectionner la suggestion à utiliser ou rejeter toutes les suggestions.

For example, type this function header in a JavaScript file, and press Enter:

JavaScript
function calculateDaysBetweenDates(begin, end) {

GitHub Copilot will show you a suggestion.

Now hover over the suggestion to show the GitHub Copilot control for choosing suggestions. To display next or previous suggestions, click the forward or back arrow button in the control.

You can also use keyboard shortcuts to show alternative suggestions:

OSSee next suggestionSee previous suggestion
macOSOption (⌥) or Alt+]Option (⌥) or Alt+[
Windows or LinuxAlt+]Alt+[

Pour accepter une suggestion, cliquez sur « Accepter » dans la palette de commandes Copilot ou appuyez sur Tab. Pour rejeter toutes les suggestions, appuyez sur Échap.

Showing multiple suggestions in a new tab

Si vous ne souhaitez pas utiliser les suggestions initiales proposées par GitHub Copilot, vous pouvez afficher plus de suggestions dans un nouvel onglet.

For example, type this function header in a JavaScript file, and press Enter:

JavaScript
function calculateDaysBetweenDates(begin, end) {

GitHub Copilot will show you a suggestion. Now press Ctrl+Enter to open a new tab with multiple additional options.

To accept a suggestion, below the suggestion, click Accept suggestion NUMBER. To reject all suggestions, close the tab.

Accepting partial suggestions

If you don't want to accept an entire suggestion from GitHub Copilot, you can accept the next word or the next line of a suggestion.

For example, type this function header in a JavaScript file, and press Enter:

JavaScript
function calculateDaysBetweenDates(begin, end) {

GitHub Copilot will automatically suggest an entire function body in grayed text. The exact suggestion may vary.

Now hover over the suggestion to show the GitHub Copilot control for choosing suggestions. To accept only the next word of the suggestion, click Accept Word in the control.

Alternatively, you can use a keyboard shortcut to accept the next word of a suggestion:

OSAccept Next Word
macOSCommand+
Windows or LinuxControl+

If you want to accept the next line of a suggestion, you will need to set a custom keyboard shortcut for the command editor.action.inlineSuggest.acceptNextLine. For more information on setting custom keyboard shortcuts, see "Configuration de GitHub Copilot dans votre environnement."

About GitHub Copilot and Vim/Neovim

This guide demonstrates how to get coding suggestions from GitHub Copilot in Vim/Neovim. To see instructions for other popular coding environments, use the tool switcher at the top of the page.

Prerequisites

  • Subscription to Copilot. To use GitHub Copilot in Vim/Neovim, you must have an active GitHub Copilot subscription. Pour plus d'informations sur l'obtention de l’accès à Copilot, consultez « About GitHub Copilot ».

  • Compatible version of Vim/Neovim. To use GitHub Copilot in Vim/Neovim you must have Vim version 9.0.0185 / Neovim version 0.6 or above and Node.js version 18 or above installed. For more information, see the Vim / Neovim documentation and the Node.js website.

  • GitHub Copilot extension for Vim/Neovim. To use GitHub Copilot in Vim/Neovim, you must install the GitHub Copilot plugin. For more information, see "Installation de l’extension GitHub Copilot dans votre environnement."

Learning to use GitHub Copilot in Vim/Neovim

GitHub Copilot provides suggestions inline as you type in Vim/Neovim. To accept a suggestion, press the tab key.

For more information and guidance on using GitHub Copilot in Vim/Neovim run the following command to view the plugin documentation:

Shell
:help copilot

About GitHub Copilot and Azure Data Studio

This guide demonstrates how to get coding suggestions from GitHub Copilot in Azure Data Studio. To see instructions for other popular coding environments, use the tool switcher at the top of the page.

Prerequisites

  • Subscription to Copilot. To use GitHub Copilot in Azure Data Studio, you must have an active GitHub Copilot subscription. Pour plus d'informations sur l'obtention de l’accès à Copilot, consultez « About GitHub Copilot ».

  • Compatible version of Azure Data Studio. To use GitHub Copilot in Azure Data Studio, you must have Azure Data Studio version 1.44.0 or later installed. For more information, see the Azure Data Studio download page in the Azure Data Studio documentation.

  • GitHub Copilot extension for Azure Data Studio. To use GitHub Copilot in Azure Data Studio, you must install the GitHub Copilot extension. For more information, see "Installation de l’extension GitHub Copilot dans votre environnement."

Getting code suggestions

GitHub Copilot can provide you with inline suggestions as you create SQL databases in Azure Data Studio. For example, if you're writing a query that joins two tables, Copilot may suggest the join condition from columns in the open editor, other files in the workspace, and common syntax patterns.

In a SQL file, type the following query:

SQL
SELECT [UserId], [Red], [Orange], [Yellow], [Green], [Blue], [Purple], [Rainbow]
FROM [Tag].[Scoreboard]
INNER JOIN

GitHub Copilot will automatically suggest a join condition in grayed text. The exact suggestion may vary. Pour accepter la suggestion, appuyez sur Tab.

You can also describe something you want to do using natural language within a comment, and Copilot will suggest the code to accomplish your goal. For example, type this comment in a SQL file:

SQL
SELECT TokenColor, COUNT(UserID) AS UserCount
FROM Tag.Users
GROUP BY TokenColor
-- pivot that query on tokencolor for Purple, Blue, Green, Yellow, Orange, Red
-- and rename the columns to match the colors
SELECT [Purple], [Blue], [Green], [Yellow], [Orange], [Red]

GitHub Copilot will automatically suggest code. Pour accepter la suggestion, appuyez sur Tab.

Tip

If you receive limited or no suggestions from Copilot, you may have duplication detection enabled. For more information on duplication detection, see "Gestion des stratégies de Copilot en tant qu’abonné individuel."

Showing alternative suggestions

For some suggestions, GitHub Copilot may provide multiple alternatives. You can select which suggestion you want to use, or reject all suggestions.

For example, type this query in a SQL file:

SQL
SELECT [UserId], [Red], [Orange], [Yellow], [Green], [Blue], [Purple], [Rainbow]
FROM [Tag].[Scoreboard]
INNER JOIN

GitHub Copilot will show you a suggestion.

Now hover over the suggestion to show the GitHub Copilot control for choosing suggestions. To display next or previous suggestions, click the forward or back arrow button in the control.

You can also use keyboard shortcuts to show alternative suggestions:

OSSee next suggestionSee previous suggestion
macOSOption+[Option+]
Windows or LinuxAlt+[Alt+]

To accept a suggestion, click "Accept" in the Copilot control, or press Tab. To reject all suggestions, press Esc.

Accepting partial suggestions

If you don't want to accept an entire suggestion from GitHub Copilot, you can accept the next word or the next line of a suggestion.

For example, type this query in a SQL file:

SQL
SELECT [UserId], [Red], [Orange], [Yellow], [Green], [Blue], [Purple], [Rainbow]
FROM [Tag].[Scoreboard]
INNER JOIN

GitHub Copilot will show you a suggestion in grayed text. The exact suggestion may vary.

Now hover over the suggestion to show the GitHub Copilot control for choosing suggestions. To accept only the next word of the suggestion, click Accept Word in the control.

Alternatively, you can use a keyboard shortcut to accept the next word of a suggestion:

OSAccept Next Word
macOSCommand+
Windows or LinuxControl+

If you want to accept the next line of the suggestion, you will need to set a custom keyboard shortcut for the command editor.action.inlineSuggest.acceptNextLine. For more information on setting custom keyboard shortcuts, see "Keyboard shortcuts in Azure Data Studio" in the Microsoft documentation.

Next steps