Vim: what are all the possible swapfile extensions?

The particular piece of code that you're looking for (and comment) is in memline.c:

    /* 
     * Change the ".swp" extension to find another file that can be used. 
     * First decrement the last char: ".swo", ".swn", etc. 
     * If that still isn't enough decrement the last but one char: ".svz" 
     * Can happen when editing many "No Name" buffers. 
     */
    if (fname[n - 1] == 'a')        /* ".s?a" */
    {   
        if (fname[n - 2] == 'a')    /* ".saa": tried enough, give up */
        {   
            EMSG(_("E326: Too many swap files found"));
            vim_free(fname);
            fname = NULL;
            break;  
        }
        --fname[n - 2];             /* ".svz", ".suz", etc. */
        fname[n - 1] = 'z' + 1;
    }
    --fname[n - 1];                 /* ".swo", ".swn", etc. */

The information from the code snippet is in Vim's help. See :h swap-file:

The name of the swap file is normally the same as the file you are editing,
with the extension ".swp".
- On Unix, a '.' is prepended to swap file names in the same directory as the
  edited file.  This avoids that the swap file shows up in a directory
  listing.
- On MS-DOS machines and when the 'shortname' option is on, any '.' in the
  original file name is replaced with '_'.
- If this file already exists (e.g., when you are recovering from a crash) a
  warning is given and another extension is used, ".swo", ".swn", etc.
- An existing file will never be overwritten.
- The swap file is deleted as soon as Vim stops editing the file.

Technical: The replacement of '.' with '_' is done to avoid problems with
       MS-DOS compatible filesystems (e.g., crossdos, multidos).  If Vim
       is able to detect that the file is on an MS-DOS-like filesystem, a
       flag is set that has the same effect as the 'shortname' option.
       This flag is reset when you start editing another file.

                            *E326*
       If the ".swp" file name already exists, the last character is
       decremented until there is no file with that name or ".saa" is
       reached.  In the last case, no swap file is created.

In, slightly easier on the eyes, regex-speak:

[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]

The source for this is Github's own gitignore file for Vim.

Tags:

Vim

Filenames