Vim: How to delete a vim buffer when you quit a file in vim

I open 15 files in vim.

vim -p *.php

I close one file without saving

:q

Then after closing some I get this E173: 15 more files to edit.

It seems quitting a file does not remove it from a buffer.

Is there any way so that I don't get this error when I quit a file?

At the moment I have to use qall to exit.

Thanks in advance.


Solution 1:

You don't quit files; in order to "close" a file, you either delete or wipe the buffer, whereas you quit the editor itself. You're using the quit-editor command (q) to close a single buffer, which is why you're getting the error message.

Here are the commands you need to know:

  • :bd closes a single buffer; that is, Vim removes it from the buffer list. Some bits of information, such as marks, are still kept around.
  • :bw closes a single buffer and wipes it; the buffer is "really" deleted and all temporary information is lost.
  • :q quits the editor; assumes that only one buffer is open.
  • :qa (which is short for the :qall command you've been using) quits the editor and close all buffers. This is separate from q because otherwise you might forget that you have other files open and accidentally lose information.