Cmd+K is your quick-edit tool in the editor. Highlight code and press Cmd+K to change it by describing what you want. No agent conversation needed. In the Agents Window, Cmd+K searches instead.
The Cmd+K Workflow
Highlight code in your editor
Select the code you want to change.
Press Cmd+K (Mac) or Ctrl+K (Windows)
A prompt bar appears right above your code.
Type your instruction
Tell the AI what to do: "Make it faster", "Add error handling", "Use Tailwind instead"
Press Enter
Cursor edits the code inline and shows you the result.
Example Edits
Here's what Cmd+K can do. Select the code and try:
if (user) { alert("Welcome"); }Cmd+K → "Convert to console.log instead of alert"
if (user) { console.log("Welcome"); }Cmd+K or the agent: when to use which
Both use AI, but for different situations:
- Cmd+K: Quick changes to existing code (refactor, fix, adjust)
- The agent (lesson 5): New features, changes across several files, explanations (Ask mode) and debugging
- Cmd+L with code selected sends it to the agent if a quick edit turns out to be bigger
Bonus: Cmd+K in Terminal
You can also use Cmd+K in the Terminal (bottom of Cursor) to generate shell commands from natural language:
Click in the Terminal
Focus the terminal at the bottom of the screen.
Press Cmd+K (Mac) or Ctrl+K (Windows)
A prompt appears in the terminal.
Describe what you want
"Remove all node_modules folders" or "Restart the dev server"
Press Enter
Cursor generates and runs the command.
Always review terminal commands before pressing Enter. The AI might misunderstand, and bad terminal commands can cause problems.
Inline Editing Mastered!
- You can select code and use Cmd+K to edit it
- You know when to use Cmd+K and when to use the agent
- You know how to use Cmd+K in the terminal
- You're confident with quick, targeted edits
Cmd+K is your quick tool for small edits in the editor. Next, Design Mode: changing a running prototype by pointing at it.