
- macOS:
Command+I - Windows / Linux:
Ctrl+I - Or: right-click the editor → “Copilot Editor → Inline Chat”
Invoke inline chat by selecting code and typing a prompt (for example,
explain or /explain). Use “View in Chat” to open the same content in the sidebar chat if you prefer a larger workspace.- Get immediate explanations for selected code.
- Request refactors or configuration changes in-place.
- Generate helper functions, unit-test scaffolding, or documentation.
- Keep context inside the editor — no context switching to a browser.
Explaining code with Inline Chat
Select a code block and ask Copilot to explain it. The tool will break down intent, variables, and control flow, and provide a short summary.
Example: logic that determines whether a car moving north should stop at a stop line, obey a traffic light, and maintain a safe gap.
front represents, why the light state is checked, and how SAFE_GAP prevents collisions. Use /explain or a natural-language prompt like “Explain this logic” to get a line-by-line explanation plus a short summary.
Inspecting a method or class
Run inline chat against a method or an entire class to get more context. Example Car class with initialization and an update method that contains the above logic:
get_light_state. It can scaffold tests using pytest or unittest, including example assertions you can refine.
Example terminal output when installing pytest:
Be mindful of sensitive data. Do not paste secrets, private keys, or proprietary code into inline chat prompts. Review generated code for correctness, edge cases, and security implications before merging.
- Provide focused prompts (e.g., “simplify this loop” or “add edge-case tests for red light behavior”).
- Use “View in Chat” to move longer interactions into the sidebar for a larger workspace and persistent context.
- Review and run generated tests locally; treat suggestions as starting points, not final production code.