Getting Started with GitHub Copilot
|
This content was generated with the assistance of AI and should be verified against the official documentation of each tool and framework before being relied on in production. This section’s bibliography lists the reference material consulted while preparing these pages. |
This page targets Visual Studio Code 1.139 with the built-in GitHub Copilot Chat extension, the GitHub Copilot
plugin for JetBrains IDEs, and the standalone GitHub Copilot CLI 1.0.88 (the @github/copilot package), all
checked against the official GitHub and VS Code documentation as of
2026-09-28. Both products ship updates frequently, so command names, keybindings and # references are the
ones documented on that date; re-check the linked pages if a menu or shortcut has moved since. The running
example throughout is DocsAssistant API, the small Spring Boot + Python sample used across this sub-section,
with its controller at src/main/java/com/example/docsassistant/DocsController.java and its tests under
src/test/java/com/example/docsassistant/.
Installing and Signing In
GitHub Copilot needs a GitHub account with an active Copilot plan (Free, Pro, Pro+, Business or Enterprise) — plans differ in how many completions, chat requests and premium-model requests they include, and those limits are not repeated here: see GitHub — Plans for GitHub Copilot for the current figures.
In VS Code, Copilot ships as a single extension, GitHub Copilot Chat, which now provides completions as well as chat and agents (the separate GitHub Copilot extension was deprecated in early 2026 — see VS Code blog — Open Source AI Editor: Second Milestone). It is bundled with recent VS Code releases, so there is usually nothing to install manually beyond opening VS Code itself. To sign in, use any of:
-
select Sign in to use Copilot from the Copilot menu in the Status Bar;
-
select the Accounts menu in the Activity Bar, then Sign in with GitHub to use GitHub Copilot;
-
run the GitHub Copilot: Sign in command from the Command Palette.
In JetBrains IDEs (IntelliJ IDEA, PyCharm, WebStorm and the rest of the family), open Settings → Plugins, search the Marketplace for GitHub Copilot, install it, restart the IDE, and sign in from the Copilot tool window that appears. The JetBrains plugin covers ghost-text completions, next edit suggestions, chat, inline chat and commit-message generation from staged changes.
Ghost-Text Completions and Next Edit Suggestions
Copilot offers two related kinds of inline suggestion directly in the editor:
-
Ghost-text completions — dimmed, greyed-out text that completes the current line or suggests a whole new block, generated from the current file and other open files as context.
-
Next edit suggestions (Copilot NES) — rather than completing what you are typing, NES predicts the location of your next edit elsewhere in the file (shown as an arrow in the gutter) and what that edit should be, for example fixing a typo, propagating a rename, or updating a related line after you changed a class’s shape. NES is opt-in, enabled through the
github.copilot.nextEditSuggestions.enabledsetting.
Suppose the DocsAssistant controller only exposes GET /api/pages, and a comment sketches the next endpoint:
// GET /api/pages/{id} - return the page as a PageDto, or a JSON 404 (ProblemDetail) if it does not exist
@GetMapping("/api/pages/{id}")
public ResponseEntity<PageDto> getPage(@PathVariable Long id) {
}
Typing that comment and the method signature is usually enough for ghost text to suggest the method body; once
part of the file has changed, NES’s gutter arrow can then point at the matching test class and offer to add a
getPage_returns404WhenMissing case there.
Accepting, rejecting, partially accepting and cycling through suggestions all use dedicated keybindings, which differ slightly between macOS and Windows/Linux:
| Action | macOS | Windows / Linux | Command |
|---|---|---|---|
Accept the current ghost-text suggestion, or navigate to / accept an NES edit |
Tab |
Tab |
|
Dismiss (reject) the current suggestion |
Esc |
Esc |
|
Accept only the next word or the next line of a ghost-text suggestion (partial accept) |
Cmd+Right |
Ctrl+Right |
|
Cycle to the next alternative suggestion |
Option+] |
Alt+] |
|
Cycle to the previous alternative suggestion |
Option+[ |
Alt+[ |
|
Manually trigger a suggestion at the cursor |
kbd:[Option+\] |
kbd:[Alt+\] |
|
These are VS Code’s defaults; any of them can be rebound in the Keyboard Shortcuts editor by searching for the command name. See GitHub — Keyboard shortcuts for GitHub Copilot in the IDE and VS Code — Inline suggestions from GitHub Copilot.
Chat and Inline Chat
Chat is the panel-based conversation (the Chat view, or the newer Agents window), for anything from a one-off question to a multi-file change. Inline chat (Cmd+I / Ctrl+I in the editor) scopes a prompt to the active editor — optionally to just the selected code — and shows the suggested change as an inline diff you accept with Keep or reject with Undo, without leaving the file; a separate terminal inline chat does the same for shell commands in the integrated terminal. See VS Code — Inline chat and Quick Chat.
# context references
Typing in the chat input opens a picker of context you can attach explicitly, instead of relying on
Copilot’s automatic workspace indexing. As of the date above, VS Code groups what appears behind into three
kinds — tools (actions, such as searching or reading a file), tool sets (named groups of tools) and plain
context items — and the exact reference names have moved since Copilot chat first shipped, so don’t assume any
older list is still complete. The context items you attach directly are:
-
<file>,<folder>and<symbol>— a specific file, folder or code symbol picked from thelist (open the file first to reference a symbol inside it), for example#DocsController.java. -
#selection— the text currently selected in the editor. -
#codebase— tells Copilot to treat the whole indexed workspace as context, backed by the same semantic search tool the picker calls#search/codebase.
Terminal context, which older documentation named as a standalone #terminalLastCommand reference, is now
surfaced under the #read tool set as #read/terminalLastCommand (the last command and its output) and
#read/terminalSelection (the current terminal selection); typing #read or #terminalLastCommand in the
picker shows the current name. See
VS Code — Tools and context reference
and
VS Code — Add context to chat for the
authoritative, up-to-date list.
Attaching files and images
Beyond #-mentions, you can drag files or folders from the Explorer, Search view or editor tabs onto the Chat
view, or select Add Context and choose Files & Folders or Symbols from the picker. Chat also supports
vision: paste a screenshot (from the clipboard or by dragging it from a browser) or attach an image file, and
ask Copilot to explain it or turn a UI sketch into code. See
VS Code — Add context to chat.
Example: adding an endpoint to DocsAssistant API
A chat prompt that asks for a new GET /api/pages/{id} endpoint, with the file attached explicitly so Copilot
edits the right controller instead of guessing at one:
#DocsController.java Add a GET /api/pages/{id} endpoint that returns the page as a PageDto,
using PageRepository.findById, or a 404 with a JSON error body when no page has that id.
Follow the same style as the existing GET /api/pages handler above it.
Copilot proposes the new method as an inline diff in the Chat view (or directly in the editor, for inline
chat), which you review and accept before it is written to
src/main/java/com/example/docsassistant/DocsController.java. The contract is the same one used in
Getting
Started with Claude Code, whose diff shows the resulting getPage method: PageRepository.findById mapped to a
PageDto, and a ProblemDetail JSON body on the 404. See
VS Code — Use chat in VS Code.
The Copilot CLI and Copilot on github.com
Copilot CLI
The GitHub Copilot CLI is a standalone terminal agent, separate from the IDE extensions, distributed as the
@github/copilot package. It replaces the older gh copilot GitHub CLI extension, which only answered
one-shot "explain" and "suggest" questions; the Copilot CLI is a full agent that can read, edit and run
commands in a project, and act on github.com on your behalf. Install it with any of:
$ npm install -g @github/copilot # all platforms, needs Node.js 22+
$ brew install --cask copilot-cli # macOS / Linux
$ winget install GitHub.Copilot # Windows
$ curl -fsSL https://gh.io/copilot-install | bash # macOS / Linux install script
Run copilot with no arguments to start an interactive session; on first use it prompts you to run /login
and authenticate with your GitHub account. Inside the session, press Shift+Tab to switch between the
default ask/execute mode and a plan mode that drafts a structured implementation plan before touching any
files. A first prompt against DocsAssistant API might be:
$ copilot
> Add a GET /api/pages/{id} endpoint to DocsController that returns the page as a PageDto,
using PageRepository.findById, or a 404 with a JSON error body when the id doesn't exist.
Then run the existing tests.
For a one-shot, non-interactive invocation instead of a session, use -p/--prompt, combined with an
allow-tool option so it can act without an approval prompt for that one command:
$ copilot -p "Summarize this week's commits" --allow-tool='shell(git)'
Sessions persist between runs: copilot --continue resumes the most recent session in the current directory,
and copilot --resume opens a picker (or takes a session ID or name) to resume a specific one. Inside a session,
/compact summarizes the conversation history to free up context, optionally steered by focus instructions — VS Code chat has the same /compact command. See
GitHub — GitHub
Copilot CLI command reference and
VS Code — Manage agent sessions.
Copilot on github.com
Copilot is also available directly on github.com: a chat panel at github.com/copilot (and inline on any
issue, pull request or file page) answers questions about a repository, its commits and its pull requests, and
can create issues on your behalf. On a pull request specifically, selecting Summary in the description or
comment editor’s toolbar generates an AI-written overview — a short prose summary followed by a bulleted list
of key changes linked to the files they touch — meant to help a reviewer decide where to look first, not to
replace a human description. See
GitHub — GitHub Copilot on GitHub and
GitHub — Creating a pull request summary with GitHub Copilot.