I would like a command that saves every buffer that has a filename. :h :wall gives this:

                            *:wa* *:wall*
:wa[ll]     Write all changed buffers.  Buffers without a file
            name cause an error message.  Buffers which are
            readonly are not written.

:wa[ll]!    Write all changed buffers, even the ones that are
            readonly.  Buffers without a file name are not
            written and cause an error message.

So basically I want a command that would say "Write all changed buffers. Buffers without a filename are skipped/ignored." I don't care what happens to readonly buffers.

Is there an existing command that does this, or would I need to write a function to do this?


1 Answer 1


Sounds like an ideal place to make use of the command :silent!.

:silent can be inserted before other commands and its effect is to prevent display of "normal" (i.e. non-error) messages. Error messages still get displayed and may cause execution to halt.

:silent!, with added !, goes a step further and also suppresses messages caused by errors and prevents those errors from aborting execution.

So you should be able to use the latter along with :wa! thusly...

:silent! wa!

...to get your desired result:

  1. Write changed buffers
  2. Ignore buffers without a filename (error suppressed)
  3. Write readonly buffers (which you don't have a preference for either way)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.