Home Explore Blog CI



neovim

5th chunk of `runtime/doc/usr_11.txt`
306e17803da0b114f0fbfa384b26f1a7aee0d22bec6a4a040000000100000c67
 If you are the one in charge of
that file, be prepared to redo your last changes.


WHAT TO DO?					*swap-exists-choices*

If dialogs are supported you will be asked to select one of six choices:

  Swap file ".main.c.swp" already exists! ~
  [O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort, (D)elete it: ~

O  Open the file readonly.  Use this when you just want to view the file and
   don't need to recover it.  You might want to use this when you know someone
   else is editing the file, but you just want to look in it and not make
   changes.

E  Edit the file anyway.  Use this with caution!  If the file is being edited
   in another Vim, you might end up with two versions of the file.  Vim will
   try to warn you when this happens, but better be safe than sorry.

R  Recover the file from the swap file.  Use this if you know that the swap
   file contains changes that you want to recover.

Q  Quit.  This avoids starting to edit the file.  Use this if there is another
   Vim editing the same file.
      When you just started Vim, this will exit Vim.  When starting Vim with
   files in several windows, Vim quits only if there is a swap file for the
   first one.  When using an edit command, the file will not be loaded and you
   are taken back to the previously edited file.

A  Abort.  Like Quit, but also abort further commands.  This is useful when
   loading a script that edits several files, such as a session with multiple
   windows.

D  Delete the swap file.  Use this when you are sure you no longer need it.
   For example, when it doesn't contain changes, or when the file itself is
   newer than the swap file.
      On Unix this choice is only offered when the process that created the
   swap file does not appear to be running.

If you do not get the dialog (you are running a version of Vim that does not
support it), you will have to do it manually.  To recover the file, use this
command: >

	:recover


Vim cannot always detect that a swap file already exists for a file.  This is
the case when the other edit session puts the swap files in another directory
or when the path name for the file is different when editing it on different
machines.  Therefore, don't rely on Vim always warning you.

If you really don't want to see this message, you can add the 'A' flag to the
'shortmess' option.  But it's very unusual that you need this.

For programmatic access to the swap file, see |swapinfo()|.

==============================================================================
*11.4*	Further reading

|swap-file|	An explanation about where the swap file will be created and
		what its name is.
|:preserve|	Manually flushing the swap file to disk.
|:swapname|	See the name of the swap file for the current file.
'updatecount'	Number of key strokes after which the swap file is flushed to
		disk.
'updatetime'	Timeout after which the swap file is flushed to disk.
'directory'	List of directory names where to store the swap file.

==============================================================================

Next chapter: |usr_12.txt|  Clever tricks

Copyright: see |manual-copyright|  vim:tw=78:ts=8:noet:ft=help:norl:

Title: Swap File Options: Open, Edit, Recover, Quit, Abort, Delete, and Further Reading
Summary
This section outlines the options available when a swap file already exists: Open Read-Only, Edit Anyway, Recover, Quit, Abort, and Delete, detailing when each is appropriate. It explains how to recover a file manually if the dialog isn't supported and cautions against relying solely on Vim's warnings about existing swap files. It also covers the 'shortmess' option to suppress the swap file message and programmatic access to swap files. Finally, it provides links to further reading on swap file locations, manual flushing, swap file names, and related settings.