How can you create multiple cursors in Visual Studio Code
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Multiple cursors are one of the highest-leverage editing features in Visual Studio Code. Instead of repeating the same change line by line, you create several active carets and type once, which is especially useful for local, visible edits that do not justify a full refactor or global replace.
Manual Cursor Placement
The most direct technique is mouse-based:
- Windows and Linux:
Alt+ click - macOS:
Option+ click
Each click adds another cursor where you place it. This works well when the target locations are visually obvious but not identical text matches.
For example, if you need to add commas to a few unrelated lines, manual placement is often faster than any selection command.
Add Cursors Above Or Below
If the edit points line up vertically, use stacked cursors instead of repeated clicking:
- Windows and Linux:
Ctrl+Alt+DownandCtrl+Alt+Up - macOS:
Option+Cmd+DownandOption+Cmd+Up
This creates one cursor per line directly above or below the current cursor.
That is useful for editing a block like this:
Put the first cursor on the number or the name, add cursors downward, and edit the whole column at once.
Select Matching Occurrences
When the same text appears repeatedly, VS Code can create multiple cursors from the current selection:
- '
Ctrl+Don Windows and Linux' - '
Cmd+Don macOS'
Each keypress adds the next occurrence of the selected text. This is ideal when you want a few matches, not every match in the file.
If you want all current matches immediately:
- '
Ctrl+Shift+Lon Windows and Linux' - '
Cmd+Shift+Lon macOS'
That is convenient for simple text edits. For actual symbol renames in code, the language-aware rename action is usually safer because it respects scope and syntax.
Add One Cursor To Every Selected Line
The official VS Code productivity docs highlight a very useful shortcut: place a cursor at the end of every selected line.
- Windows and Linux:
Shift+Alt+I - macOS:
Shift+Option+I
This is perfect for adding a suffix such as a comma or semicolon:
After selecting those lines and using the shortcut, typing , gives:
Box Selection And Column Edits
When text is column-shaped, box selection is often better than ordinary cursor stacking. It lets you create a rectangular selection and type at the same horizontal position on multiple lines.
This is useful for:
- inserting a prefix at the same column on many lines
- editing a fixed-width block of text
- aligning repeated values in structured data
It is one of the best ways to edit tabular data in a general-purpose editor without reaching for a spreadsheet.
The editor.multiCursorModifier Setting
VS Code also lets you choose which modifier key is used for mouse-based multiple cursors through the editor.multiCursorModifier setting. That matters if the default conflicts with other gestures on your platform or window manager. If cursor placement feels wrong, check the setting before assuming the feature is broken.
When Multiple Cursors Are The Wrong Tool
Multiple cursors are still plain text editing. Use them when you can see the exact edit points and want to control them manually. Use something else when the change is semantic or global:
- multi-cursor for local repeated edits
- rename refactor for identifiers and symbols
- search-and-replace for broad file-wide patterns
Choosing the right tool matters more than memorizing every shortcut.
Common Pitfalls
- Using multiple cursors for symbol renames that should be handled by the rename refactor.
- Creating too many cursors at once and not noticing one is in the wrong place.
- Forgetting that
Ctrl+DandCmd+Dselect text matches, not semantic references. - Ignoring
Shift+Alt+IorShift+Option+Iwhen the task is just adding the same suffix to many lines. - Overlooking the
editor.multiCursorModifiersetting when mouse gestures do not behave as expected.
Summary
- Use
AltorOptionclick for manual cursor placement. - Use stacked cursors for vertically aligned edits.
- Use
Ctrl+DorCmd+Dfor the next match andCtrl+Shift+LorCmd+Shift+Lfor all matches. - Use
Shift+Alt+IorShift+Option+Ito put a cursor at the end of every selected line. - Prefer multiple cursors for local text edits, not semantic refactors.

