Make Inline Edits (Cmd+K)
Cmd+K is your quick-edit tool. Highlight code and press Cmd+K to refactor, fix, or modify it with natural language instructions. No Chat panel needed.
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 vs Chat (Cmd+L): When to Use Which
Both use AI, but for different situations:
- **Cmd+K**: Quick changes to existing code (refactor, fix, adjust)
- **Chat (Cmd+L)**: Explanations, debugging, understanding code, creating new code from scratch
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 understand the difference between Cmd+K and Chat
- You know how to use Cmd+K in the terminal
- You're confident with quick, targeted edits
Perfect! Cmd+K is your speed tool for edits. Next, meet Composer—the power tool for generating entire features.