Cursor Documentation
  1. ⌘K
Cursor Documentation
  • Get Started
    • Introduction
    • Installation
    • FAQ
  • Guides
    • Editor Migration
      • Migrate from VS Code
      • Migrate from JetBrains IDEs
    • Languages & Frameworks
      • JavaScript & TypeScript
      • iOS & macOS (Swift)
      • Java
  • Editor
    • AI Commit Message
    • Notepads (Beta)
    • Keyboard Shortcuts
    • Tab
      • Overview
      • Tab vs GitHub Copilot
      • Auto-import
      • Advanced Features
    • Chat
      • Overview
      • Agent mode
      • Ask mode
      • Custom modes
      • Tools
      • Apply
    • ⌘K
      • Overview
      • Terminal Cmd K
  • Context
    • Codebase Indexing
    • Rules for AI
    • Ignore Files
    • Model Context Protocol
    • @ Symbols
      • Overview
      • @Files
      • @Folders
      • @Code
      • @Docs
      • @Git
      • @Web
      • @Definitions
      • @Link
      • @Lint Errors
      • @Lint Errors
      • @Recent Changes
      • @Cursor Rules
      • @Notepads
      • @Summarized Composers
      • #Files
      • /command
  • Account
    • Plans & Usage
    • Dashboard
    • Billing
    • Business
      • Get Started
      • Members + Roles
      • Analytics
      • SSO
  • Settings
    • Models
    • Custom API Keys
    • Early Access Program
  • Troubleshooting
    • Common Issues
    • Troubleshooting Guide
    • Getting a Request ID
  1. ⌘K

Overview

Learn how to use Cmd/Ctrl K in Cursor to generate, edit code and ask questions with the Prompt Bar
Cmd K, also known or “Ctrl K” on Windows/Linux, allows you to generate new code or edit existing code in the editor window.
img

Prompt Bars#

In Cursor, we call the bar that appears when you press Ctrl/Cmd K the “Prompt Bar”. It works similarly to the AI input box for chat, in which you can type normally, or use @ symbols to reference other context.

Inline Generation#

If no code is selected when you press Ctrl/Cmd K, Cursor will generate new code based on the prompt you type in the prompt bar.
img

Inline Edits#

For in-place edits, you can simply select the code you want to edit and type into the prompt bar.
img

Follow-up Instructions#

After each generation, you can further refine the prompt by adding more instructions to the prompt bar, and pressing Enter so the AI regenerates based on your follow-up instructions.

Default Context#

By default, Cursor will try to find different kinds of useful information to improve code generation, in addition to the manual @ symbols you include.
Additional context may include related files, recently viewed files, and more. After gathering, Cursor ranks the context items by relevance to your edit/generation and keeps the top items in context for the large language model.

Quick Question#

If you press Option/Alt Enter while in the prompt bar, Cursor will respond to any questions you have about the selection, and the context you have attached.
The contents of this conversation could be further used in follow-up generations, so you could simply type “do it” after Cursor comes up with a response to generate the code after a quick question.
Modified at 2025-03-26 08:34:35
Previous
Apply
Next
Terminal Cmd K
Built with