Step 3 of 6

Navigating within the current line

Navigating within the current line

We’re not just interested in jumping to specific lines; we also want to navigate within that line.

We could just use h and l (or the arrow keys) to move left and right one character at a time, but there are better ways. Helix gives us a few tools for navigating horizontally in the line.

The two simplest live in the goto menu from the last step: gh jumps to the start of the line and gl to the end. There are also I and A, which do the same thing but automatically drop you into insert mode. That’s useful if you want to quickly insert some new text at the start or end of the line.

If you want to specify a more precise position somewhere on the line, the f and t commands in normal mode are your friends!

  • f, followed by a character, jumps the cursor forwards onto the next instance of that character
  • t, followed by a character, jumps forwards till that character — it stops one short
  • F, followed by a character, jumps backwards onto the previous instance of that character
  • T jumps backwards till that character, stopping one short

Notice that each jump highlights everything between where you were and where you landed: in Helix, every motion is also a selection. We’ll put that to work in the next lesson.

To repeat the last f or t jump, press Alt-. — so if you’re still not in the place you want, keep hitting it.

Work through the checklist below — and have a play with F, T, I, and A on your own while you’re there. The count trick in the next step is another way to reach a later X.

  1. Jump to the end of the line With the cursor on the top line, type gl.
  2. Jump back to the start of the line To snap back to the first character, type gh.
  3. Jump forward to a character Go to the line of Xs, Ys, and Zs (5gg gets you there), then jump to the first X after the cursor with fX.
  4. Stop just before the next one To land on the character right before the next X, type tX.
Jump to the end of the line With the cursor on the top line, type gl.

Next: Jump back to the start of the line

Loading editor…