vs code copilot trick "copy and paste sample code"?

344 Views Asked by At

The vscode official document https://code.visualstudio.com/docs/editor/github-copilot#_provide-context has these words about how to "Provide context",

One trick to get Copilot on the right page is to copy and paste sample code that is close to what you are looking for. Providing a small example can help Copilot generate suggestions that match the language and tasks you want to achieve. Once Copilot begins providing you with the code you want and will actually use, you can delete the sample code from the file.

But how do I do that, i.e. how to copy and paste sample code to copilot? I just can't figure that out.

1

There are 1 best solutions below

0
On

They mean to say is that you have to paste the sample example preferably in commented form in the file which you are editing above the area where you want to generate the code.