5 min readUpdated Aug 6, 2026Beginner
Code Generation (Cmd+K)
Learn about Code Generation (Cmd+K) in this comprehensive lesson.
Cmd+K (or Ctrl+K on Windows) is your superpower in Cursor. It opens a floating prompt right in your editor.
- **To Generate:** Go to a new line, hit Cmd+K, and type what you want (e.g., "Create a fast inverse square root function").
- **To Edit:** Highlight existing code, hit Cmd+K, and tell Cursor how to modify it (e.g., "Refactor this to use async/await").
- **Accept/Reject:** Cursor shows a beautiful inline diff. Hit Enter to accept, or Esc to reject.
Prompt
Add error handling to this API fetch block and log the status code.