Skip to main content

在环境中配置 Copilot

可以在受支持的 IDE 中启用、配置或禁用 Copilot。

本文内容

About Copilot in JetBrains IDEs

If you use a JetBrains IDE, Copilot can help you with a variety of tasks, including generating code suggestions, explaining how the code in your editor works, and suggesting code fixes. After installation, you can enable or disable Copilot, and you can configure advanced settings within your IDE or on . This article describes how to configure Copilot in the IntelliJ IDE, but the user interfaces of other JetBrains IDEs may differ.

Prerequisites

To configure Copilot in a JetBrains IDE, you must install the Copilot plugin. For more information, see Installing the Copilot extension in your environment.

Using or rebinding keyboard shortcuts for Copilot

You can use the default keyboard shortcuts for inline suggestions in your JetBrains IDE when using Copilot. Alternatively, you can rebind the shortcuts to your preferred keyboard shortcuts for each specific command. For more information on rebinding keyboard shortcuts in your JetBrains IDE, see the JetBrains documentation. For example, you can view the IntelliJ IDEA documentation.

Keyboard shortcuts for macOS

ActionShortcut
Accept an inline suggestionTab
Dismiss an inline suggestionEsc
Show next inline suggestionOption (⌥) or Alt+]
Show previous inline suggestionOption (⌥) or Alt+[
Trigger inline suggestionOption (⌥)+\
Open Copilot (additional suggestions in separate pane)Option (⌥) or Alt+Return

Keyboard shortcuts for Windows

ActionShortcut
Accept an inline suggestionTab
Dismiss an inline suggestionEsc
Show next inline suggestionAlt+]
Show previous inline suggestionAlt+[
Trigger inline suggestionAlt+\
Open Copilot (additional suggestions in separate pane)Alt+Enter

Keyboard shortcuts for Linux

ActionShortcut
Accept an inline suggestionTab
Dismiss an inline suggestionEsc
Show next inline suggestionAlt+]
Show previous inline suggestionAlt+[
Trigger inline suggestionAlt+\
Open Copilot (additional suggestions in separate pane)Alt+Enter

Enabling or disabling Copilot

You can enable or disable Copilot from within your JetBrains IDE. The Copilot status icon in the bottom panel of the JetBrains window indicates whether Copilot is enabled or disabled. When enabled, the icon is highlighted. When disabled, the icon is grayed out.

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

    Screenshot of the bottom panel in a JetBrains IDE. The GitHub Copilot status icon is outlined in dark orange.

  2. If you are disabling 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 globally, click Disable Completions. Alternatively, click the language-specific button to disable Copilot for the specified language.

    Screenshot of the menu to disable GitHub Copilot globally or for the current language in a JetBrains IDE.

Configuring advanced settings for Copilot

You can manage advanced settings for Copilot in your JetBrains IDE, such as how your IDE displays code completions, and which languages you want to enable or disable for Copilot.

  1. In your JetBrains IDE, click the File menu (Windows), or the name of the application in the menu bar (macOS), then click Settings.
  2. Under Languages & Frameworks, click Copilot.
  3. Edit the settings according to your personal preferences.
    • To adjust the behavior and appearance of code suggestions, and whether to automatically check for updates, select or deselect the corresponding checkboxes.
    • If you have selected to receive automatic updates, you can choose whether to receive stable, but less frequent updates, or nightly updates, which may be less stable. Click the Update channel dropdown and select Stable for stable updates, or Nightly for nightly updates.

Configuring language settings for Copilot

You can specify which languages you want to activate or deactivate Copilot for either in the IDE or by editing your -copilot.xml file. If you make changes to language settings in your IDE, you can individually select and deselect the languages you want to activate or deactivate.

If you make changes to the language settings in your -copilot.xml file, you can specify individual languages, or you can use a wildcard to activate or deactivate Copilot for all languages. You can also specify exceptions, which will override the wild card setting for the specified languages. For example, you can deactivate Copilot for all languages, except for Python and YAML. By default, when you install the Copilot extension, Copilot is activated for all languages.

Configuring language settings in the IDE

  1. In your JetBrains IDE, click the File menu (Windows), or the name of the application in the menu bar (macOS), then click Settings.
  2. Under Languages & Frameworks, click Copilot.
  3. Under "Languages," select or deselect the checkboxes for the languages you want to activate or deactivate Copilot for.
  4. Click Apply, and then click OK.
  5. Restart your JetBrains IDE for the changes to take effect.

Editing your -copilot.xml file

To configure language settings in the -copilot.xml file, you must edit the languageAllowList. Every line you add to the languageAllowList must contain an entry key and a value. The entry key is the name of the language, or (*) for a wildcard. The value is either true or false. If the value is true, Copilot is activated for the specified language. If the value is false, Copilot is deactivated for the specified language.

The file is located in the following directory:

  • macOS: ~/Library/Application Support/JetBrains/<product><version>/options/-copilot.xml
  • Windows: %APPDATA%\JetBrains\<product><version>\options\-copilot.xml
  • Linux: ~/.config/JetBrains/<product><version>/options/-copilot.xml

For example, if you are using IntelliJ IDEA 2021.1 on macOS, the file is located at ~/Library/Application Support/JetBrains/IdeaIC2021.1/options/-copilot.xml.

The -copilot.xml file might not be generated until you make a change to your default language configuration in the IDE's settings. If you cannot locate the file, you should try modifying the default language settings in the IDE. For more information, see Configuring language settings in the IDE.

Alternatively, you can create the file manually and save it in the location for your operating system listed above. For more information, see Example language configurations.

  1. Open the -copilot.xml file in a text editor.

  2. Between the <map> tags, add the line or lines for the languages you want to activate or deactivate Copilot for. For example, to deactivate Copilot for all languages:

    XML
    <entry key="*" value="false" />
    
  3. Save the changes to the -copilot.xml file.

  4. Restart your JetBrains IDE for the changes to take effect.

Example language configurations

The default configuration of the -copilot.xml file, which enables Copilot for all languages is as follows:

XML
<application>
  <component name="-copilot">
    <languageAllowList>
      <map>
        <entry key="*" value="true" />
      </map>
    </languageAllowList>
  </component>
</application>

To deactivate Copilot for all languages, the wildcard (*) value is changed to false:

XML
<application>
  <component name="-copilot">
    <languageAllowList>
      <map>
        <entry key="*" value="false" />
      </map>
    </languageAllowList>
  </component>
</application>

To specify languages individually, add an entry for each language you want to activate or deactivate Copilot for. Specific language settings will override the wildcard. For example, to activate Copilot for Python and YAML, and deactivate Copilot for all other languages, add the following entries:

XML
<application>
  <component name="-copilot">
    <languageAllowList>
      <map>
        <entry key="*" value="false" />
        <entry key="Python" value="true" />
        <entry key="YAML" value="true" />
      </map>
    </languageAllowList>
  </component>
</application>

You can also add a configuration to make the languageAllowList readonly in the IDE's settings. This will prevent you from changing the language settings in the IDE. For example:

XML
<application>
  <component name="-copilot">
    <option name="languageAllowListReadOnly" value="true" />
    <languageAllowList>
      <map>
        <entry key="*" value="true" />
      </map>
    </languageAllowList>
  </component>
</application>

Configuring Copilot settings on .com

If you are using a Copilot Pro plan, you can choose to allow or block code completion suggestions that match publicly available code. You configure this in your personal settings on .com. See Managing Copilot policies as an individual subscriber.

Authenticating to an account on GHE.com

If you're using a Copilot plan for a managed user account on GHE.com, you'll need to update some settings before you sign in. See Using Copilot with an account on GHE.com.

Further reading

About Copilot in Visual Studio

If you use Visual Studio, Copilot can help you with a variety of tasks, including generating code suggestions, explaining how the code in your editor works, and suggesting code fixes. After installation, you can enable or disable Copilot, and you can configure advanced settings within Visual Studio or on .

Prerequisites

To configure Copilot in Visual Studio, you must install the Copilot plugin. For more information, see Installing the Copilot extension in your environment.

Using or rebinding keyboard shortcuts for Copilot

You can use the default keyboard shortcuts in Visual Studio when using Copilot. Alternatively, you can rebind the shortcuts in the Tools settings for Visual Studio using your preferred keyboard shortcuts for each specific command. You can search for each keyboard shortcut by its command name in the Keyboard Shortcuts editor.

Using default keyboard shortcuts

ActionShortcutCommand name
Show next inline suggestionAlt+.Edit.NextSuggestion
Show previous inline suggestionAlt+,Edit.PreviousSuggestion

Rebinding keyboard shortcuts

If you don't want to use the default keyboard shortcuts in Visual Studio when using Copilot, you can rebind the shortcuts in the Keyboard editor using your preferred keyboard shortcuts for each specific command.

  1. In the Visual Studio menu bar, under Tools, click Options.

    Screenshot of the Visual Studio menu bar. The "Tools" menu is expanded, and the "Options" item is highlighted with an orange outline.

  2. In the "Options" dialog, under Environment, click Keyboard.

  3. Under "Show commands containing:", search for the command you want to rebind.

    Screenshot of the "Show commands containing" search bar. The string "tools.next" is entered in the search field.

  4. Under "Press shortcut keys," type the shortcut you want to assign to the command, then click Assign.

    Screenshot of the fields for entering a new keyboard shortcut assignment.

Enabling or disabling Copilot

The Copilot status icon in the bottom panel of the Visual Studio window indicates whether Copilot is enabled or disabled. When enabled, the background color of the icon will match the color of the status bar. When disabled, it will have a diagonal line through it.

  1. To enable or disable Copilot, click the Copilot icon in the bottom panel of the Visual Studio window.

    Screenshot of editor margin in Visual Studio with the GitHub Copilot icon emphasized.

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

    • To disable suggestions from Copilot globally, click Enable Globally.
    • To disable suggestions from Copilot for the specified language, click Enable for LANGUAGE.

Configuring ReSharper for Copilot

If you use ReSharper, Copilot may work best when you configure ReSharper to use Copilot's native IntelliSense. For more information about ReSharper, see the ReSharper documentation

  1. In the Visual Studio menu bar, under Extensions, click ReSharper, then click Options.
  2. In the "Options" dialog, under Environment, click IntelliSense and then click General.
  3. Under "General" select Visual Studio and then click Save.

Configuring Copilot settings on .com

If you are using a Copilot Pro plan, you can choose to allow or block code completion suggestions that match publicly available code. You configure this in your personal settings on .com. See Managing Copilot policies as an individual subscriber.

Authenticating to an account on GHE.com

If you're using a Copilot plan for a managed user account on GHE.com, you'll need to update some settings before you sign in. See Using Copilot with an account on GHE.com.

Further reading

About Copilot in Visual Studio Code

If you use Visual Studio Code, Copilot can help you with a variety of tasks, including generating code suggestions, explaining how the code in your editor works, and suggesting edits based on your instructions. You can enable or disable Copilot, and configure advanced settings within Visual Studio Code or on .

You can learn more about scenarios and setup in the VS Code documentation.

Keyboard shortcuts for Copilot

You can use the default keyboard shortcuts for Copilot in Copilot. Search keyboard shortcuts by command name in the Keyboard Shortcuts editor.

Alternatively, you can rebind the shortcut for each command in the Keyboard Shortcuts editor. For more information, see the VS Code documentation on editing shortcuts.

Keyboard shortcuts for macOS

ActionShortcutCommand name
Accept an inline suggestionTabeditor.action.inlineSuggest.commit
Dismiss an inline suggestionEsceditor.action.inlineSuggest.hide
Show next inline suggestionOption (⌥)+]
editor.action.inlineSuggest.showNext
Show previous inline suggestionOption (⌥)+[
editor.action.inlineSuggest.showPrevious
Trigger inline suggestionOption (⌥)+\
editor.action.inlineSuggest.trigger
Open Copilot (additional suggestions in separate pane)Ctrl+Return.copilot.generate
Toggle Copilot on/offNo default shortcut.copilot.toggleCopilot

Keyboard shortcuts for Windows

ActionShortcutCommand name
Accept an inline suggestionTabeditor.action.inlineSuggest.commit
Dismiss an inline suggestionEsceditor.action.inlineSuggest.hide
Show next inline suggestionAlt+]editor.action.inlineSuggest.showNext
Show previous inline suggestionAlt+[editor.action.inlineSuggest.showPrevious
Trigger inline suggestionAlt+\editor.action.inlineSuggest.trigger
Open Copilot (additional suggestions in separate pane)Ctrl+Enter.copilot.generate
Toggle Copilot on/offNo default shortcut.copilot.toggleCopilot

Keyboard shortcuts for Linux

ActionShortcutCommand name
Accept an inline suggestionTabeditor.action.inlineSuggest.commit
Dismiss an inline suggestionEsceditor.action.inlineSuggest.hide
Show next inline suggestionAlt+]editor.action.inlineSuggest.showNext
Show previous inline suggestionAlt+[editor.action.inlineSuggest.showPrevious
Trigger inline suggestionAlt+\editor.action.inlineSuggest.trigger
Open Copilot (additional suggestions in separate pane)Ctrl+Enter.copilot.generate
Toggle Copilot on/offNo default shortcut.copilot.toggleCopilot

Enabling or disabling Copilot code completions

You can enable or disable Copilot from within Visual Studio Code.

  1. To configure code completions, click the arrow next to the icon in the title bar of Visual Studio Code, then select Configure code completions.

    Screenshot of the option in the GitHub Copilot dropdown. Configure code completions is highlighted in orange.

  2. In the "Configure Copilot Completions" dialog, select Enable Completions or Disable Completions.

    Screenshot of the "Configure Copilot Completions" dialog. Enable Completions and Disable Completions options are highlighted in orange.

Enabling or disabling inline suggestions

You can choose to enable or disable inline suggestions for Copilot in Visual Studio Code.

  1. In the File menu, navigate to Preferences and click Settings.

    Screenshot of Visual Studio Code settings.

  2. In the left-side panel of the settings tab, click Extensions and then select Copilot.

  3. Under "Inline Suggest:Enable," select or deselect the checkbox to enable or disable inline suggestions.

Enabling next edit suggestions

You can enable next edit suggestions via the VS Code setting .copilot.nextEditSuggestions.enabled. For more detailed instructions, see Enabling edit suggestions in the VS Code documentation.

If you're using a Copilot Business or Copilot Enterprise plan, the organization or enterprise that provides your plan must enable the Editor preview features setting. See Managing policies for Copilot in your organization or Managing policies and features for Copilot in your enterprise.

Enabling or disabling Copilot for specific languages

You can specify which languages you want to enable or disable Copilot for.

  1. From the Visual Studio Code, click the Extensions tab, then navigate to the Copilot section. For more information, see Enabling or disabling inline suggestions.

  2. Under "Enable or disable Copilot for specified languages," click Edit in settings.json.

  3. In the settings.json file, add or remove the languages you want to enable or disable Copilot for. For example, to enable Python in Copilot, add "python": true to the list, ensuring there is a trailing comma after all but the last list item.

    {
        "editor.inlineSuggest.enabled": true,
        ".copilot.enable": {
            "*": true,
            "yaml": false,
            "plaintext": false,
            "markdown": true,
            "javascript": true,
            "python": true
        }
    }
    

Revoking Copilot authorization

Visual Studio Code retains authorization to use Copilot through a particular account. If you want to prevent your account being used for Copilot on a device you no longer have access to, you can revoke authorization and then go through the authorization process again. The device you previously used will not have the new authorization.

  1. In the upper-right corner of any page on , click your profile photo, then click Settings.

  2. In the "Integrations" section of the sidebar, click Applications.

  3. Click the Authorized OAuth Apps tab.

    Screenshot of the "Applications" page. A tab, labeled "Authorized OAuth Apps," is highlighted with an orange outline.

  4. Click the ... next to for VS Code and click Revoke.

  5. Click the Authorized Apps tab.

  6. If the Copilot extension is listed, click Revoke.

After revoking authorization, Visual Studio Code will be able to continue using Copilot in a current session for a maximum of 30 minutes. After that time, you will need to reauthorize Copilot for use in Visual Studio Code again.

Re-authorizing Copilot

After you have revoked authorization, if you want to continue using Copilot, you will need to complete the reauthorization process.

  1. In the bottom left corner of Visual Studio Code, click the Accounts icon, hover over your username, and click Sign out.

    Screenshot of the menu in Visual Studio Code. The "Sign out" option is outlined in dark orange.

  2. In the "Visual Studio Code" pop-up, click Sign Out.

  3. In the bottom left corner of Visual Studio Code, click the Accounts icon, hover over your username, and click Sign in with to use Copilot.

    Screenshot of the accounts menu in Visual Studio Code. The "Sign in with GitHub to use GitHub Copilot (1)" option is outlined in dark orange.

  4. In your browser, will request the necessary permissions for Copilot. To approve these permissions, click Continue.

  5. In the "Open Visual Studio Code?" pop-up, click Open Visual Studio Code.

Configuring Copilot settings on .com

If you are using a Copilot Pro plan, you can choose to allow or block code completion suggestions that match publicly available code. You configure this in your personal settings on .com. See Managing Copilot policies as an individual subscriber.

Authenticating to an account on GHE.com

If you're using a Copilot plan for a managed user account on GHE.com, you'll need to update some settings before you sign in. See Using Copilot with an account on GHE.com.

Further reading

Configuring Copilot in Vim/Neovim

For guidance on configuring Copilot in Vim/Neovim, invoke the Copilot documentation in Vim/Neovim by running the following command:

:help copilot

Rebinding keyboard shortcuts

You can rebind the keyboard shortcuts in Vim/Neovim when using Copilot to use your preferred keyboard shortcuts for each specific command. For more information, see the Map article in the Neovim documentation.

Configuring Copilot settings on .com

If you are using a Copilot Pro plan, you can choose to allow or block code completion suggestions that match publicly available code. You configure this in your personal settings on .com. See Managing Copilot policies as an individual subscriber.

Authenticating to an account on GHE.com

If you're using a Copilot plan for a managed user account on GHE.com, you'll need to update some settings before you sign in. See Using Copilot with an account on GHE.com.

Further reading

About Copilot in Xcode

If you use Xcode, Copilot can help you with a variety of tasks, including generating code suggestions, explaining how the code in your editor works, and suggesting code fixes. After installation, you can enable or disable Copilot, and you can configure advanced settings within Xcode or on .

Prerequisites

To configure Copilot for Xcode, you must install the Copilot extension. See Installing the Copilot extension in your environment.

Using or rebinding keyboard shortcuts for Copilot

You can use the default keyboard shortcuts for inline suggestions in Xcode when using Copilot. Alternatively, you can rebind the shortcuts to your preferred keyboard shortcuts for each specific command.

Default keyboard shortcuts

ActionShortcut
Accept the first line of a suggestionTab
View full suggestionHold Option
Accept full suggestionOption+Tab

Rebinding keyboard shortcuts

If you don't want to use the default keyboard shortcuts for Copilot, you can rebind the shortcuts in the Key Bindings editor and use your preferred keyboard shortcuts.

If you want to use something besides Tab to accept the first line of a suggestion, you need to disable the "Accept suggestions with Tab" option in the advanced settings in the Copilot for Xcode application. Additionally, we currently only support the Option key for the "View full suggestion" action.

  1. In the Xcode menu bar, click Settings.
  2. Click Key Bindings and search for "Copilot" to find the commands you want to rebind.

Enabling or disabling Copilot

You can enable or disable the Copilot extension from within the application.

  1. Open the Copilot extension application.
  2. At the top of the application window, click Advanced.
  3. In the "Suggestion Settings" section, use the "Request suggestions while typing" toggle to enable or disable the extension.

Automatically updating Copilot for Xcode

You can configure the Copilot extension to automatically check for updates.

  1. Open the Copilot extension application.
  2. Select Automatically check for updates.

After updating the extension, Xcode must be restarted for the changes to take effect.

Configuring Copilot settings on .com

If you are using a Copilot Pro plan, you can choose to allow or block code completion suggestions that match publicly available code. You configure this in your personal settings on .com. See Managing Copilot policies as an individual subscriber.

Authenticating to an account on GHE.com

If you're using a Copilot plan for a managed user account on GHE.com, you'll need to update some settings before you sign in. See Using Copilot with an account on GHE.com.

About Copilot in Eclipse

If you use Eclipse, Copilot can provide code suggestions as you work in the IDE. You can also use the Copilot Chat panel to work with Copilot as your AI pair programmer.

After you install Copilot in Eclipse, you can enable or disable it, and you can configure advanced settings within the IDE.

Prerequisites

To configure Copilot in Eclipse, you must install the Copilot extension. See Installing the Copilot extension in your environment.

Using or rebinding keyboard shortcuts for Copilot

You can use the default keyboard shortcuts for inline suggestions in Eclipse when using Copilot. Alternatively, you can rebind the shortcuts to your preferred keyboard shortcuts for each specific command.

Rebinding keyboard shortcuts

If you don't want to use the default keyboard shortcuts for Copilot, you can rebind the shortcuts in the Key Bindings editor and use your preferred keyboard shortcuts.

  1. In the IDE, click Copilot to open the menu.
  2. Click Edit Keyboard Shortcuts... to rebind the shortcuts.

Settings and configurations

For advanced settings, you can set auto-completion behavior, configure proxy, and assign a Enterprise authentication endpoint.

Configuring Copilot settings on .com

If you are using a Copilot Pro plan, you can choose to allow or block code completion suggestions that match publicly available code. You configure this in your personal settings on .com. See Managing Copilot policies as an individual subscriber.

Authenticating to an account on GHE.com

If you're using a Copilot plan for a managed user account on GHE.com, you'll need to update some settings before you sign in. See Using Copilot with an account on GHE.com.