Overview
AI-powered in-line edits
Windsurf Command generates new or edits existing code via natural language inputs, directly in the editor window.
To invoke Command, press ⌘+I
on Mac or Ctrl+I
on Windows/Linux.
From there, you can enter a prompt in natural language and hit the Submit button (or ⌘+⏎
/Ctrl+⏎
) to forward the instruction to the AI.
Windsurf will then provide a multiline suggestion that you can accept or reject.
If you highlight a section of code before invoking Command, then the AI will edit the selection spanned by the highlighted lines. Otherwise, it will generate code at your cursor’s location.
You can accept, reject, or follow-up a generation by clicking the corresponding code lens above the generated diff,
or by using the appropriate shortcuts (⌥+A
/Alt+A
, ⌥+R
/Alt+R
, and ⌥+F
/Alt+F
, respectively).
To invoke Command, press ⌘+I
on Mac or Ctrl+I
on Windows/Linux.
From there, you can enter a prompt in natural language and hit the Submit button (or ⌘+⏎
/Ctrl+⏎
) to forward the instruction to the AI.
Windsurf will then provide a multiline suggestion that you can accept or reject.
If you highlight a section of code before invoking Command, then the AI will edit the selection spanned by the highlighted lines. Otherwise, it will generate code at your cursor’s location.
You can accept, reject, or follow-up a generation by clicking the corresponding code lens above the generated diff,
or by using the appropriate shortcuts (⌥+A
/Alt+A
, ⌥+R
/Alt+R
, and ⌥+F
/Alt+F
, respectively).
To invoke Command, press ⌘+I
on Mac or Ctrl+I
on Windows/Linux.
Some users have reported keyboard conflicts with this shortcut, so ⌘+⇧+I
and ⌘+\
on Mac (Ctrl+⇧+I
and Ctrl+\
on Windows/Linux)
will also work.
The Command invocation will open an interactive popup at the appropriate location in the code. You can enter a prompt in natural language and Windsurf will provide a multiline suggestion that you can accept or reject. If you highlight a section of code before invoking Command, then the AI will edit the selection spanned by the highlighted lines. Otherwise, it will generate code at your cursor’s location.
The Command popup will persist in the editor if you scroll around or focus your cursor elsewhere in the editor. It will act on your most recently highlighted selection of code or your most recent cursor position. While it is active, the Command popup gives you the following options:
- Cancel (
Esc
): this will close the popup and undo any code changes that may have occured while the popup was open. - Accept generation (
⌘+⏎
): this option appears after submitting an instruction and receiving a generation. It will write the suggestion into the code editor and close the popup. - Undo generation (
⌘+⌫
): this option appears after submitting an instruction and receiving a generation. It will restore the code to its pre-Command state without closing the popup, while reinserting your most recent instruction into the input box. - Follow-up: this option appears after submitting an instruction and receiving a generation. You can enter a second (and third, fourth, etc.) instruction and submit it, which will undo the currently shown generation and rerun Command using your comma-concatenated instruction history.
Best Practices
Windsurf Command is great for file-scoped, in-line changes that you can describe as an instruction in natural language. Here are some pointers to keep in mind:
-
The model that powers Command is larger than the one powering autocomplete. It is slower but more capable, and it is trained to be especially good at instruction-following.
-
If you highlight a block of code before invoking Command, it will edit the selection. Otherwise, it will do a pure generation.
-
Using Command effectively can be an art. Simple prompts like “Fix this” or “Refactor” will likely work thanks to Windsurf’s context awareness. A specific prompt like “Write a function that takes two inputs of type
Diffable
and implements the Myers diff algorithm” that contains a clear objective and references to relevant context may help the model even more.