Step 1 of 5

Joining lines

Joining lines

This lesson is a handful of small commands that each do one thing to a selection. None of them needs much explanation, so this lesson moves quickly.

First up is J, which joins lines. Press it in normal mode and the line below the cursor is pulled up onto the current one, with a single space in between. The line break and any leading whitespace on the joined line are removed.

Like everything else in Helix, J works on the selection. With a single cursor it joins two lines; select several lines first — x a few times, or % for the whole buffer — and one press joins them all.

The checklist starts with a warm-up from lessons 4 and 7. Then put the sentence back on one line.

  1. Delete the first line Warm-up from lesson 4 — select the line, then remove it.
  2. Bring it back Lesson 7's safety net puts the line back exactly as it was.
  3. Join the first two lines with J With the cursor anywhere on line 1, press J — line 2 comes up to meet it.
  4. Select all three lines and join them Press x three times to extend the selection down the buffer, then J.
Delete the first line Warm-up from lesson 4 — select the line, then remove it.

Next: Bring it back

Loading editor…