Home Explore Blog CI



neovim

3rd chunk of `runtime/doc/recover.txt`
20df1434fb8ac078ec457a89f553cd2f2fce61e3a3b320f70000000100000e15
 option.  Writing can be switched back on by setting the
'updatecount' option to non-zero.  Swap files will be created for all buffers
when doing this.  But when setting 'updatecount' to zero, the existing swap
files will not be removed, it will only affect files that will be opened
after this.

If you want to make sure that your changes are in the swap file use this
command:

					*:pre* *:preserve* *E313* *E314*
:pre[serve]		Write all text for the current buffer into its swap
			file.  The original file is no longer needed for
			recovery.

A Vim swap file can be recognized by the first six characters: "b0VIM ".
After that comes the version number, e.g., "3.0".


Links and symbolic links ~

On Unix it is possible to have two names for the same file.  This can be done
with hard links and with symbolic links (symlinks).

For hard links Vim does not know the other name of the file.  Therefore, the
name of the swapfile will be based on the name you used to edit the file.
There is no check for editing the same file by the other name too, because Vim
cannot find the other swapfile (except for searching all of your harddisk,
which would be very slow).

For symbolic links Vim resolves the links to find the name of the actual file.
The swap file name is based on that name.  Thus it doesn't matter by what name
you edit the file, the swap file name will normally be the same.  However,
there are exceptions:
- When the directory of the actual file is not writable the swapfile is put
  elsewhere.
- When the symbolic links somehow create a loop you get an *E773* error
  message and the unmodified file name will be used.  You won't be able to
  save your file normally.

==============================================================================
2. Recovery					*recovery* *E308* *E311*

Basic file recovery is explained in the user manual: |usr_11.txt|.

Another way to do recovery is to start Vim and use the ":recover" command.
This is easy when you start Vim to edit a file and you get the "ATTENTION:
Found a swap file ..." message.  In this case the single command ":recover"
will do the work.  You can also give the name of the file or the swap file to
the recover command:
					*:rec* *:recover* *E305* *E306* *E307*
:rec[over] [file]	Try to recover [file] from the swap file.  If [file]
			is not given use the file name for the current
			buffer.  The current contents of the buffer are lost.
			This command fails if the buffer was modified.

:rec[over]! [file]	Like ":recover", but any changes in the current
			buffer are lost.

						*E312* *E309* *E310* *E1364*
Vim has some intelligence about what to do if the swap file is corrupt in
some way.  If Vim has doubt about what it found, it will give an error
message and insert lines with "???" in the text.  If you see an error message
while recovering, search in the file for "???" to see what is wrong.  You may
want to cut and paste to get the text you need.

The most common remark is "???LINES MISSING".  This means that Vim cannot read
the text from the original file.  This can happen if the system crashed and
parts of the original file were not written to disk.

Be sure that the recovery was successful before overwriting the original
file or deleting the swap file.  It is good practice to write the recovered
file elsewhere and run 'diff' to find out if the changes you want are in the
recovered file.  Or use |:DiffOrig|.

Once you are sure the recovery is ok delete the swap file.  Otherwise, you
will continue to get warning messages that the ".swp" file already exists.


 vim:tw=78:ts=8:noet:ft=help:norl:

Title: Swap File Handling: Preservation, Links, and Recovery
Summary
This section explains how to manually preserve changes to the swap file using the `:preserve` command and identifies swap files by their "b0VIM " signature. It also discusses how Vim handles hard links and symbolic links in relation to swap file naming, resolving symbolic links to the actual file for swap file creation. Additionally, the section details the recovery process, explaining how to use the `:recover` command to retrieve data from swap files, handle corrupted swap files (marked by "???"), and verify successful recovery before overwriting the original file or deleting the swap file.