这是生成交换文件扩展名的实际VIM代码:
/*
* 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. */
这将生成以下格式的交换文件:
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]
几乎是GitHub自己的VIM gitignore文件中包含的内容。
正如其他人正确指出的那样,此.gitignore也将忽略.svg图像文件和.swf Adobe Flash文件。
*.sw?
解决了标准问题.swp
,还解决了替代交换文件扩展名,例如.swo
。