Answers:
您要查找(和注释)的特定代码在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. */
从代码片段的信息是 Vim的帮助。见: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.
.gitignore
尽管这里的其他答案在技术上显然更完整,但是对于大多数s来说,这是一个足够好的输入,.gitignore
这是我最常关心的地方:
# vim swap files
##################
*.sw[a-p]
从其他答案中可以看到,vim
可以创建数百个其他名称,但是您必须堆叠16个交换文件,否则该文件将失败。通过归纳为*.s[a-z][a-z]
可能看起来更正确的东西,它也将与许多有效的扩展名匹配,在这种情况下,.gitignore
意味着这些文件不会被跟踪git
。在使用20年中,我从未设法为同一文件创建16个交换文件,vim
因此我希望您能够做到这一点,并且对您有用。
正如评论中指出的那样,Flash开发人员可能拥有.swf
文件,因此您可能更喜欢
*.sw[g-p]
仍然会忽略10个交换文件,这对大多数人来说已经足够了。唯一可悲的是您丢失了“交换”助记符。
.sw2
或者.sw$
应该在存储库中进行跟踪。
.swf
文件。或将您的Flash开发人员升级到HTML5 :-)
.
或_
添加的开头来避免捕获大多数合法文件。
*.sw[a-p]
自己发现了助记符。我喜欢它:)