3. Multi-Cursor & Advanced Editing

Standard text editors force you to edit lines one-by-one. In VS Code, you can edit multiple lines simultaneously, mass-generate repetitive configurations, and restructure blocks of code using simple keyboard operations.

Multi-Cursor Click & Drag

Need to add a prefix to 5 separate lines of code? Instead of typing it 5 times, add multiple active cursors to your screen:

  • Manual Cursors: Press Alt + Click (or Option + Click on macOS) on any position to insert an active cursor. Anything you type will appear at every cursor point simultaneously!
  • Vertical Stack Cursors: Add cursors straight up or down using Ctrl + Alt + Up/Down (Cmd + Option + Up/Down). Great for editing aligned lists or CSV outputs.

Mastering Selection Shortcuts

Speed up your bulk refactorings by letting VS Code select target words automatically:

  1. Select Next Occurrence: Double-click a word (like a variable name) and press Ctrl + D (Cmd + D). This finds the next matching occurrence and inserts a cursor. Repeating this shortcut lets you selectively batch edit multiple variables!
  2. Select All Occurrences: Highlight a word and press Ctrl + F2 (Cmd + F2) to instantly select and edit *every* instance of that word inside your active file!
  3. Shrink/Expand Selection: Highlight code blocks hierarchically using Shift + Alt + Left/Right (Control + Shift + Left/Right). This expands selection outward to matching brackets, functions, and elements.

Fast Line Restructuring

Copy-pasting lines to duplicate them or cutting and pasting to move them takes multiple keys. VS Code handles line manipulation natively:

1. Copy Line Up/Down

Duplicate your active line or highlighted block instantly without using clipboard commands:

PlatformDuplicate Down Shortcut
Windows / LinuxShift + Alt + Down
macOSShift + Option + Down

2. Move Line Up/Down

Move lines of code or whole blocks up or down through the file. VS Code handles indentation changes automatically:

  • Press Alt + Up / Down (Option + Up / Down on macOS).

Column Selection Mode

When you want to select a neat rectangular box of text (e.g. copying just the column values of a text table), enable Column Selection:

  1. Hold down Shift + Alt (Shift + Option on macOS).
  2. Click and drag your cursor diagonally over the text.
  3. VS Code will select a perfect bounding box of columns and insert cursors at the end of each selected line!
Pro Tip: Hit Ctrl + U (Cmd + U on macOS) to undo the last cursor operation! If you make a mistake and select one cursor too many using Ctrl + D, pressing undo removes the last cursor while keeping your previous selections active!