Find helpful tutorials or share inspiring use cases on AI technology for higher education.

Shared content may not reflect the policies of Tilburg University on the use of AI. 

GitHub Copilot vs. ChatGPT: Why We Recommend Copilot

Do you also find programming challenging and frequently encounter errors? Let GitHub CoPilot help you write code faster and more efficiently! Dive into this guide to master its features and elevate your coding game. Don’t forget to check out our previous article that covers all the ins and outs of the installation and billing process. We will be using Visual Studio code in this article. In Rstudio (the most recent version), Github Copilot can also be enabled.

Why should you use GitHub Copilot instead of ChatGPT?

On this website, you will often see us talking passionately about ChatGPT. However, when it comes to coding projects, we are bigger fans of GitHub Copilot. So, before we start this article, let’s first summarize the benefits of using GitHub Copilot instead of ChatGPT:

  • Contextual Understanding of Code: GitHub Copilot is designed specifically for coding and provides suggestions based on the context within your codebase.
  • Intelligent Code Suggestions: GitHub Copilot is trained on a large corpus of code from public repositories on GitHub, which allows it to suggest code snippets and functions that are widely used and accepted in the developer community.
  • Integrated Development Workflow: GitHub Copilot fits right into your coding space (for example Visual Studie Code), just like a helpful buddy.

Inline suggestions

Copilot automatically makes recommendations to help you write code more quickly. Write some code, or coding-related stuff like tests or comments. Copilot may provide several recommendations for any given input. You have the option to accept all suggestions or just one of them. Copilot will give you a recommendation in the form of grey text.

For instance, in a JavaScript file, you could type the function header that follows:

ShellScript
function calculateDaysBetweenDates(begin, end) {

Copilot will give you a suggestion like the following:

One of Copilot’s great features is that it offers multiple recommendations, allowing you to select your favorite. Use “Tab” to accept suggestions, but you can also hover over suggestions to see the inline suggestion toolbar, which appears as follows, to find more options for code:

Copilot makes three recommendations in the image above. Using Tab, you can accept every option, or using Ctrl+RightArrow, you can accept just some of the suggestions. Alternatively, you can use the keyboard shortcut Alt+] to navigate between options or use the suggestion toolbar.

When you don’t want to use any of the suggestions you can keep typing, and Copilot will keep making suggestions while you continue working.

Chat with Copilot

Apart from inline recommendations, Copilot also offers support through a chat window. There are multiple ways to do this:

Chat view
This feature is ideal if you’re learning how to code or creating a new project. Simply turn on the chat feature to begin interacting with Copilot (similar to ChatGPT, but with your own files and code context). You can access the Chat view via the Activity bar. Copilot will suggest potential questions to get started. You can select any of these questions or use the chat box to type your own:

There are several keyboard shortcuts that makes it easy to work with Chat view:

  • Ctrl+Alt+I – Opens the Chat view
  • Ctrl+L – Clears the Chat view
  • Ctrl+Down – Moves keyboard focus to the Chat view input box

Inline chat
This function will make it possible to ask questions while you are coding. In any file, you can just press Ctrl+I on your keyboard to bring up Copilot inline chat:

Quick chat When you want to ask a quick question, and don’t want to open the Chat view you can use the Quick chat. you can run Chat: Open Quick Chat or use the Ctrl+Shift+I keyboard shortcut.

Want to know more about GitHub Copilot?

If you want to know and learn more about all the cool functionalities of Github Copilot we recommend the following videos and blogs: