Inline Edit (Cmd/Ctrl+K)

Cursor · Essentials · 8 min

Inline Edit is the right size for focused changes where you already know exactly which code should change.

Inline Edit works on the code you have selected. Select a function or a few lines, press Cmd+K (Mac) or Ctrl+K (Windows/Linux), type what you want ("convert to async/await", "add input validation and a docstring") and submit. Cursor shows the change as a diff right in the editor: removed lines in red, added lines in green. Accept it, reject it, or type a follow-up instruction to refine it.

Two related moves:

  • Quick question: after opening inline edit on a selection, switch to question mode with Opt+Enter (Mac) or Alt+Enter (Windows/Linux) and ask "why does this loop skip the last item?". If you like the suggested fix, reply "do it" to apply it.
  • Send to Agent: if the change grows beyond the selection (other files, tests to run), select the code and press Cmd+L / Ctrl+L to open Agent with that selection attached as context.

Choosing between the three features:

  • Tab: you are already typing the change.
  • Inline Edit: one place, clear instruction, you want to see the diff immediately.
  • Agent: several files, needs searching, or should run commands.

Inline Edit sees mainly your selection and nearby code, so name what matters: "use our Result type from errors.ts" works better than "handle errors properly". Keep selections focused; selecting a whole 2,000-line file gives the model too much to change at once and makes review harder.

Remember

  • Select code, Cmd/Ctrl+K, describe, review the inline diff
  • Opt/Alt+Enter switches to a quick question; "do it" applies the answer
  • Cmd/Ctrl+L sends the selection to Agent when the change grows

Watch out for

  • Using Inline Edit for a change that also needs edits in other files, then fixing the rest by hand.

Check yourself

  1. Your selected function's fix also needs a new test file and a test run. What's the better move?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: cursor.com/docs/inline-edit/overview

Builds on

Unlocks

Nothing builds on this yet.