Step 8 of 8

Rotating selection contents

Rotating selection contents

The cursors themselves can rotate, and so can the text under them. Alt-) moves the contents of each selection into the next selection along; Alt-( moves them the other way. The selections stay where they are, so the effect is that the pieces of text swap places.

  • Alt-) rotates selection contents forwards
  • Alt-( rotates them backwards

It sounds like a novelty, but it’s the quickest way to swap two arguments in a function call, reorder a couple of list items, or flip a = b around: select the pieces and press Alt-). With exactly two selections, forwards and backwards do the same thing.

Work through the checklist below to push a list of colours round by one.

  1. Select the whole buffer with % Everything highlights when you press %.
  2. Split it into one cursor per line with Alt-s Three cursors, one per colour, appear when you hold Alt and press s.
  3. Rotate the contents forwards with Alt-) Every colour moves down a line when you hold Alt and press ).
  4. 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…