Basics
Cursor Inline Edit: Editing Code in Place with Cmd+K
Inline edit lets you make quick, targeted code changes without opening the chat panel. Select the code you want to change, press Cmd+K on Mac or Ctrl+K on Windows and Linux, type an instruction such as "Convert this to an async function", and press Enter. Cursor applies the edit to the selection in place, and follow-up instructions refine it.
On this page
What is inline edit in Cursor?
Inline edit is the shortest path between a selection and a change. You stay in the editor, the prompt opens over the code you highlighted, and the result lands on that selection - no chat panel, no re-explaining which file you meant. It is built for quick, targeted edits: rename a pattern, convert a function, tighten a block.
Inline edit works on the code you select and applies the edit in place. If the change spans several files, that is Agent's job, not inline edit's - see the last section for the one-key handoff.
How do I use inline edit?
The loop is five steps, and the fifth is the one people forget: you can keep talking to the same prompt until the edit is right. Cursor's documented sequence:
- 1Select the code you want to change.
- 2Press
Cmd+Kon Mac, orCtrl+Kon Windows and Linux. - 3Type your instructions - for example, "Convert this to an async function."
- 4Press Enter. Cursor applies the edit to your selected code.
- 5To refine, add follow-up instructions and press Enter again.
How do I ask a quick question with inline edit?
The same prompt has a second mode: instead of editing the selection, it answers a question about it. Switch modes with a modifier on Enter, then ask. The table below shows the two keystrokes per platform.
- Action
- Open inline edit on a selection
- Mac
- Cmd + K
- Windows / Linux
- Ctrl + K
- Action
- Switch to question mode
- Mac
- Opt + Enter
- Windows / Linux
- Alt + Enter
- Action
- Open Agent with the selection
- Mac
- Cmd + L
- Windows / Linux
- Ctrl + L
| Action | Mac | Windows / Linux |
|---|---|---|
| Open inline edit on a selection | Cmd + K | Ctrl + K |
| Switch to question mode | Opt + Enter | Alt + Enter |
| Open Agent with the selection | Cmd + L | Ctrl + L |
Keystrokes as documented at cursor.com/help/ai-features/inline-edit.
Once you are in question mode, type your question about the selected code. If the answer includes a change you want, you do not have to retype it as an instruction: type "do it" and press Enter, and Cursor applies the suggested change.
Can I switch from inline edit to Agent?
Yes, and the handoff keeps your selection. Inline edit is scoped to the code you highlighted; when a change needs to touch several files or reason across the codebase, that scope stops being useful. Select the code and press Cmd+L on Mac, or Ctrl+L on Windows and Linux. Agent opens with your selected code already attached as context, so you restate the task, not the location.
Inline edit for a change confined to a selection. Agent mode for multi-file edits or more complex changes. The line is where the edit lands, not how many lines you typed to ask for it.
Frequently asked questions
What is the keyboard shortcut for inline edit in Cursor?
Select the code, then press ⌘K on Mac or CtrlK on Windows and Linux. Type your instruction and press Enter to apply the edit to the selection.
Can inline edit answer a question instead of editing my code?
Yes. Open inline edit on a selection, then press ⌥↵ on Mac or ⌥↵ on Windows and Linux to switch to question mode. Ask your question; if you want to apply a change it suggests, type "do it" and press Enter.
When should I use Agent instead of inline edit?
Use Agent for multi-file edits or more complex changes. Select the code and press ⌘L (CtrlL on Windows and Linux) to open Agent with that selection as context.
Sources & last verified
Cursor ships frequently. Facts verified against primary sources on July 9, 2026.