GitHub Copilot can help you code by offering autocomplete-style suggestions right in VS Code and Codespaces.
Nice work! 🎉 You created a Codespace using a devcontainer file that installed Copilot!
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++. The following samples are in JavaScript, but other languages will work similarly.
Let's try this out utilizing Javascript for Copilot.
- From inside the codespace in the VS Code explorer window, create a new file.
Note: If you closed the Codespace from above, please open it back up or create a new Codespace.
-
Name the file
skills.js
-
In the
skills.js
file, type the following function header.function calculateNumbers(var1, var2)
GitHub Copilot will automatically suggest an entire function body in grayed text. Below is an example of what you'll most likely see, but the exact suggestion may vary.
-
Press
Tab
to accept the suggestion.
-
Use the VS Code terminal to add the
skills.js
file to the repository:git add skills.js
-
Next from the VS Code terminal stage and commit the changes to the repository:
git commit -m "Copilot first commit"
-
Finally from the VS Code terminal push to code to the repository:
git push
Wait about 60 seconds then refresh your repository landing page for the next step.
Get help: Post in our discussion board • Review the GitHub status page
© 2023 GitHub • Code of Conduct • MIT License