to {file} and close the window. If this was the
last |edit-window| Vim quits. Quitting fails when the
last file in the argument list has not been edited.
:wq! [++opt] {file} Write to {file} and close the current window. Quit
Vim if this was the last |edit-window|.
:[range]wq[!] [++opt] [file]
Same as above, but only write the lines in [range].
*:x* *:xit*
:[range]x[it][!] [++opt] [file]
Like ":wq", but write only when changes have been
made.
When 'hidden' is set and there are more windows, the
current buffer becomes hidden, after writing the file.
*:exi* *:exit*
:[range]exi[t][!] [++opt] [file]
Same as :xit.
*ZZ*
ZZ Write current file, if modified, and close the current
window (same as ":x").
If there are several windows for the current file,
only the current window is closed.
*ZQ*
ZQ Quit without checking for changes (same as ":q!").
MULTIPLE WINDOWS AND BUFFERS *window-exit*
*:qa* *:qall*
:qa[ll] Exit Vim, unless there are some buffers which have been
changed. (Use ":bmod" to go to the next modified buffer).
When 'autowriteall' is set all changed buffers will be
written, like |:wqall|.
:conf[irm] qa[ll]
Exit Vim. Bring up a prompt when some buffers have been
changed. See |:confirm|.
:qa[ll]! Exit Vim. Any changes to buffers are lost.
Also see |:cquit|, it does the same but exits with a non-zero
value.
*:quita* *:quitall*
:quita[ll][!] Same as ":qall".
:wqa[ll] [++opt] *:wqa* *:wqall* *:xa* *:xall*
:xa[ll] Write all changed buffers and exit Vim. If there are buffers
without a file name, which are readonly or which cannot be
written for another reason, Vim will not quit.
:conf[irm] wqa[ll] [++opt]
:conf[irm] xa[ll]
Write all changed buffers and exit Vim. Bring up a prompt
when some buffers are readonly or cannot be written for
another reason. See |:confirm|.
:wqa[ll]! [++opt]
:xa[ll]! Write all changed buffers, even the ones that are readonly,
and exit Vim. If there are buffers without a file name or
which cannot be written for another reason, Vim will not quit.
==============================================================================
6. Dialogs *edit-dialogs*
*:confirm* *:conf*
:conf[irm] {command} Execute {command}, and use a dialog when an
operation has to be confirmed. Can be used on the
|:edit|, |:q|, |:qa| and |:w| commands (the latter to
override a read-only setting), and any commands that
can fail because of unsaved changes, such as |:only|,
|:buffer|, |:bdelete|, etc.
Examples: >
:confirm w foo
< Will ask for confirmation when "foo" already exists. >
:confirm q
< Will ask for confirmation when there are changes. >
:confirm qa
< If any modified, unsaved buffers exist, you will be prompted to save
or abandon each one. There are also choices to "save all" or "abandon
all".
If you want to always use ":confirm", set the 'confirm' option.
*:browse* *:bro* *E338* *E614* *E615* *E616*
:bro[wse] {command} Open a file selection dialog for an argument to
{command}. At present this works for |:e|, |:w|,
|:wall|, |:wq|, |:wqall|, |:x|, |:xall|, |:exit|,
|:view|, |:sview|, |:r|, |:saveas|, |:sp|, |:mkexrc|,
|:mkvimrc|, |:mksession|, |:mkview|, |:split|,
|:vsplit|, |:tabe|, |:tabnew|, |:cfile|, |:cgetfile|,
|:caddfile|, |:lfile|, |:lgetfile|, |:laddfile|,
|:diffsplit|, |:diffpatch|, |:pedit|, |:redir|,
|:source|, |:update|, |:visual|, |:vsplit|,
and |:qall| if 'confirm' is set.
Note: only in Win32 GUI; in console `:browse edit`
works if the FileExplorer autocommand group exists.
When ":browse" is not possible you get an error
message. If {command} doesn't support browsing, the
{command} is executed without a dialog.
":browse set" works like |:options|.
See also |:oldfiles| for ":browse oldfiles".
The syntax is best shown via some examples: >
:browse e $vim/foo
< Open the browser in the $vim/foo