2025年8月31日日曜日

Ask Mode in VS Code Copilot Chat

 Ask Mode is designed for natural language interaction with your codebase. It's ideal for asking coding questions, understanding your project, and exploring technology concepts — all without modifying your code.


🔧 Prerequisites

  • Visual Studio Code (latest version)

  • GitHub Copilot Access (Free plan includes limited chat usage)


💡 Why Use Ask Mode?

Use Ask Mode for:

Task TypeExample
🧠 Understanding code"Where is the database connection string defined?"
💭 Brainstorming"What are 3 ways to implement caching?"
💻 Coding help"How do I create a new React component?"
📚 Learning concepts"Explain the factory design pattern"

📝 Responses often include code blocks, terminal commands, or symbol references.


🚀 How to Use Ask Mode

  1. Open Chat View

    • Ctrl+Alt+I (Windows/Linux)

    • Use command: “Open Chat”

  2. Select Ask Mode

    • Choose "Ask" from the dropdown next to the input box

  3. Type a Question

    • Example:

      "How do I fetch data with Axios in React?"

  4. Send your question

    • Press Enter or click Send


🧱 Add Context for Smarter Answers

Use #-mentions

Attach files, folders, symbols, or context variables:

"Where is the login token stored? #codebase" "Explain this #auth.service.ts" "Summarize changes in #changes"

➡️ Type # in the chat box to browse available items

Use @-mentions

Refer to built-in participants (like experts):

"@vscode how do I format code on save?" "@terminal how do I find large files?"

Use /slash Commands

Trigger specific tasks:

  • /explain – Explains selected code

  • /fix – Proposes a fix for an issue

  • /test – Generates tests

➡️ Type / to see available slash commands


🧩 Quick Chat (Lightweight Prompting)

For quick one-off questions:

  • Ctrl+Shift+Alt+L to open Quick Chat

  • Found under Copilot Menu → Quick Chat

➡️ You can promote a Quick Chat to a full session using “Open in Chat View


✍️ Apply Code from Chat Responses

When Copilot provides a code block:

  • Hover over the block

  • Click Apply in Editor to insert it smartly into your file

💡 Alternatively:

  • Copy, Insert at Cursor, or Insert into Terminal (for shell commands)

Keyboard Shortcuts:

  • Next Code Block: Ctrl+Alt+PageDown

  • Previous Code Block: Ctrl+Alt+PageUp


🧠 Tips for Effective Use

TipHow
Add project-specific contextUse #codebase, #<file>, or drag files into chat
Use IntelliSense for promptsPress #, @, or / to auto-suggest context items
Prefer Ask Mode for Q&AUse Edit/Agent mode for making actual code changes
Use instruction filesDefine custom style/rules once for all chats (Markdown)

📘 Example Prompts

"What is the purpose of #auth.ts?" "Explain this function #sortUsers" "Create a reusable input component in React" "List open ports on localhost @terminal" "Suggest 3 performance improvements for this code"

📚 Related Features

0 件のコメント:

コメントを投稿