Guides for SE student projects »

GitHub Copilot is an AI Tool that is well-integrated with VS Code, because both tools are from the same parent company (Microsoft).

Signing Up for GitHub Copilot

  • Filling in your billing information
  • Enabling Two-Factor Authentication (2FA). You can skip this step if you have already done so.
    • Go to the Two-factor authentication page for your GitHub account.
    • Click on Enable two-factor authentication.
    • Open the Microsoft Authenticator App on your phone.
    • Tap the scan QR code button at the bottom right.
    • Scan the QR code displayed on the GitHub page.
    • Complete the remaining setup steps.
    • You should see the following page when 2FA is enabled.
  • Linking your university email to GitHub (for Education benefits).
    • Go to the emails settings page in GitHub account.
    • Add your university-issued email under the Add email address field.
    • Verify your email using the link sent to your inbox.
    • Once verified, you will see your school email in the list of emails.
  • Applying for GitHub Education benefits
    • Go to the GitHub Education page.
    • Click on Start an application.
    • Select your role as Student.
    • Choose university as your school (e.g., National University of Singapore).
    • Follow the instructions and complete the application form.
    • Once your application is approved, it will show that you have a current student coupon applied.

Installing GitHub Copilot in Visual Studio Code

  • Updating Visual Studio Code
    • Open Visual Studio Code.
    • Go to HelpCheck for Updates.
    • If updates are available, it should now say "Installing update…".
    • Once it finishes installing, go to HelpRestart to Update.
  • Install the Extension Pack for GitHub Copilot and the Extension Pack for GitHub Copilot Chat extension, to enable support for AI autocompletion.
    • Click on both of the extension links above.
    • Click on the Install button on the page that opens.
    • It should prompt you with Open Visual Studio Code? and click Open Visual Studio Code.
    • You will be redirected to the extension page in Visual Studio Code.
    • Click on Install to install the extension.
    • Make sure to install the Extension Pack for GitHub Copilot Chat as well with the same steps above.

Signing in to GitHub Copilot

  • Verify prerequisies
  • Sign in to GitHub Copilot
    • Open Visual Studio Code.
    • Click on the GitHub Copilot icon at the top.
    • Click on Sign in in the pop up.
    • You will be redirected to GitHub login page, where you can login or select the account linked to GitHub Education.
    • It should prompt you with Open Visual Studio Code? and click Open Visual Studio Code.
    • Once signed in, the GitHub Copilot icon will now say "Toggle Chat" when hovered over.
    • Clicking on the GitHub Copilot icon will open the Copilot chat window.
  • Verifying the installation of GitHub Copilot
    • Open a new text file using FileNew File or / Ctrl+N | Cmd+N.
    • You should see an automatic suggestion appear in the empty text file.

Using GitHub Copilot in Visual Studio Code

Basic Code Completion

  • In a Java file, type a comment like // print Hello World inside the main method.
    public class Main {
        public static void main(String[] args) {
            // print Hello World
        }
    }
    
  • GitHub Copilot will automatically suggest code to complete or implement the comment.
  • Press Tab to accept the suggestion, or continue typing to refine it.
The more descriptive your comment or method signatures, the better Copilot can understand what you want to implement.

Copilot Chat

  • Open the Copilot Chat using / Ctrl+Alt+I | Cmd+Alt+I or using the Copilot icon.
  • Ask something like: "Write a main method that calculates the factorial of N".
  • Copilot will generate a response in the chat window.
  • You can directly insert or copy code chunks using the buttons in the top right corner.
  • From left to right: Insert automatically into the current file, Insert at cursor, Copy to clipboard.

Copilot Inline Chat

  • Go to the line or section where you want to ask Copilot for assistance.
  • Use the inline chat feature using the shortcut / Ctrl+I | Cmd+I.
  • Type your request such as "Add a print log here" and press Enter.
  • The generated lines of code will be highlighted in yellow, and you can insert them by clicking on accept.

Contributors: Norbert Loh (@NorbertLoh )