Step 3 of 5

History is a tree

History is a tree

u and U are all you need if you think of your history as a straight line. But it isn’t always that simple. Sometimes you undo a few steps, then start editing again. In many editors, that throws away your redo history, and the text you had before the undo is gone for good.

Helix keeps the whole tree of changes, so you’ll never find yourself in that situation.

This is best shown with an example. Say you have three lines, and you delete the first one:

draft two
draft three

Then you delete the next one:

draft three

You change your mind and undo, then delete the last line instead:

draft two

If you now decide you wanted the draft three version after all, you’re in a sticky situation. u takes you back to the two-line state, and U only takes you forward again along the new branch. The first half of the checklist walks you through this exact workflow — follow it and see for yourself.

Luckily, Helix has another pair of commands. Alt-u and Alt-U move to older and newer states in the history tree, visiting every state in the order you made it, whichever branch it’s on. Keep pressing Alt-u and you’ll find your lost text eventually.

The last two checklist items have you try them. On a Mac, alt is the option key.

  1. Delete the draft one line The cursor starts on it — press x then d.
  2. Delete the draft two line too It's under the cursor now — press x then d again.
  3. Undo that second deletion draft two comes back — press u.
  4. Delete draft three instead This is where the history branches — press j to move down, then x and d.
  5. Walk back through history with Alt-u The lost draft three-only state returns — hold alt (option on a Mac) and press u.
  6. Walk forward again with Alt-U draft two comes back — hold alt and shift, then press u.
Delete the draft one line The cursor starts on it — press x then d.

Next: Delete the draft two line too

Loading editor…