Deleting a buffer
If you like to keep your buffer list nice and tidy, you can use the :bd command to delete a buffer from the buffer list. :bd by itself will get rid of the current buffer, but just like the :b command, you can also specify a buffer number or a file path.
And don’t worry — if you try to delete a buffer that has unsaved changes, Vim will stop you from proceeding.
Work through the checklist below. Open all of the text files in the current directory with :args *.txt, then thin the list back out with :bd — once by name, and once from inside the buffer itself.
1 2 3 4
Open every text file at once Vim loads all five files and lands in the first, a.txt — type :args *.txt and hit Enter.
Delete bar.txt's buffer You can delete a buffer you're not even in — type :bd bar.txt and hit Enter.
Delete the buffer you're in Plain :bd deletes the current buffer and drops you in one of the survivors — type :bd and hit Enter.
Check what's left Two buffers down — type :ls, hit Enter, and hit Enter again to dismiss the list.
Next: Delete bar.txt's buffer
Next: Delete the buffer you're in
Next: Check what's left
Last one — goal check runs when it's done
Nice work!
Up next: Lesson 12 — Windows.