In this categoryCursor · 26
- How to Install Cursor and Import VS Code Settings (6 Minutes)Start
- Cursor Setup Guide: From Install to Your First AI Edit
- How to Set Up Project Rules in the .cursor/rules Folder
- How to Set Up Codebase Indexing in Cursor
- How to Enforce Project Conventions with Cursor Rules
- How to Write a Team Rule That Applies Only to Certain Files
- How to Migrate a Legacy .cursorrules File to the New Rules Folder
- How to Use Cursor Rules to Guide AI Edits
- How to Set Project Rules in Cursor
- How to Add a .cursorrules File to Steer Cursor
- How to Customize Cursor Keyboard Shortcuts
- How to Edit Multiple Files at Once with Cursor Composer
- How to Use Cursor Tab Completion Effectively
- How to Edit Code Inline with Cmd+K in Cursor
- How to Add Context to Cursor Chat with @ Mentions
- How to Choose and Switch AI Models in Cursor
- How to Add Library Docs as Context with @Docs in Cursor
- How to Generate and Maintain Tests with Cursor Composer
- How to Undo a Composer Change with Checkpoints in Cursor
- How to Use Cursor Agent Mode to Build a Feature End to End
- How to Connect an MCP Server to Cursor
- How to Refactor Across Your Whole Codebase in Cursor
- How to Query Your Database from Cursor with a Postgres MCP Server
- How to Let Cursor Run Commands Automatically (and Keep It Safe)
- How to Build a Full Feature Across Frontend and Backend with Composer
- How to Debug an MCP Server That Will Not Connect in Cursor
How to Edit Code Inline with Cmd+K in Cursor
Use the inline edit prompt to rewrite a selection in place, generate new code, and review the diff before accepting.
Inline edit is Cursor's fastest way to change code without leaving the file. You select code, press Cmd+K, describe the change in plain English, and Cursor rewrites the selection in place with a diff you approve. This guide walks through a real edit from selection to accept.
What you need
- Cursor installed and signed in
- A file with some code you want to change
- A clear, short description of the change
Step 1: Select and open the prompt
Highlight the lines you want to change, then press Cmd+K (Ctrl+K on Windows). A small prompt box appears right above the selection. With nothing selected, Cmd+K instead generates new code at the cursor.
Step 2: Describe the change
Type an instruction, not code. Be specific about the outcome you want. Reference symbols or other files with @ if the edit needs context from elsewhere in the project.
Step 3: Review the diff
Cursor shows the proposed change as a colored diff inline: removed lines in red, added lines in green. Read it before accepting. You can accept, reject, or type a follow-up to refine without starting over.
- function toMoney(n) {
- return "$" + n
+ function toMoney(n: number) {
+ return n.toLocaleString("en-US", {
+ style: "currency",
+ currency: "USD",
+ })
}Step 4: Accept or refine
Press Enter or click Accept to apply the change. If it is close but not right, type a correction like make the currency a parameter and Cursor revises the same selection again.
Result: a one-line, plain-English instruction turns an untyped string concatenation into a properly typed, locale-aware currency formatter, applied in place after you reviewed the diff.
Watch related tutorials
41:18
28:05
3:12
39:10
32:18
10:00New guides in your inbox
Fresh step-by-step how-to guides as we publish them. One email a week, no more.