Step 6 of 8

Aligning selections

Aligning selections

Once you have a cursor in the same spot on several lines, one more command becomes possible: & aligns the selections. It pads each line with spaces so that every selection starts in the same column.

This is how Helix handles the tidy-up you’d otherwise do by hand: lining up the = signs in a block of assignments, the colons in a list of keys, the comments at the end of a few lines. Select the text you want to line up on every line — s is the natural tool — and press &.

Work through the checklist below to align the => arrows, then collapse your cursors with ,.

  1. Select the whole buffer with % Everything highlights when you press %.
  2. Put a cursor on every => with s Press s and type => — every arrow lights up with its own cursor.
  3. Line the cursors up with & Hit Enter to close the prompt — every => lines up when you 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: Put a cursor on every => with s

Loading editor…