Step 5 of 6

Jumping back and forth

Jumping back and forth

Most of the time when we’re working with multiple files, we’re jumping back and forth between just two files at any given time. For example, we might be switching between two source code files, or between a file and its tests. Helix has a shortcut for exactly this.

gp and gn always walk the buffer list in order, so with several files open they won’t take you back to where you just came from. Instead, Helix remembers the buffer you were in last, and gago to the last accessed file — takes you straight back to it. Press ga again and you return to where you were, so the two keys bounce you between the two files with no command line and no picker.

Work through the checklist below. Open foo.txt with :e — that switch makes exercise.txt the last-accessed file. Then use ga to flip between the two.

  1. Open foo.txt That makes exercise.txt the last file you were in — type :e foo.txt and press Enter.
  2. Flip back with ga You'll land back in exercise.txt — type ga.
  3. Flip to foo.txt again Now foo.txt is the last-accessed file — type ga once more.
Open foo.txt That makes exercise.txt the last file you were in — type :e foo.txt and press Enter.

Next: Flip back with ga

Loading editor…