【问题标题】:How to stop Vim from creating *-e files如何阻止 Vim 创建 *-e 文件
【发布时间】:2013-03-05 22:39:33
【问题描述】:

最近我的 Vim 一直在我的文件夹中乱扔以 -e 结尾的额外文件。例如,如果我正在编辑一个名为 test.php 的文件,有时(但并非总是如此!)我最终也会得到另一个名为 test.php-e 的文件。

我不知道是什么原因造成的,但这很烦人。据我所知,我最近没有改变任何东西。备份文件都在我的~/.vim/backups 目录中,所以我不确定这些东西是从哪里来的。想法?

【问题讨论】:

  • 所有文件都会发生这种情况吗?例如.txt、*.py、*.?或仅适用于 php 文件?你确定 -e 文件不是来自其他编辑器的 tmp/swap 文件吗?
  • @Kent 我只注意到 .php 文件,但这可能是因为我主要编写 php 文件。而且我没有使用任何其他编辑器,所以我认为也不是这样。

标签: vim


【解决方案1】:
set nobackup

或将备份目录设置为 /tmp 之类的内容并不时清除。

来自 VIM 文档 (:help nobackup)

'backup' 'bk'       boolean (default off)
            global
            {not in Vi}
    Make a backup before overwriting a file.  Leave it around after the
    file has been successfully written.  If you do not want to keep the
    backup file, but you do want a backup while the file is being
    written, reset this option and set the 'writebackup' option (this is
    the default).  If you do not want a backup file at all reset both
    options (use this if your file system is almost full).  See the
    |backup-table| for more explanations.
    When the 'backupskip' pattern matches, a backup is not made anyway.
    When 'patchmode' is set, the backup may be renamed to become the
    oldest version of a file.
    NOTE: This option is reset when 'compatible' is set.

【讨论】:

  • 这似乎不是 OP 正在寻找的解决方案......他说他将备份重新配置到某个目录。
  • 在正在运行的编辑器/全局 .vimrc 中设置 nobackup 是避免它们的最快方法之一。您可以将 vim 配置为在任何地方写入,但是如果您现在无法访问该目录怎么办?
  • 对,所有其他备份都在~/.vim/backup 中,所以在我的假设示例中,我的备份目录中还有一个test.php~ 文件。我不介意这些 -e 文件是否在备份目录中,但是它们使我的所有工作目录都变得非常混乱。
  • @MichaelM。这似乎将 VIM 排除在罪魁祸首之外。你在使用某种版本控制吗?打开这个 -e 文件会显示实际文件吗?与原版的不同显示了一些提示? (我在考虑他们是交换)
  • 嗯,我不确定它还会是什么。我正在使用 Git,但在切换到 Vim 之前我从未注意到这是一个问题(我是一个相对较新的转换者)。据我所知,-e 文件似乎与非 e 版本相同。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-16
  • 2010-10-19
  • 2018-05-29
  • 1970-01-01
  • 2013-01-13
  • 2020-05-16
相关资源
最近更新 更多