Complete Guide to Using GitHub Copilot in VSCode

Overview

This article comprehensively covers how to set up GitHub Copilot in VSCode, enable it for Markdown files, and use Chat tools. A GitHub Copilot account is required as a prerequisite.

Getting Started with GitHub Copilot in VSCode

Installing the Extension

First, you need to install the extension in VSCode. Open VSCode, click on the icon with four squares in the left menu, enter “copilot” in the search text input, and click “install” to start the installation.

Extension

Linking with GitHub

After clicking install and completing the installation, the following screen will appear. Click on “Sign in to GitHub.”

Sing in to GitHub Screen

You will be asked to allow access to your GitHub account. Click “Allow” to grant permission.

Access Permission Screen

Click “Authorize Visual Studio Code” to give permission.

Confirmation Screen

This completes the integration of GitHub Copilot with VSCode, and you’re now ready to use it.

How to Use

Basically, as you write code, suggestions will automatically appear. Use the following commands to write code efficiently with the suggested completions.

Cheat Sheet

FunctionKey
Accept suggestionTab
Reject suggestionEsc
Open CopilotCtrl + Enter
Next suggestionAlt/Option + ]
Previous suggestionAlt/Option + [
Trigger inline CopilotAlt/Option + \

Enabling Completions for Markdown Files

By default, GitHub Copilot has completions disabled for Markdown files. If you write blogs or documentation in Markdown, enabling this feature is quite useful.

How to Enable

  1. Open the GitHub Copilot plugin page in VSCode
  2. Click the gear icon to open settings
  3. Change markdown from false to true

This enables Copilot completions in Markdown files. This blog was also written with GitHub Copilot assistance, significantly improving efficiency.

Using Chat Tools for Even More Power

GitHub Copilot Chat has a feature called “Chat tools” that lets you execute various tasks within the chat.

How to Use Chat Tools

Simply enter commands in the format #<command> <args>.

Common Chat Tool Commands

CommandFunction
#codebaseSearch the entire current workspace
#selectionAdd currently selected code in the editor as context
#terminal_selectionAdd currently selected terminal output as context. Useful for referencing error output.
#fetch_webpageFetch content from a URL and add it as context

For more useful commands, check the official documentation:

Summary

This article covered how to set up and use GitHub Copilot in VSCode.

  • Basic Setup: Extension installation and GitHub integration
  • Shortcuts: Tab/Esc to accept/reject suggestions
  • Markdown Support: Change markdown setting to true
  • Chat Tools: Add context with #codebase and #selection

GitHub Copilot not only provides code completions but also assists with writing text. Give it a try and see how it can help you.