Home Explore Blog CI



neovim

14th chunk of `runtime/doc/editing.txt`
60e13b218aaf566134f97812e5b56f7c48d146d07cc658760000000100000fad
 will reset the 'modified' flag,
even though the buffer itself may still be different from its file.

If a file name is given with ":w" it becomes the alternate file.  This can be
used, for example, when the write fails and you want to try again later with
":w #".  This can be switched off by removing the 'A' flag from the
'cpoptions' option.

Note that the 'fsync' option matters here.  If it's set it may make writes
slower (but safer).

							*:sav* *:saveas*
:sav[eas][!] [++opt] {file}
			Save the current buffer under the name {file} and set
			the filename of the current buffer to {file}.  The
			previous name is used for the alternate file name.
			The [!] is needed to overwrite an existing file.
			When 'filetype' is empty filetype detection is done
			with the new name, before the file is written.
			When the write was successful 'readonly' is reset.

							*:up* *:update*
:[range]up[date][!] [++opt] [>>] [file]
			Like ":write", but only write when the buffer has been
			modified.


WRITING WITH MULTIPLE BUFFERS				*buffer-write*

							*: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.


Vim will warn you if you try to overwrite a file that has been changed
elsewhere (unless "!" was used).  See |timestamp|.

			    *backup* *E207* *E506* *E507* *E508* *E509* *E510*
If you write to an existing file (but do not append) while the 'backup',
'writebackup' or 'patchmode' option is on, a backup of the original file is
made.  The file is either copied or renamed (see 'backupcopy').  After the
file has been successfully written and when the 'writebackup' option is on and
the 'backup' option is off, the backup file is deleted.  When the 'patchmode'
option is on the backup file may be renamed.

							*backup-table*
'backup' 'writebackup'	action	~
   off	     off	no backup made
   off	     on		backup current file, deleted afterwards (default)
   on	     off	delete old backup, backup current file
   on	     on		delete old backup, backup current file

When the 'backupskip' pattern matches with the name of the file which is
written, no backup file is made.  The values of 'backup' and 'writebackup' are
ignored then.

When the 'backup' option is on, an old backup file (with the same name as the
new backup file) will be deleted.  If 'backup' is not set, but 'writebackup'
is set, an existing backup file will not be deleted.  The backup file that is
made while the file is being written will have a different name.

On some filesystems it's possible that in a crash you lose both the backup and
the newly written file (it might be there but contain bogus data).  In that
case try recovery, because the swap file is synced to disk and might still be
there. |:recover|

The directories given with the 'backupdir' option are used to put the backup
file in.  (default: same directory as the written file).

Whether the backup is a new file, which is a copy of the original file, or the
original file renamed depends on the 'backupcopy' option.  See there for an
explanation of when the copy is made and when the file is renamed.

If the creation of a backup file fails, the write is not done.  If you want
to write anyway add a '!' to the command.

							*file-watcher*
When you notice issues with programs, that act upon when a buffer is written
(like inotify, entr or fswatch) or when external applications execute Vim to
edit the file (like git) and those programs do not seem to notice that the
original file has been changed, you may want to consider switching the
'backupcopy' option value to "yes".  This makes sure, Vim writes to the same
file, that those watcher programs expect, without creating a new file (which
prevents them from detecting that the file has changed).  See also |crontab|

							*write-permissions*

Title: Saving, Backups, and Multiple Buffers in Vim
Summary
This section explains advanced features for writing files in Vim, including `:saveas`, `:update`, and writing multiple buffers with `:wall`. It details Vim's backup system controlled by 'backup', 'writebackup', 'patchmode', and 'backupskip' options. It clarifies how Vim handles backups when overwriting files and the 'backupcopy' and 'backupdir' options, as well as how Vim warns if you attempt to overwrite a file that has been changed elsewhere. It also addresses potential issues with file watchers and external applications.