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

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.

  1. Select the code to change.
  2. Right-click and choose Edit Selection, or run AstraCode: Edit Selection from the command palette.
  3. 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.
  4. The status bar says Editing selection… while it works. The new code replaces your selection.
  5. 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

MessageWhat 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 reasonThe 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:

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

FromHowWhat is attached
A selection in the editorOption+K (Alt+K on Windows and Linux), Add to chat above it, or right-click, Add Selection to ChatThe selected lines, up to 20,000 characters, and @path#lines in your message.
A fileRight-click it in the Explorer or on its editor tab, Add to ChatThe file. Select several in the Explorer to add them all.
The terminalSelect 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 ChatThe selected output; with nothing selected, the last command and its output, up to 12,000 characters.
Text in the chatSelect 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 panelRight-click a problem, Add to ChatThat problem.
All problemsAstraCode: Add Problems to Chat, or type @ and choose ProblemsEvery 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

More in Chat panel problems.

← Tab completion Reviewing the agent's changes →

All documentation

Get started

Using the editor

Agent

Context

Workspaces

Connectors

Extending AstraCode

CLI

Account and usage

Troubleshooting

Reference