Code generation and automation
At its core, Copilot is a code generator. It can generate text for you that is either part of documentation or source code.
There are two primary ways to generate code with Copilot:
- Copilot’s active editor via prompts as comments.
- Copilot Chat, which lets you type in a prompt.
Copilot’s active editor
When you’re in the active editor, Copilot can generate code. To generate code, you need to write a prompt as a comment. There are different ways to add comments to your programming language code. In JavaScript and C#, for example, you use //
, while you would type <!--
if you’re in HTML.
Let’s see an example of this:
[Prompt]
Create a new function called add that takes two parameters.
[End of prompt]
//Create a new function called add that takes two parameters
Above, we have a prompt as a comment. Copilot looks at this prompt and attempts to generate code based...