Step 3 of 6

Scratch buffers

Scratch buffers

When you opened example.rs in the last step, exercise.txt didn’t go anywhere. Helix keeps every file you open loaded in memory as a buffer, and switching files is really switching buffers.

You met the buffer picker in lesson 12: the list of everything that’s loaded, filtered the same way as the file picker. The checklist starts with two things from that lesson: load a file by name, then come back with the picker.

A buffer doesn’t have to be a file. :new opens an empty scratch buffer with no filename at all, handy for pasting something you want to look at without saving it. Two things to know: Helix throws an empty scratch buffer away as soon as you leave it, so type something in first, and once it has text the picker shows it as [scratch] with a + for the unsaved change.

After that warm-up, make a scratch buffer, put a word in it, and use the picker to move between it and this file.

Note

Buffers pile up over a long session. :buffer-close (or :bc) closes the current one.

  1. Load welcome.txt into the buffer list Lesson 12 — the command that opens a file by name.
  2. Come back to exercise.txt with the buffer picker Lesson 12 — the picker that lists only what's already loaded.
  3. Make a scratch buffer with :new Run it from the : prompt — the statusline switches to [scratch] and the editor goes blank.
  4. Put a word in it Insert the word scratch — an empty scratch buffer is thrown away the moment you leave it.
  5. Go back to exercise.txt with the buffer picker The same picker as before — exercise.txt is one of three rows now.
  6. Hop back to the scratch buffer The picker once more — [scratch] is the row without a filename, and the + marks its unsaved change.
Load welcome.txt into the buffer list Lesson 12 — the command that opens a file by name.

Next: Come back to exercise.txt with the buffer picker

Loading editor…