Step 7 of 8

Choosing the primary selection

Choosing the primary selection

Every time you’ve had several cursors in this lesson, one of them has been drawn a little brighter. That’s the primary selection, and a few commands care about it: search jumps from it, , keeps it and drops the rest, and when you add cursors with C the new one becomes primary.

Which cursor is primary isn’t fixed. Two keys move the title around:

  • ) makes the next selection primary
  • ( makes the previous one primary

And one key gets rid of the primary cursor without touching the others:

  • Alt-, removes the primary selection

Together they let you trim a set of cursors by hand. Run s over a block, and if one of the matches is one you’d rather not change, cycle to it with ) and drop it with Alt-,. The rest stay exactly where they were.

Work through the checklist below to cycle through three cursors and remove one of them.

  1. Select the whole buffer with % Everything highlights when you press %.
  2. Split it into one cursor per line with Alt-s Three cursors, red the brighter one, appear when you hold Alt and press s.
  3. Make the next cursor primary with ) The brighter highlight moves down to green when you press ).
  4. Remove the primary cursor with Alt-, green loses its cursor and the statusline reads 2 sels once you press Alt-,.
  5. Collapse back to one cursor with , The statusline stops counting selections when you press ,.
Select the whole buffer with % Everything highlights when you press %.

Next: Split it into one cursor per line with Alt-s

Loading editor…