GitHub Copilot has captured the attention of developers worldwide, promising a revolutionary shift in the way we write code. While the concept sounds enticing, many developers are left wondering, “How do I actually use it in my programming workflow?” In this practical guide, we’ll explore step-by-step instructions on integrating GitHub Copilot into your coding journey.
Setting Up GitHub Copilot:
a. Installation: Begin by installing GitHub Copilot as an extension in your code editor such as Visual Studio Code.
b. Authentication: Link your GitHub account to enable Copilot and access its features seamlessly. After installing the extension VScode will ask you to sign in to your account. Make sure your account is subscripted to one of the available plans.
Make it work!
Let’s start with the basics. How do I get my copilot to do anything? The most basic hotkey we can use is ctrl + i
. With this command we open a prompt window where we can interact directly with the copilot.
We can use this prompt window to ask our copilot to do anything, however we can quickly specify the direction of our prompt by using shortcuts like: /fix /doc /explain
. We can use these commands to quickly interact with our copilot without having to write exhaustive prompts.
Write my documentation please
Sooo let’s apply what we have learned so far by making our copilot write some documentation for our hello world function app. We start by selecting the code we want to document, we press our hotkey ctrl + i
and we write in our prompt “/doc
include js doc types”. This will result in the copilot generating a suggestion which we can then accept by pressing the accept button. By supplying additional information in our prompt we can make the documentation the copilot will come up with more specific. To do this you can simple extend your prompt and press enter and the copilot will come up with new documentation. We have now succesfully made our copilot write documentation for our code.
In summary, GitHub Copilot presents a practical solution for developers seeking to streamline their coding process. Its AI-powered suggestions offer valuable assistance in generating code efficiently, facilitating additional features like documentation generation and improving productivity. By incorporating Copilot into their workflow, developers can benefit from its capabilities to expedite project development while maintaining code quality. As we continue to explore its potential, GitHub Copilot stands as a valuable tool in the arsenal of modern developers.