Multiple cursors
Type in many places at once, from a click to every occurrence of a value in a column.
With several cursors, whatever you type, delete or paste happens at each of them. It is the quickest way to change the same thing in many rows: fix a spelling, add a prefix, retype a code.
Adding cursors
- Ctrl+Click⌘Click adds a cursor where you click, and Ctrl⌘ and a drag adds a selection. Alt+Click⌥Click and Alt⌥ with a drag, as in VS Code, do the same.
- Ctrl+Alt+↑⌥⌘↑ and Ctrl+Alt+↓⌥⌘↓ add one on the row above or below, at the same place on the screen. Because the columns are aligned, that is the same column.
- Ctrl+Alt+Shift+C⌥⇧⌘C puts one on every value of the column: see Selecting columns and rows.
The status bar says how many there are (3 cursors, or 3 selections when they select text). Esc goes back to a single cursor.
The next occurrence, in the same column
Select a value, or part of one, and press Ctrl+D⌘D: the next place where it appears in the same column is selected too. Press it again for the one after; at the end of the file it goes on from the top. Then type, and every one changes.
id,name,city,country 1,Ada Lovelace,London,United Kingdom 2,Grace Hopper,New York,United States 3,Alan Turing,Manchester,United Kingdom 4,Katherine Johnson,Hampton,United States 5,Hedy Lamarr,Vienna,Austria 6,Margaret Hamilton,Boston,United States
Ctrl+Shift+L⇧⌘L selects all of them at once.
Searching in the column is what you want most of the time: replacing United States in the country column shouldn’t touch a company called United States Steel in another. A few rules make it predictable:
- Capitals count:
Spaindoesn’t findSPAIN. - If what you selected is a whole word, only whole words are found:
Yorkdoesn’t findYorkshire. - What is found has to be inside one value, and the header row is never included.
- With only a cursor and no selection, the first press selects the word at the cursor.
Anywhere in the file
Ctrl+Alt+D⌥⌘D and Ctrl+Alt+Shift+L⌥⇧⌘L do the same in the whole file, every column and the header included, as in a code editor. A selection that spans more than one value belongs to no column, so Ctrl+D⌘D searches the whole file for it too.
All four are in the Selection menu; the two that stay in the column are in the right-click menu too.