Vim Tips Wiki
(:wqa as an alternative to :xa)
Tags: apiedit, Visual edit
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{review}}
 
 
{{TipImported
 
{{TipImported
 
|id=652
 
|id=652
 
|previous=651
 
|previous=651
 
|next=653
 
|next=653
|created=February 6, 2004
+
|created=2004
 
|complexity=intermediate
 
|complexity=intermediate
 
|author=Andreas Berg
 
|author=Andreas Berg
 
|version=6.0
 
|version=6.0
 
|rating=6/12
 
|rating=6/12
|category1=
+
|category1=Usage
 
|category2=
 
|category2=
 
}}
 
}}
  +
Vim can open multiple files, each in its own buffer. Here is how to save all changes and continue working, or save all changes and exit Vim. It is also possible to quit all (discard changes).
If you have opened files in several buffers, you can use the following commands to save any changed files.
 
  +
{| class="cleartable"
<pre>
 
:wa " write (save) any changed files and keep working
+
|<code>:wa</code> || write all changed files (save all changes), and keep working
  +
|-
:xa " write any changed files and exit
 
  +
|<code>:xa</code> || exit all (save all changes and close Vim)
</pre>
 
  +
|-
  +
|<code>:wqa</code>
  +
|same as <code>:xa</code>
  +
|-
  +
|<code>:qa</code> || quit all (close Vim, but not if there are unsaved changes)
  +
|-
  +
|<code>:qa!</code> || quit all (close Vim without saving—discard any changes)
  +
|}
   
  +
The <code>:wa</code> and <code>:xa</code> commands only write a file when its buffer has been changed. By contrast, the <code>:w</code> command always writes the current buffer to its file (use <code>:update</code> to save the current buffer only if it has been changed).
==Comments==
 
   
  +
Warning: If you enter <code>:qa!</code>, Vim will discard all changes without asking "are you sure?".
If you're trying to do the '''opposite''' of this (that is, close all buffers '''without''' saving), use :qa!
 
   
  +
==See also==
Naturally, be very sure that is what you really don't want to save anything before you do this.
 
  +
*[[Tutorial]]
   
  +
==References==
This page was the first hit on Google for me for the search string "vim close all buffers without saving", so it seems some others agree that this would be useful to have listed here.
 
  +
*{{help|window-exit}}
  +
 
==Comments==

Latest revision as of 18:24, 10 August 2017

Tip 652 Printable Monobook Previous Next

created 2004 · complexity intermediate · author Andreas Berg · version 6.0


Vim can open multiple files, each in its own buffer. Here is how to save all changes and continue working, or save all changes and exit Vim. It is also possible to quit all (discard changes).

:wa write all changed files (save all changes), and keep working
:xa exit all (save all changes and close Vim)
:wqa same as :xa
:qa quit all (close Vim, but not if there are unsaved changes)
:qa! quit all (close Vim without saving—discard any changes)

The :wa and :xa commands only write a file when its buffer has been changed. By contrast, the :w command always writes the current buffer to its file (use :update to save the current buffer only if it has been changed).

Warning: If you enter :qa!, Vim will discard all changes without asking "are you sure?".

See also[]

References[]

Comments[]