Skip to main content

Mastering Multi-Cursor Editing in Cursor

Multi-cursor editing is one of the most powerful features in modern code editors, and Cursor takes it further by combining traditional multi-cursor techniques with AI assistance. This guide covers everything from basic selection to advanced regex-based editing that will transform how you manipulate code.

Multi-cursor editing in Cursor

Why Multi-Cursor Editing Matters​

When you need to make the same change in multiple places, multi-cursor editing saves enormous time compared to find-and-replace or manual editing. Common scenarios include:

  • Renaming variables across multiple lines
  • Adding prefixes or suffixes to multiple items
  • Converting data formats (JSON to TypeScript interfaces, etc.)
  • Removing or adding brackets, quotes, or delimiters
  • Aligning code or comments
tip

Multi-cursor editing shines when changes are structurally similar but not identical. For truly identical replacements, find-and-replace might still be faster.

Basic Multi-Cursor Techniques​

Alt+Click (Option+Click on macOS)​

The most intuitive way to place multiple cursors is to hold Alt (or Option on macOS) and click where you want each cursor.

How to use it:

  1. Hold Alt / Option
  2. Click each location where you want a cursor
  3. Start typing -- all cursors will insert text simultaneously
// Before: Place cursors at the start of each line with Alt+Click
const user = { name: 'Alice' };
const admin = { name: 'Bob' };
const guest = { name: 'Charlie' };

// After typing 'export ' at each cursor
export const user = { name: 'Alice' };
export const admin = { name: 'Bob' };
export const guest = { name: 'Charlie' };
info

You can place up to 10,000 cursors. In practice, more than 100 becomes hard to manage visually.

Cmd+D / Ctrl+D -- Add Selection to Next Find Match​

This is the fastest way to select multiple occurrences of the same word or selection.

Basic workflow:

  1. Select a word or text segment
  2. Press Cmd+D (macOS) or Ctrl+D (Windows/Linux) to select the next occurrence
  3. Repeat to select more occurrences
  4. Edit all selections simultaneously
// Select 'status' and press Cmd+D three times
interface Task {
status: 'pending';
status: 'active';
status: 'completed';
}

// Change all to 'state'
interface Task {
state: 'pending';
state: 'active';
state: 'completed';
}

Skipping an occurrence:

If you accidentally select an occurrence you don't want to change, press Cmd+K Cmd+D (macOS) or Ctrl+K Ctrl+D (Windows/Linux) to skip the current selection and move to the next.

Selecting all occurrences at once:

Press Cmd+Shift+L (macOS) or Ctrl+Shift+L (Windows/Linux) to select all occurrences of the current word in the file.

warning

Be careful with "Select All Occurrences" in large files. You might select matches in comments or strings that you didn't intend to change.

Column Selection (Box Selection)​

Column selection lets you select a rectangular block of text, placing a cursor at the beginning of each selected line.

Mouse-Based Column Selection​

  • Windows/Linux: Hold Shift+Alt and drag
  • macOS: Hold Shift+Option and drag
# Column select the prefixes and replace them
old_prefix_item1 = 100
old_prefix_item2 = 200
old_prefix_item3 = 300
old_prefix_item4 = 400

# After column selecting 'old_prefix_' and typing 'new_'
new_item1 = 100
new_item2 = 200
new_item3 = 300
new_item4 = 400

Keyboard-Based Column Selection​

Place multiple cursors using keyboard shortcuts:

ShortcutAction
Cmd+Option+Down / Ctrl+Alt+DownAdd cursor to line below
Cmd+Option+Up / Ctrl+Alt+UpAdd cursor to line above
Cmd+Option+Shift+Down / Ctrl+Alt+Shift+DownExtend column selection down
Cmd+Option+Shift+Up / Ctrl+Alt+Shift+UpExtend column selection up
tip

Column selection is perfect for working with tabular data, aligned assignments, or any code with vertical structure.

Advanced Multi-Cursor Techniques​

Multi-Cursor with Find and Replace​

The find widget supports multi-cursor operations through regex.

  1. Open find with Cmd+F / Ctrl+F
  2. Enable regex mode (.* icon)
  3. Enter a pattern with capture groups
  4. Use $1, $2, etc. in replacement
// Convert console.log statements to a custom logger
// Find: console\.log\((.*)\);
// Replace: logger.debug($1);

console.log('User logged in');
console.log('Data fetched');
console.log('Error occurred');

// Result:
logger.debug('User logged in');
logger.debug('Data fetched');
logger.debug('Error occurred');

Regex Multi-Line Editing​

For complex transformations, combine regex with multi-cursor:

// Transform interface properties to class properties with defaults
interface Config {
timeout: number;
retries: number;
enabled: boolean;
}

// Find: (\w+): (\w+);
// Replace: public $1: $2 = defaultValues.$1;

// Result:
public timeout: number = defaultValues.timeout;
public retries: number = defaultValues.retries;
public enabled: boolean = defaultValues.enabled;

Creating Cursors at Line Ends​

Select multiple lines and press Shift+Option+I (macOS) or Shift+Alt+I (Windows/Linux) to place a cursor at the end of each selected line.

{
"name": "project"
"version": "1.0.0"
"description": "A sample project"
}

// After selecting lines and pressing Shift+Option+I, add commas
{
"name": "project",
"version": "1.0.0",
"description": "A sample project",
}

Multi-Cursor Shortcuts Reference​

ActionmacOSWindows/Linux
Add cursor at click positionOption+ClickAlt+Click
Select next occurrenceCmd+DCtrl+D
Select all occurrencesCmd+Shift+LCtrl+Shift+L
Skip current and select nextCmd+K Cmd+DCtrl+K Ctrl+D
Add cursor belowCmd+Option+DownCtrl+Alt+Down
Add cursor aboveCmd+Option+UpCtrl+Alt+Up
Column select (mouse)Shift+Option+DragShift+Alt+Drag
Cursors at line endsShift+Option+IShift+Alt+I
Undo last cursor additionCmd+UCtrl+U
Focus next cursorCmd+F6Ctrl+F6

Practical Workflows​

Workflow 1: Bulk Property Renaming​

You have an object and need to rename multiple properties:

// Step 1: Place cursors at each property name with Cmd+D
const user = {
firstName: 'John',
firstName: 'Admin', // Oops, duplicate
firstName: 'Guest',
};

// Step 2: After renaming
const user = {
firstName: 'John',
lastName: 'Doe',
role: 'Admin',
};

Workflow 2: Generating TypeScript from JSON​

Convert a JSON snippet to TypeScript interface properties:

{
"id": 1,
"title": "Hello",
"completed": false
}
  1. Paste JSON into a TypeScript file
  2. Use multi-cursor to transform each line:
    • Column select the keys
    • Add readonly prefix
    • Move cursors to after values
    • Replace with TypeScript types
readonly id: number;
readonly title: string;
readonly completed: boolean;

Workflow 3: Adding Error Handling​

Wrap multiple API calls with try-catch:

// Before
const user = await fetchUser(id);
const posts = await fetchPosts(user.id);
const comments = await fetchComments(posts[0].id);

// After multi-cursor editing
const user = await fetchUser(id).catch(handleError);
const posts = await fetchPosts(user.id).catch(handleError);
const comments = await fetchComments(posts[0].id).catch(handleError);

Combining Multi-Cursor with AI​

Cursor's AI features work alongside multi-cursor editing:

  1. Select multiple functions with multi-cursor
  2. Press Cmd+K to open inline edit
  3. Type a prompt like "add JSDoc comments"
  4. Cursor applies the transformation to all selected blocks
// Before
function add(a: number, b: number) { return a + b; }
function subtract(a: number, b: number) { return a - b; }
function multiply(a: number, b: number) { return a * b; }

// After AI multi-cursor edit
/**
* Adds two numbers
* @param a - First number
* @param b - Second number
* @returns Sum of a and b
*/
function add(a: number, b: number) { return a + b; }

/**
* Subtracts two numbers
* @param a - First number
* @param b - Second number
* @returns Difference of a and b
*/
function subtract(a: number, b: number) { return a - b; }

/**
* Multiplies two numbers
* @param a - First number
* @param b - Second number
* @returns Product of a and b
*/
function multiply(a: number, b: number) { return a * b; }

Common Pitfalls​

PitfallSolution
Cursors in wrong placesPress Escape and start over; use undo cursor (Cmd+U)
Accidental edits in comments/stringsBe selective with "Select All Occurrences"
Too many cursors to trackWork in smaller chunks, 5-10 cursors at a time
Inconsistent indentation breaks column selectionEnsure consistent tabs/spaces before column selecting
Regex replacement affects unwanted areasPreview changes before applying

Summary​

Multi-cursor editing in Cursor gives you surgical precision for bulk changes:

  • Alt+Click for precise cursor placement
  • Cmd+D / Ctrl+D for selecting repeated patterns
  • Column selection for vertical text manipulation
  • Regex find-and-replace for complex transformations
  • Combine with AI (Cmd+K) for intelligent bulk edits

Spend time mastering these shortcuts. The investment pays off every time you need to change more than a few lines at once.


Last updated: July 2025. Cursor shortcuts may vary by version and configuration.