Docs › Using the editor › Edit and ask about a selection
Edit and ask about a selection
Rewrite selected code in place, ask about it in a new chat, or add it, a file, terminal output or problems to the chat.
On this page
- Edit Selection
- Messages you might see
- The buttons above a selection
- Adding things to the chat
- If something goes wrong
You do not have to open the chat and describe where something is. Select it in the editor, then rewrite it in place, ask about it, or hand it to the chat as context.
Edit Selection
Edit Selection rewrites the code you selected from one instruction, without a chat. It is quick and narrow: it changes the selection and nothing else.
- Select the code to change.
- Right-click and choose Edit Selection, or run AstraCode: Edit Selection from the command palette.
- In Edit selection, say what the code should do instead (What should this code do instead?), for example
handle the empty case, or convert to async. Press Enter. - The status bar says Editing selection… while it works. The new code replaces your selection.
- Review it like any agent change: Keep or Undo above the change, Cmd+Y or Cmd+N (Ctrl+Y or Ctrl+N on Windows and Linux) at the cursor, or Cmd+Z (Ctrl+Z) as for any edit.
Edit Selection has no keyboard shortcut. To give it one, open Keyboard Shortcuts (Cmd+K Cmd+S, or Ctrl+K Ctrl+S on Windows and Linux), search for
astracode.inlineEdit, and set a key.
Your always-on custom instructions apply to it, as they do to the chat. For anything that spans files or needs commands run, use the chat in Agent mode.
Messages you might see
| Message | What to do |
|---|---|
| Select some code first, then run Inline Edit. | Select the code, then run it again. Don't show again hides this warning; Reset "Don't Ask Again" Dialogs in AstraCode Settings, General, brings it back. |
| Not signed in. | Run AstraCode: Sign In. |
| Inline edit: no change suggested. | The instruction led to no change. Say more precisely what should be different. |
| Inline edit failed: followed by a reason | The reason says what happened. Report this sends a report. |
| Inline edit could not be applied. | The editor did not accept the change to the file. Try again, or ask in the chat. |
The buttons above a selection
Select at least 12 characters, on no more than 400 lines, and two buttons appear above the selection:
- Add to chat (⌥K): attaches the selection to the chat you have open. See below.
- Edit: edits the selection in place from an instruction you type (AstraCode: Edit Selection).
Report a problem with selected code is on the editor's right-click menu. See Reporting a problem. AstraCode: Ask About This Selection in the command palette still starts a new chat with a question about the selection.
Adding things to the chat
| From | How | What is attached |
|---|---|---|
| A selection in the editor | Option+K (Alt+K on Windows and Linux), Add to chat above it, or right-click, Add Selection to Chat | The selected lines, up to 20,000 characters, and @path#lines in your message. |
| A file | Right-click it in the Explorer or on its editor tab, Add to Chat | The file. Select several in the Explorer to add them all. |
| The terminal | Select output and choose Add to Chat beside it, press Cmd+L (Ctrl+L on Windows and Linux) or Option+K (Alt+K), or right-click, Add to Chat | The selected output; with nothing selected, the last command and its output, up to 12,000 characters. |
| Text in the chat | Select it in an answer or a tool's output and choose Reply, or press Option+K (Alt+K) | The passage, as a quote. |
| The Problems panel | Right-click a problem, Add to Chat | That problem. |
| All problems | AstraCode: Add Problems to Chat, or type @ and choose Problems | Every error and warning, up to 100. |
If the chat is not open, it opens. Whatever is attached shows as a chip above the composer until you send or remove it. The selection you have in the editor also travels with each message on its own chip; see The chat panel.
Sending the terminal's last command needs the terminal's shell integration, which is on by default in the editor's own terminal. Without it, select the output you want instead.
If something goes wrong
- Open a file to add it, or a selection of it, to the chat. Option+K needs an open file.
- Nothing to attach from the terminal yet: run a command in it (with shell integration on), or select some of its output. Run a command first, or select the output.
- The buttons do not appear above a selection. The selection is under 12 characters or over 400 lines. Use Option+K (Alt+K) instead.
- No bar beside text selected in the chat. It does not appear on your own messages, or when Selection Bar is off in Settings; Option+K still adds the selection as a quote.
More in Chat panel problems.
← Tab completion Reviewing the agent's changes →
All documentation
Get started
Using the editor
- Tab completion
- Edit and ask about a selection
- Reviewing the agent's changes
- Git: commit messages, branch review and conflicts
- Dictation
- Layout, themes and the settings page
Agent
- Agent overview
- Agent, Plan, Ask and Debug
- Approvals and permissions
- Plan mode
- Debug mode
- Tools
- Browser tools
- How the agent checks its work
- Checkpoints and undo
- Running several agents at once
- Subagents and background tasks
- Remote agents in GitHub Actions
- Infrastructure as code
Context
Workspaces
Connectors
- Connectors (MCP servers)
- Connector configuration reference
- Use AstraCode from Claude, ChatGPT and other apps
Extending AstraCode
CLI
Account and usage
- Usage and limits
- Bring your own key
- What AstraCode sends and keeps
- Reporting a problem and getting help
Troubleshooting
- Troubleshooting
- Sign-in problems
- Install and update problems
- Chat panel problems
- Agent run problems
- Connector problems
- Dictation problems
- Usage, billing and network errors
- CLI problems