GitHub Copilot provides autocomplete-style suggestions from an AI pair programmer as you code. For more information, see "About GitHub Copilot". Show
If you use Visual Studio Code, you can view and incorporate suggestions from GitHub Copilot directly within the editor. This guide demonstrates how to use GitHub Copilot within Visual Studio Code for macOS, Windows, or Linux. PrerequisitesInstalling the Visual Studio Code extensionTo use GitHub Copilot, you must first install the Visual Studio Code extension.
Seeing your first suggestionNote: If you have duplication detection enabled for GitHub Copilot, you may receive limited suggestions, or no suggestions, when using the code examples provided. As an alternative, you can start by typing your own code to see suggestions from GitHub Copilot. For more information on duplication detection, see "." 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++. The following samples are in JavaScript, but other languages will work similarly.
Seeing alternative suggestionsFor any given input, GitHub Copilot may offer multiple suggestions. You can select which suggestion to use, or reject all suggestions.
Seeing multiple suggestions in a new tabYou may not want any of the initial suggestions GitHub Copilot offers. You can use a keyboard shortcut to prompt GitHub Copilot to show you multiple suggestions in a new tab.
You can describe something you want to do using natural language within a comment, and GitHub Copilot will suggest the code to accomplish your goal.
Using a frameworkYou can also use GitHub Copilot to generate suggestions for APIs and frameworks. The following example uses GitHub Copilot to create a simple Express server that returns the current time.
Enabling or disabling GitHub CopilotYou can enable or disable GitHub Copilot from within Visual Studio Code. The GitHub Copilot status icon in the bottom panel of the Visual Studio Code window indicates whether GitHub Copilot is enabled or disabled. When enabled, the background color of the icon will match the color of the status bar. When disabled, the background color of the icon will contrast with the color of the status bar.
|