Skip to main content

GitHub Copilot을 사용하여 IDE에서 코드 제안 가져오기

GitHub Copilot을(를) 사용하여 편집기에서 코드 제안을 가져옵니다.

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 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.

Prerequisites

  • Access to Copilot. To use GitHub Copilot in Visual Studio, you need either an active Copilot subscription (such as Copilot Pro, Copilot Enterprise, or Copilot Business) or access through Copilot Free, which provides limited functionality. For information about how to get access to Copilot, see What is GitHub Copilot?.

  • Compatible version of Visual Studio. To use GitHub Copilot in Visual Studio, you must have version 2022 17.8 or later of Visual Studio for Windows installed. For more information, see Install Visual Studio in the Microsoft documentation.

  • GitHub Copilot extension for Visual Studio. For instructions on how to install the Copilot extension, see Install GitHub Copilot in Visual Studio in the Microsoft documentation.

  • Add your GitHub account to Visual Studio. See Add your GitHub accounts to your Visual Studio keychain in the Microsoft documentation.

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. To accept the suggestion, press 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. To accept the suggestion, press Tab.

Tip

If you receive limited or no suggestions from Copilot, you may have duplication detection enabled. For more information about duplication detection, see Managing Copilot policies as an individual subscriber.

Showing alternative suggestions

For any given input, GitHub Copilot may offer multiple suggestions. You can select which suggestion to use, or reject all 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.

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

Next steps