Movatterモバイル変換


[0]ホーム

URL:


TryMCP servers to extend agent mode in VS Code!

Dismiss this update

GitHub Copilot in VS Code cheat sheet

GitHub Copilot in Visual Studio Code provides AI-powered features to help you write code faster and with less effort. This cheat sheet provides a quick overview of the features for GitHub Copilot in Visual Studio Code.

Tip

If you don't yet have a Copilot subscription, you can use Copilot for free by signing up for theCopilot Free plan and get a monthly limit of completions and chat interactions.

Essential keyboard shortcuts

  • ⌃⌘I (Windows, LinuxCtrl+Alt+I) - Open the Chat view
  • ⌘I (Windows, LinuxCtrl+I) - Enter voice chat prompt in Chat view
  • ⌘N (Windows, LinuxCtrl+N) - Start a new chat session in Chat view
  • ⇧⌘I (WindowsCtrl+Shift+I, LinuxCtrl+Shift+Alt+I) - Switch to agent mode
  • ⌘I (Windows, LinuxCtrl+I) - Start inline chat in the editor or terminal
  • ⌘I (Windows, LinuxCtrl+I) (hold) - Start inline voice chat
  • Tab - Accept inline suggestion or navigate to the next edit suggestion
  • Escape - Dismiss inline suggestion

Access AI in VS Code

  • Start a chat conversation using natural language

    • Chat view (⌃⌘I (Windows, LinuxCtrl+Alt+I)): keep an ongoing chat conversation in the Secondary Side Bar
    • Inline chat in the editor or terminal (⌘I (Windows, LinuxCtrl+I)): ask questions while you're in the flow
    • Quick Chat (⇧⌥⌘L (Windows, LinuxCtrl+Shift+Alt+L)): ask quick questions without leaving your current task
  • AI in theeditor

    • Code completions: get suggestions as you type, pressTab to accept a suggestion
    • Edit context menu actions: access common AI actions like explaining or fixing code, generating tests, or reviewing a text selection
    • Code actions: get editor code actions (lightbulb) to fix linting and compiler errors
  • Task-specificsmart actions across VS Code

    • Generate commit messages and pull request titles and descriptions
    • Fix testing errors
    • Semantic file search suggestions

Chat experience in VS Code

Start a natural language chat conversation to get help with coding tasks. For example, ask to explain a block of code or a programming concept, refactor a piece of code, or implement a new feature. Get more information about usingCopilot Chat.

ActionDescription
⌃⌘I (Windows, LinuxCtrl+Alt+I)Open theChat view in the Secondary Side Bar.
⌘I (Windows, LinuxCtrl+I)Startinline chat to open chat in the editor or terminal.
⇧⌥⌘L (Windows, LinuxCtrl+Shift+Alt+L)OpenQuick Chat without interrupting your workflow.
⌘N (Windows, LinuxCtrl+N)Start a new chat session in the Chat view.
⌘. (Windows, LinuxCtrl+.)Toggle between differentchat modes in the Chat view.
⌥⌘. (Windows, LinuxCtrl+Alt+.)Show the model picker toselect a different AI model for chat.
Add Context...Attach different types ofcontext to your chat prompt.
/-commandUseslash commands for common tasks or invoke areusable chat prompt.
#-mentionReference common tools or chat variables toprovide context within in your prompt.
@-mentionReferencechat participants to handle domain-specific requests.
Edit ()Edit a previous chat prompt and revert changes.
History ()Access your history of chat sessions.
Voice ()Enter a chat prompt by using speech (voice chat). The chat response is read out aloud.

Tips

  • Use#-mentions to add more context to your chat prompt.
  • Use/ commands and@ participants to get more precise and relevant answers.
  • Be specific, keep it simple, and ask follow-up questions to get the best results.
  • Choose a chat mode that fits your needs: ask, edit, agent, or create a custom mode.

Add context to your prompt

Get more relevant responses by providingcontext to your chat prompt. Choose from different context types, such as files, symbols, editor selections, source control commits, test failures, and more.

ActionDescription
Add ContextOpen a Quick Pick to select relevant context for your chat prompt. Choose from different context types, such as workspace files, symbols, current editor selection, terminal selection, and more.
Drag & drop filesDrag & drop a file from the Explorer or Search view, or drag an editor tab onto the Chat view.
Drag & drop foldersDrag & drop a folder onto the Chat view to attach the files within it.
Drag & drop problemDrag & drop an item from the Problems panel.
#<file|folder|symbol>Type#, followed by a file, folder, or symbol name, to add it as chat context.
`#-mentionType#, followed by achat variable to add a specific context type or tool.

Chat variables

Use chat variables in your chat prompt to reference context that is relevant to your question or to reference specific tools. Reference chat variables or tools in your chat prompt by using the#-mention syntax.

Tools can be invoked as part of an autonomous coding workflow withagent mode. Extensions and MCP servers can provide additional tools that you can use in your chat prompts.

Chat variable/ToolDescription
#changesList of source control changes.
#codebasePerform a code search in the current workspace to automatically find relevant context for the chat prompt.
#editFilesTool set to enable creating and editing files in the workspace.
#extensionsTool to find and ask questions about VS Code extensions. For example, "how to get started with Python #extensions?"
#fetchFetch the content from a web page - provide the URL.
#findTestFilesTool for finding test files in the current workspace.
#<file|folder|symbol>Add a file, folder, or code symbol as context.
#githubRepoTool to perform a code search in a GitHub repo. For example, "what is a global snippet #githubRepo microsoft/vscode."
#newTool to scaffold a new VS Code workspace.
#openSimpleBrowserTool to open the built-in Simple Browser and preview a locally-deployed web app.
#problemsAdd workspace issues and problems from theProblems panel as context. Useful while fixing code or debugging.
#readCellOutputTool for reading the output from a notebook cell.
#runCommandsTool for running commands in the terminal and reading the output.
#runNotebooksTool for running cells in a notebook and reading the output.
#runTasksTool for running tasks in the workspace and reading the output.
#runTestsTool for running tests in the workspace and reading the output.
#searchTool set for searching for files in the current workspace.
#searchResultsAdd the results from the Search view as context to your prompt.
#selectionAdd the current editor selection as context to your prompt.
#terminalSelectionAdd the current terminal selection as context to your chat prompt.
#terminalLastCommandAdd the last run terminal command as context to your chat prompt.
#testFailureAdd test failure information as context. Useful when running and diagnosingtests.
#usagesCombination of "Find All References", "Find Implementation", and "Go to Definition".
#VSCodeAPITool to reference the VS Code extension APIs and ask questions related to VS Code extension development.

Slash commands

Slash commands are shortcuts to specific functionality within the chat. You can use them to quickly perform actions, like fixing issues, generating tests, or explaining code.

Slash commandDescription
/docsGenerate code documentation comments from editor inline chat.
/explainExplain a code block, file, or programming concept.
/fixAsk Copilot to fix a code block or resolve compiler or linting errors.
/helpGet help about using chat in VS Code.
/testsGenerate tests for all or only the selected methods and functions in the editor.
/setupTestsGet help setting up a testing framework for your code. Get recommendation for a relevant testing framework, steps to set up and configure it, and suggestions for VS Code testing extensions.
/clearStart a new chat session in the Chat view.
/newScaffold a new VS Code workspace or file. Use natural language to describe the type of project/file you need, and preview the scaffolded content before creating it.
/newNotebookScaffold a new Jupyter notebook based on your requirements. Use natural language to describe what the notebook should contain.
/searchGenerate a search query for the Search view. Use natural language to describe what you want to search for.
/startDebuggingGenerate alaunch.json debug configuration file and start a debugging session from the Chat view.
/<prompt file name>Run areusable prompt file in chat.

Chat participants

Use chat participants to handle domain-specific requests in chat. Chat participants are prefixed with@ and can be used to ask questions about specific topics. VS Code provides built-in chat participants, such as@github,@terminal, and@vscode, and extensions can provide additional participants.

Chat participantDescription
@githubUse the@github participant to ask questions about GitHub repositories, issues, pull requests, and more. Get more information about theavailable GitHub skills.
Example:@github What are all of the open PRs assigned to me?,@github Show me the recent merged PRs from @dancing-mona
@terminalUse the@terminal participant to ask questions about the integrated terminal or shell commands.
Example:@terminal list the 5 largest files in this workspace
@vscodeUse the@vscode participant to ask questions about VS Code features, settings, and the VS Code extension APIs.
Example:@vscode how to enable word wrapping?
@workspaceUse the@workspace participant to ask questions about the current workspace.
Example:@workspace how is authentication implemented?

Agent mode

With chatagent mode, you can use natural language to specify a high-level task, and let AI autonomously reason about the request, plan the work needed, and apply the changes to your codebase. Agent mode uses a combination of code editing and tool invocation to accomplish the task you specified. As it processes your request, it monitors the outcome of edits and tools, and iterates to resolve any issues that arise.

ActionDescription
⇧⌘I (WindowsCtrl+Shift+I, LinuxCtrl+Shift+Alt+I)Switch to agent mode in the Chat view
Tools ()Configure which tools are available in agent mode. Select from built-in tools, MCP servers, and extension-provided tools.
Auto-approve tools(Experimental)Enableauto-approval of all tools in agent mode (chat.tools.autoApprove).
Auto-approve terminal commands(Experimental)Enableauto-approval of terminal commands in agent mode with an allow and deny list.
MCPConfigureMCP servers to extend agent mode with extra capabilities and tools.

Tips

  • Add extra tools to agent mode to extend its capabilities.
  • Configure custom chat modes to define how agent mode operates, for example to implement a read-only planning mode.
  • Define custom instructions to guide agent mode on how to generate and structure code.

Customize your chat experience

Customize your chat experience to generate responses that match your coding style, tools, and developer workflow. There are several ways to customize your chat experience in VS Code:

  • Custom instructions: Define common guidelines or rules for tasks like generating code, performing code reviews, or generating commit messages. Custom instructions describe the conditions in which the AI should perform operate (how a task should be done).

  • Reusable prompt files: Define reusable prompts for common tasks like generating code or performing a code review. Prompt files are standalone prompts that you can run directly in chat. They describe the task to be performed (what should be done).

  • Chat modes: Define how chat operates, which tools it can use, and how it interacts with the codebase. Each chat prompt is run within the boundaries of the chat mode, without having to configure tools and instructions for every request.

Tips

  • Define language-specific instructions to get more accurate generated code for each language.
  • Store your instructions in your workspace to easily share them with your team.
  • Define reusable prompt files for common tasks to save time and help team members get started quickly.

Editor AI features

As you're coding in the editor, you can use Copilot to generate code completions as you're typing. Invoke Inline Chat to ask questions and get help from Copilot, while staying in the flow of coding. For example, ask Copilot to generate unit tests for a function or method. Get more information aboutcode completions andInline Chat.

ActionDescription
Code completionsStart typing in the editor and getcode suggestions that match your coding style and take your existing code into account.
Code commentsProvide a code completion prompt by writing instructions in a code comment.
Example:# write a calculator class with methods for add, subtract, and multiply. Use static methods.
⌘I (Windows, LinuxCtrl+I)Start editor inline chat to send a chat request directly from the editor. Use natural language and reference chat variables and slash commands to provide context.
F2Get AI-powered suggestions when renaming symbols in your code.
Context menu actionsUse the editor context menu to access common AI actions, such as explaining code, generating tests, reviewing code, and more. Right-click in the editor to open the context menu and selectCopilot.
Code Actions (lightbulb)Select the Code Action (lightbulb) in the editor for fixing linting or compiler errors in your code.

Tips

  • Use meaningful method or function names to get better code completions quicker.
  • Select a code block to scope your Inline Chat prompt or attach relevant context by attaching files or symbols.
  • Use the editor context menu options to access common Copilot actions directly from the editor.

Source control and issues

Use AI to analyze the changes in your commits and pull requests and provide suggestions for commit messages and pull request descriptions.

ActionDescription
#changesAdd the current source control changes as context in your chat prompt.
Commit as contextAdd a commit from the source control history as context in your chat prompt.
Summarize commitRight-click a commit in the source control graph and selectCopilot >Summarize to generate a summary of the commit changes.
Commit messageGenerate a commit message for the current changes in a source control commit.
Pull request descriptionGenerate a pull request title and description that correspond with the changes in your pull request.
@githubUse the@github participant in chat to ask about issues, pull requests, and more across your repositories. Get more information about theavailable GitHub skills.
Example:@github What are all of the open PRs assigned to me?,@github Show me the recent merged pr's from @dancing-mona

Review code (experimental)

Use AI to do a quick review pass of a code block or perform a review of uncommitted changes in your workspace. Review feedback shows up as comments in the editor, where you can apply the suggestions.

ActionDescription
Review and Comment(Preview)Select a block of code, and selectCopilot >Review and Comment from the editor context menu for quick review pass.
Copilot Code ReviewSelect theCopilot Code Review button in the Source Control view for a deeper review of all uncommitted changes.

Search and settings

Get semantically relevant search results in the Search view or help with searching for settings in the Settings editor.

ActionDescription
Semantic search(Preview)Include semantic search results in the Search view (search.searchView.semanticSearchBehavior).
Settings search(Preview)Include semantic search results in the Settings editor (workbench.settings.showAISearchToggle).

Generate tests

Copilot can generate tests for functions and methods in your codebase. Get more information aboutslash commands in Chat.

ActionDescription
/testsGenerate tests for all or only the selected methods and functions in the editor. The generated tests are appended in an existing tests file or a new tests file is created.
/setupTestsGet help setting up a testing framework for your code. Get recommendation for a relevant testing framework, steps to set up and configure it, and suggestions for VS Code testing extensions.
/fixTestFailureAsk Copilot for suggestions on how to fix failing tests.
Test coverage(Experimental)Generate tests for functions and methods that are not yet covered by tests.Get more information.

Tips

  • Provide details about the testing frameworks or libraries to use.

Debug and fix problems

Use Copilot to help fix coding problems and to get help with configuring and starting debugging sessions in VS Code.

ActionDescription
/fixAsk Copilot for suggestions on how to fix a block of code or how to resolve any compiler or linting errors in your code. For example, to help fix unresolved Node.js package names.
/fixTestFailureAsk Copilot for suggestions on how to fix failing tests.
/startDebugging(Experimental)Generate alaunch.json debug configuration file andstart a debugging session from the Chat view.
copilot-debug commandTerminal command to help youdebug your programs. Prefix a run command to start a debugging session for it (for example,copilot-debug python foo.py).

Tips

  • Provide additional information about the type of fix you need, such as optimizing the memory consumption or performance.
  • Watch for Copilot Code Actions in the editor that indicate suggestions for fixing problems in your code.

Scaffold a new project

Copilot can help you create a new project by generating a scaffold of the project structure, or generate a notebook based on your requirements.

ActionDescription
Agent modeUseagent mode and use a natural language prompt to create a new project or file. For example,Create a svelte web application to track my tasks.
/newUse the/new command in the Chat view to scaffold a new project or a new file. Use natural language to describe the type of project/file you need, and preview the scaffolded content before creating it.
Example:/new Express app using typescript and svelte
/newNotebookUse the/newNotebook command in the Chat view to generate a new Jupyter notebook based on your requirements. Use natural language to describe what the notebook should contain.
Example:/newNotebook get census data and preview key insights with Seaborn.

Terminal

Get help about shell commands and how to resolve errors when running commands in the terminal.

ActionDescription
⌘I (Windows, LinuxCtrl+I)Start terminal inline chat to use natural language for asking about shell commands and the terminal.
Example:how many cores on this machine?
@terminalUse the@terminal participant in the Chat view to ask questions about the integrated terminal or shell commands.
Example:@terminal list the 5 largest files in this workspace
@terminal /explainUse the/explain command in the Chat view to explain something from the terminal.
Example:@terminal /explain top shell command

Python and notebook support

You can use chat to help you with Python programming tasks in the Native Python REPL and in Jupyter notebooks.

ActionDescription
Generate
⌘I (Windows, LinuxCtrl+I)
Start Inline Chat in a notebook to generate a codeblock or Markdown block.
#Attach variables from the Jupyter kernel in your chat prompt to get more relevant responses.
Native REPL +⌘I (Windows, LinuxCtrl+I)Start Inline Chat in the Native Python REPL and run the generated commands.
⌃⌘I (Windows, LinuxCtrl+Alt+I)Open theChat view and use edit or agent mode to make notebook edits.
/newNotebookUse the/newNotebook command in the Chat view to generate a new Jupyter notebook based on your requirements. Use natural language to describe what the notebook should contain.
Example:/newNotebook get census data and preview key insights with Seaborn.

Next steps

07/09/2025

[8]ページ先頭

©2009-2025 Movatter.jp