Multi-cursor editing and IntelliSense

VS Code · Essentials · 10 min

These few shortcuts cover most day-to-day editing and save hundreds of keystrokes per day.

Multiple cursors let you type in several places at once:

  • Alt+Click (Option+Click on macOS) adds a cursor.
  • Ctrl+D selects the next occurrence of the current word or selection, adding a cursor; repeat to add more, Ctrl+K Ctrl+D skips one.
  • Ctrl+Shift+L selects all occurrences.
  • Ctrl+Alt+Up/Down (Option+Cmd+Up/Down on macOS) adds cursors on the lines above or below; Shift+Alt + drag makes a column selection.

Line operations: Alt+Up/Down moves the current line, Shift+Alt+Up/Down copies it, Ctrl+Shift+K deletes it, Ctrl+/ toggles a comment, Ctrl+Enter inserts a line below.

IntelliSense suggests completions as you type, using the language service for the file type; Ctrl+Space triggers it manually and Ctrl+Shift+Space shows parameter hints. The quality depends on the language extension (for example Pylance for Python).

Code actions: a light bulb, or Ctrl+., offers quick fixes such as adding a missing import. F2 renames a symbol across files safely, unlike find-and-replace. Shift+Alt+F formats the document (Ctrl+Shift+I on Linux) with the configured formatter.

Use Ctrl+D for "change this variable here and in the next few places" and F2 when you want every reference in the project.

Example

# rename three occurrences of 'item' to 'product':
#   double-click 'item', Ctrl+D, Ctrl+D, then type 'product'
# add a semicolon to 5 lines:
#   Ctrl+Alt+Down x4, End, type ';'
# Alt+Up / Alt+Down          move line
# Shift+Alt+Down             duplicate line below
# Ctrl+/                     toggle line comment
# Ctrl+Space                 trigger suggestions
# Ctrl+.                     quick fix (e.g. add import)
# F2                         rename symbol project-wide
# Shift+Alt+F                format document

Remember

  • Ctrl+D adds the next occurrence; Ctrl+Shift+L selects all
  • Alt+Up/Down moves lines, Ctrl+/ comments
  • F2 renames semantically; Ctrl+. shows quick fixes

Watch out for

  • Using Ctrl+Shift+L or find-and-replace to rename a variable; it also hits unrelated text. Use F2.

Check yourself

  1. You want to rename a function and update every call site across the project. Which is safest?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: code.visualstudio.com/docs/editing/codebasics

Builds on

Unlocks

Nothing builds on this yet.