Write comments to automatically generate code? copilot early adopters


copilot is an AI-based programming aid. It has been integrated in vscode, and may be integrated into more platforms and tools in the future. It is still in the testing stage. Official website address: https://copilot.github.com/

Support all languages

Copilot is based on the existing public data in the network, especially the open source code on Github, and then training based on machine learning algorithms. Therefore copilot theoretically supports all programming languages.

Currently I have tested JS and Python, and the results are pretty good. The official provides examples of ts, go, py and rb languages.

Comments are code

You can write a complete program by writing notes and then following the prompts of copilot all the way.

For example, I want to get user information based on Github username. I just need to write down such a line of comment. Take JS as an example:

// 根据 Github 用户名获取用户信息

How does copilot guide you step by step to complete the complete function? Let's take a look.

first step:

Note: The color of the code below the comment is light, which is prompted by copilot. The same below, no further explanation.

Press the tab key and the light code will be filled, and the next code will be prompted.

The second step:

Press the tab key again, and the overall code is generated.

There are many similar examples, waiting for everyone to explore.

Code completion

A very important function of IDE is code completion. copilot enhances the completion function of the IDE.

copilot can prompt you for possible input based on your code warehouse and the code warehouses publicly available in the world, thereby reducing the number of times you hit the keyboard, writing more codes in a shorter time, and gaining more fishing time.

For example, still take JS as an example. I want to send a fetch request.

fetch('https://www.leetcode-solution.cn', {

It prompts me:

Then follow its prompts, just press tab without writing code, you can write the following code.

fetch("https://leetcode-solution.cn", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  body: JSON.stringify({
    question_id: "1",
    lang: "javascript",
    code: "console.log(1)",
}).then((res) => {

For my warehouse function, a small part of the above code is problematic. But I only need to change it slightly. The efficiency improvement is good.

how to use?

github copilot in the vscode plug-in market, click install, and then follow the prompts to install.

Once installed, you can experience it! Write comments? Knock the code? Press tab? The code duang is generated at once.


copilot is an ai programming tool similar to tabnine. It currently provides free services in the form of a vscode plug-in. It is currently in the testing phase and has not yet been released. It has many exciting functions such as automatic prompting, writing code according to comments and so on.

For more functions and the latest developments, please visit the official website: https://copilot.github.com/

阅读 704

5.1k 声望
4.5k 粉丝
0 条评论

5.1k 声望
4.5k 粉丝