Step 1 of 8

Many cursors, one command

Many cursors, one command

In lesson 1 we said a Helix selection can hold more than one cursor. This lesson is about how you get those cursors, and what you can do once you have them.

The idea is simple. Every command you already know acts on the selection. If the selection is made of several ranges, the command runs on every one of them, at the same time. Insert some text and it appears in each place; delete and each range disappears; move with w and every cursor moves a word.

The simplest way to get a second cursor is to copy the one you have onto the line below:

  • C copies the selection to the next line
  • Alt-C copies it to the previous line instead

The statusline keeps count: with three cursors it reads 3 sels. One of them is the primary selection — drawn a little brighter — and that’s the one commands like search keep their attention on.

When you’re done, , collapses everything down to the primary cursor. You’ll use it constantly, so get it into your fingers now. The checklist starts with warm-ups from lessons 10 and 3.

  1. Remove the note in parentheses from the first line, parentheses included Warm-up from lesson 10 — match mode has a selection for the text around a pair.
  2. Move back to the first character of the line Warm-up from lesson 3 — there's a motion that jumps to the start of the line.
  3. Add a cursor on the line below with C From the start of the first line, a second cursor appears on the line below when you press C.
  4. Add a third cursor with C The statusline reads 3 sels once you press C again.
  5. Type with every cursor at once Type a few characters into all three lines at once after you press i.
  6. Escape, then collapse back to one cursor with , Hit Escape for normal mode first — only the primary cursor stays once you press ,.
Remove the note in parentheses from the first line, parentheses included Warm-up from lesson 10 — match mode has a selection for the text around a pair.

Next: Move back to the first character of the line

Loading editor…