Skip to main content

在环境中配置 GitHub Copilot

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

本文内容

About GitHub Copilot in Xcode

If you use Xcode, GitHub 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 GitHub Copilot, and you can configure advanced settings within Xcode or on GitHub.

Prerequisites

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

Using or rebinding keyboard shortcuts for GitHub Copilot

You can use the default keyboard shortcuts for inline suggestions in Xcode when using GitHub 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 GitHub 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 GitHub Copilot for Xcode application. Additionally, we currently only support the Option key for the "View full suggestion" action.

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

Enabling or disabling GitHub Copilot

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

  1. Open the GitHub Copilot for Xcode 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 GitHub Copilot for Xcode

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

  1. Open the GitHub Copilot for Xcode 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 GitHub.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 GitHub.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 GitHub Copilot with an account on GHE.com.