Step 1 of 6

Working with multiple files

Working with multiple files

So far in the course, we’ve used Helix to edit just one file. This is fine for learning the basics of how Helix works, but in real life this is quite limiting. Most text editing tasks require us to work with multiple files at once — programmers and software engineers, for example, usually end up working across multiple source files in the same editing session.

Helix has support for editing multiple files in the same session with buffers and windows. In this lesson, we’re going to focus on buffers. These are a prerequisite to understanding what windows are and how they work. In essence, a buffer is the in-memory text of a file — a file loaded into Helix for editing. You can make changes to the buffer, and the original file on disk will remain untouched until you decide to write. Strictly speaking, buffers don’t need to have a corresponding file on disk, but most of the time they do.

Helix lets us have multiple buffers open at the same time, which corresponds to us being able to modify multiple files in the same editing session.

In the editor, the file that’s currently open is called exercise.txt — you can see its name in the statusline at the bottom. There’s one other file alongside it, called myfile.

Work through the checklist below: open myfile with the :e command, then hop between the two buffers with gp and gn — short for go previous and go next.

  1. Open myfile with :e Type :e myfile — Tab completes the name — and press Enter.
  2. Go back with gp Type gp to return to the previous buffer.
  3. Jump forward again with gn Type gn to go to the next buffer.
Open myfile with :e Type :e myfile — Tab completes the name — and press Enter.

Next: Go back with gp

Loading editor…