Editing Efficiently
✂️ Editing Efficiently
🖱️ Multi-Cursor Editing
Alt+Click (Option+Click on macOS) anywhere in the editor adds a new cursor at that exact position — every cursor you place accepts typing simultaneously, so one keystroke edits every location at once.
Ctrl+Alt+Down / Ctrl+Alt+Up (Cmd+Option+Down/Up on macOS) adds a cursor directly on the line below/above the current one — useful for editing several consecutive lines identically, without needing to click each one precisely.
After a multi-cursor edit, the extra cursors stay active — the next thing you type still goes to all of them, not just one. Pressing Escape collapses back to a single cursor at your last edit position. Forgetting this is a common way to accidentally type the same text into several unrelated places right after finishing a multi-cursor edit.
🎯 Multi-Select by Match (Ctrl+D)
Ctrl+D (Cmd+D on macOS) selects the word under your cursor, then — pressed again — selects the next occurrence of that same word, adding a new cursor there too. Keep pressing Ctrl+D to keep adding matches one at a time, editing all of them together once you type.
Ctrl+Shift+L (Cmd+Shift+L on macOS) skips the "press repeatedly" step entirely — it selects every occurrence of the currently selected word in the file at once, in a single keystroke.
▭ Column (Box) Selection
Holding Shift+Alt while dragging with the mouse selects a rectangular block of text spanning multiple lines, rather than a normal line-by-line selection. This is the tool for editing tabular or column-aligned text — adding the same prefix to the start of several lines, for example, without needing multi-cursor placement on each one individually.
A Familiar Idea, Again From Vim
If you've used the site's Vim course, this maps directly onto Vim's block-visual mode (Ctrl+V in Vim) — select a rectangular region spanning multiple lines, then insert or delete across all of them at once. Different keystroke, same underlying idea: sometimes the shape you want to select is a column, not a line.
🔍 Search & Replace Across Files
Ctrl+Shift+F (Cmd+Shift+F on macOS) opens workspace-wide search — searching (and optionally replacing) across every file in your open folder at once, not just the currently open one. Results are grouped by file, each showing the matching line in context; clicking a result jumps straight to it.
Workspace-wide "Replace All" changes every match across every file in one action — always expand and review the results first (each result is individually toggleable, letting you exclude specific matches) rather than trusting a search term to have matched only what you intended. This matters even more once regex mode (below) is involved, since a slightly-too-broad pattern can match far more than expected.
🧩 Regex Mode in Search
The search box has a small .* icon — toggling it switches from plain-text search to regular expression search, using the exact regex syntax covered in the site's own Learning Regular Expressions course (regex1). Capture groups from the pattern are available in the replace field as $1, $2, and so on.
Alt+Click
Adds a cursor at any position; type once, edit everywhere at once.
Ctrl+D / Ctrl+Shift+L
Select the next (or every) occurrence of a word for simultaneous editing.
Shift+Alt+drag
Column/box selection — for tabular or column-aligned text.
Ctrl+Shift+F
Workspace-wide search & replace, with an optional regex mode.
💻 Coding Challenges
Exercise 1: Multi-Cursor Cleanup
Open any file with at least 3 similar lines (or create one). Use Ctrl+Alt+Down to place cursors on all of them, then type the same addition on every line at once.
Exercise 2: Rename Every Occurrence
In a file containing the same word 3+ times, use Ctrl+Shift+L to select every occurrence at once and rename all of them with a single edit.
Exercise 3: A Workspace-Wide Regex Replace
Using Ctrl+Shift+F with regex mode enabled, search your open folder for a simple pattern with a capture group, and use $1 in the replace field — reviewing the results before confirming, per this chapter's own warn-box.
🎯 What's Next
Next chapter: Extensions — the Marketplace, evaluating an extension before installing it, and a few genuinely essential picks.