Inline chat
With Copilot inline chat in Visual Studio Code, you can ask questions and get suggestions directly in the editor or get help with shell commands within the integrated terminal. Inline chat allows you to stay in the flow of your work without having to switch to a separate Chat view.
Prerequisites
- Install the latest version ofVisual Studio Code
- Access toCopilot
Use editor inline chat
When you use editor inline chat, your prompt is scoped to the code in the active editor. Inline chat might use the content from other files in your workspace as context for your prompt.
To use editor inline chat:
Open a file in the editor.
Open editor inline chat by using the⌘I (Windows, LinuxCtrl+I) keyboard shortcut or selectingEditor Inline Chat from the Copilot menu in the title bar.
Notice how Copilot shows a chat input field at your cursor position in the editor.
Enter your prompt in the chat input field.
Select a block of code in the editor to scope the prompt to that code.
Experiment with some of these example prompts to get started:
Refactor this code to use async/await
Explain this code
Add error handling
Notice that Copilot shows code suggestions inline in the editor. Accept or reject the changes.
Optionally, ask a follow-up question to get other or suggestions or refine the results.
Attach context to your Inline Chat prompt to include relevant files, code symbols, or other context. Learn more aboutadding context to your chat prompt.
Use terminal inline chat
You can bring up terminal inline chat in theintegrated terminal to get help with shell commands or ask terminal-related questions.
To use terminal inline chat:
Open the terminal in VS Code by selecting theView >Terminal menu item or using the⌃` (Windows, LinuxCtrl+`) keyboard shortcut.
Open terminal inline chat by using the⌘I (Windows, LinuxCtrl+I) keyboard shortcut or running theTerminal Inline Chat command in the Command Palette.
Copilot shows a chat input field at the current position in the terminal.
Enter your prompt in the chat input field.
Experiment with some of these example prompts to get started:
How do I install npm packages?
List the top 5 largest files in the src directory
undo the last git commit
Review the response and select theRun (⌘Enter (Windows, LinuxCtrl+Enter)) to run the command in the terminal
Optionally, selectInsert (⌥Enter (Windows, LinuxAlt+Enter)) to insert the command into the terminal and modify it before running.
Related resources
- Get a quick overview of the Copilot features in VS Code
- Add context to your chat prompt
- Start a multi-file coding session
- Start an agentic coding workflow