How to Use Cursor's Inline Editing (Cmd+K)
Use Cursor's Cmd+K inline editing to generate, transform, and refactor code directly in your editor without leaving context.
Step-by-step
How to Use Cursor's Inline Editing (Cmd+K)
Select code (optional) and press Cmd+K
Select the code you want to modify and press Cmd+K. If no code is selected, Cursor generates new code at the cursor position. A prompt bar appears inline.
Describe the change
Type a natural language instruction: 'add error handling', 'convert to async/await', 'optimize this loop', or 'add TypeScript types'. Be specific for better results.
Review the inline diff
Cursor shows the proposed change as an inline diff — green for additions, red for deletions. Review the change to make sure it's correct.
Accept or reject
Press Tab or Enter to accept the change, Escape to reject it. You can also edit the prompt and try again for a different result.
Tips
Pro tips
- *
Cmd+K works anywhere — in code files, config files, markdown, even terminal
- *
Select a larger block of code to give Cursor more context for better edits
- *
Chain Cmd+K operations: generate code, then select it and refine with another Cmd+K
Related guides