vscode结合GitHub Copilot编码

已集成工具

目录

支持试用一个月

GitHub Copilot & Visual Studio Code

在vscode中利用github copilot支持 Python, JavaScript, TypeScript, Ruby, Go, C# and C++等多种语言, GitHub Copilot 支持sql语句生成,框架使用,api建议等

前提条件

GitHub Copilot offers coding suggestions as you type. For example, type this function header in a JavaScript file:

JavaScript

function calculateDaysBetweenDates(begin, end) {

GitHub Copilot will automatically suggest the rest of the function. 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 a JavaScript file:

JavaScript

// write a function to
// find all images without alternate text
// and give them a red border

GitHub Copilot will automatically suggest code. 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 header in a JavaScript file, and press Enter:

JavaScript

function calculateDaysBetweenDates(begin, end) {

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.

You can also use keyboard shortcuts to show alternative suggestions:

OSSee next suggestionSee previous suggestion
macOSOption (⌥) or Alt+]Option (⌥) or Alt+[
Windows or LinuxAlt+]Alt+[

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

Showing multiple suggestions in a new tab

If you don't want to use any of the initial suggestions GitHub Copilot offers, you can show multiple suggestions in a new tab.

For example, type this function header in a JavaScript file, and press Enter:

JavaScript

function calculateDaysBetweenDates(begin, end) {

GitHub Copilot will show you a suggestion. Now press Ctrl+Enter to open a new tab with multiple additional options.

To accept a suggestion, below the suggestion, click Accept suggestion NUMBER. To reject all suggestions, close the tab.

Accepting partial suggestions

If you don't want to accept an entire suggestion from GitHub Copilot, you can accept the next word or the next line of a suggestion.

For example, type this function header in a JavaScript file, and press Enter:

JavaScript

function calculateDaysBetweenDates(begin, end) {

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

Now hover over the suggestion to show the GitHub Copilot control for choosing suggestions. To accept only the next word of the suggestion, click Accept Word in the control.

Alternatively, you can use a keyboard shortcut to accept the next word of a suggestion:

OSAccept Next Word
macOSCommand+→
Windows or LinuxControl+→

If you want to accept the next line of a suggestion, you will need to set a custom keyboard shortcut for the command editor.action.inlineSuggest.acceptNextLine. For more information on setting custom keyboard shortcuts, see "Configuring GitHub Copilot in your environment."

  • 25
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值