Skip to main content

Schnellstart für GitHub Copilot

Erfahren Sie schnell, wie Sie GitHub Copilot in Ihrem Editor verwenden können.

Introduction

GitHub Copilot provides coding suggestions as you type in your editor. You can also ask Copilot coding-related questions, such as how best to code something, how to fix a bug, or how someone else's code works. For full details of what Copilot can do, see "What is GitHub Copilot?."

Instructions for using Copilot differ depending on the editor you use. This version of the quickstart is for Visual Studio Code. Click the tabs above to see instructions for other editors.

Sign up for GitHub Copilot

Start a free trial

If you don't already have access to GitHub Copilot, you can set up a free trial or subscription for GitHub Copilot Individual on your personal GitHub account. For more information, see "Subscription plans for GitHub Copilot."

Prerequisites

Chat with GitHub Copilot

After you've installed the GitHub Copilot extension, you can ask Copilot coding-related questions.

Note

If you have access to GitHub Copilot via your organization, you won't be able to use GitHub Copilot Chat if your organization owner has disabled chat. See "Managing policies for Copilot in your organization."

  1. Open an existing code file.

  2. Open the Chat view from the Activity Bar.

    Screenshot of the Chat icon in the VS Code Activity Bar.

  3. At the bottom of the chat view, in the chat input field, type: explain this file.

  4. Press Enter.

    Copilot replies in the chat view.

  5. In the editor, select one or more lines of code that are not commented.

  6. In the chat input field, type: add comments to these lines.

  7. If you like the comments that Copilot suggests, hover over the suggested code in the chat view and click the "Insert at Cursor" icon to replace the selected lines with the suggested code.

    Screenshot of the "Insert at Cursor" icon in the chat view.

Get your first code completion suggestion

The following example uses JavaScript, however other languages will work similarly. GitHub Copilot provides suggestions for numerous languages and a wide variety of frameworks, but works especially well for Python, JavaScript, TypeScript, Ruby, Go, C# and C++. GitHub Copilot can also assist in query generation for databases, generating suggestions for APIs and frameworks, and can help with infrastructure as code development.

  1. Open Visual Studio Code.

  2. In Visual Studio Code, create a new JavaScript (*.js) file.

  3. In the JavaScript file, type the following function header.

    JavaScript
    function calculateDaysBetweenDates(begin, end) {
    

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

  4. To accept the suggestion, press Tab.

Next steps

GitHub Copilot provides coding suggestions as you type in your editor. You can also ask Copilot coding-related questions, such as how best to code something, how to fix a bug, or how someone else's code works. For full details of what Copilot can do, see "What is GitHub Copilot?."

Instructions for using Copilot differ depending on the editor you use. This version of the quickstart is for Visual Studio. Click the tabs above to see instructions for other editors.

Sign up for GitHub Copilot

Start a free trial

If you don't already have access to GitHub Copilot, you can set up a free trial or subscription for GitHub Copilot Individual on your personal GitHub account. For more information, see "Subscription plans for GitHub Copilot."

Prerequisites

Chat with GitHub Copilot

After you've installed the GitHub Copilot extension, you can ask Copilot coding-related questions.

Note

If you have access to GitHub Copilot via your organization, you won't be able to use GitHub Copilot Chat if your organization owner has disabled chat. See "Managing policies for Copilot in your organization."

  1. Open an existing code file.

  2. In the Visual Studio menu bar, click View, then click GitHub Copilot Chat.

  3. In the Copilot Chat window, type what does this file do then press Enter.

    Copilot's answer is displayed below your question.

  4. Select a line of code in the editor.

  5. In the Copilot Chat window, type explain this line then press Enter.

Get your first code completion suggestion

The following example uses JavaScript, however other languages will work similarly. GitHub Copilot provides suggestions for numerous languages and a wide variety of frameworks, but works especially well for Python, JavaScript, TypeScript, Ruby, Go, C# and C++. GitHub Copilot can also assist in query generation for databases, generating suggestions for APIs and frameworks, and can help with infrastructure as code development.

  1. Open Visual Studio.

  2. In Visual Studio, create a new JavaScript (*.js) file.

  3. In the JavaScript file, type the following function header.

    JavaScript
    function calculateDaysBetweenDates(begin, end) {
    

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

  4. To accept the suggestion, press Tab.

Next steps

GitHub Copilot provides coding suggestions as you type in your editor. You can also ask Copilot coding-related questions, such as how best to code something, how to fix a bug, or how someone else's code works. For full details of what Copilot can do, see "What is GitHub Copilot?."

Instructions for using Copilot differ depending on the editor you use. This version of the quickstart is for JetBrains IDEs. Click the tabs above to see instructions for other editors.

Sign up for GitHub Copilot

Start a free trial

If you don't already have access to GitHub Copilot, you can set up a free trial or subscription for GitHub Copilot Individual on your personal GitHub account. For more information, see "Subscription plans for GitHub Copilot."

Prerequisites

Chat with GitHub Copilot

After you've installed the GitHub Copilot plugin, you can ask Copilot coding-related questions.

Note

If you have access to GitHub Copilot via your organization, you won't be able to use GitHub Copilot Chat if your organization owner has disabled chat. See "Managing policies for Copilot in your organization."

  1. Open an existing code file.

  2. Open the Copilot Chat window by clicking the Copilot Chat icon at the right side of the JetBrains IDE window.

    Screenshot of the Copilot Chat icon in the Activity Bar.

  3. In the Copilot Chat window, type what does this file do then press Enter.

    Copilot's answer is displayed below your question.

  4. Select a line of code in the editor.

  5. In the Copilot Chat window, type explain this line then press Enter.

Get your first code completion suggestion

The following example uses JavaScript, however other languages will work similarly. GitHub Copilot provides suggestions for numerous languages and a wide variety of frameworks, but works especially well for Python, JavaScript, TypeScript, Ruby, Go, C# and C++. GitHub Copilot can also assist in query generation for databases, generating suggestions for APIs and frameworks, and can help with infrastructure as code development.

  1. In your JetBrains editor, create a new JavaScript (*.js) file.

  2. In the JavaScript file, type the following function header.

    JavaScript
    function calculateDaysBetweenDates(begin, end) {
    

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

  3. To accept the suggestion, press Tab.

Next steps