Step 6 of 6

Closing a buffer

Closing a buffer

If you like to keep your buffer list tidy, you can use the :buffer-close command — or its short alias :bc — to remove a buffer from the list. :buffer-close by itself closes the current buffer and drops you into the one you were in last, but you can also give it a path — the one the statusline shows, like /work/b.txt — to close a buffer without switching to it first.

And don’t worry — if you try to close a buffer that has unsaved changes, Helix will stop you from proceeding.

Work through the checklist below. Open a.txt and close it again from inside the buffer, then open b.txt and bar.txt. Close b.txt by name and prove it worked with gp — the walk now skips straight over where b.txt used to sit. Finally, hop back to bar.txt and close it from the inside.

  1. Open a.txt Type :e a.txt and press Enter.
  2. Close the buffer you're in Helix drops you back in exercise.txt — type :buffer-close (or its short alias :bc) and press Enter.
  3. Open b.txt Type :e b.txt and press Enter.
  4. Open bar.txt Type :e bar.txt and press Enter.
  5. Close b.txt without switching to it, then check with gp Type :buffer-close /work/b.txt (the path as the statusline shows it) and press Enter, then press gp — with b.txt gone, it takes you straight back to exercise.txt.
  6. Hop back to bar.txt with gn It's the only other buffer left — type gn.
  7. Close bar.txt too Only exercise.txt is left to land in — type :buffer-close and press Enter.
Open a.txt Type :e a.txt and press Enter.

Next: Close the buffer you're in

Loading editor…