尝试编辑 .vimrc 文件时交换文件错误消息?

Gee*_*eek 5 vim vimrc

每次我尝试打开.vimrc文件时,我都会收到此消息。我正在vimtutor另一个终端中使用 ,但我认为我没有打开任何额外的 . vimrc文件 。为什么我会看到这个错误,我该如何解决这个问题?

E325: ATTENTION
Found a swap file by the name ".vimrc.swp"
          owned by: subhrcho   dated: Wed Dec 26 05:54:45 2012
         file name: ~subhrcho/.vimrc
          modified: YES
         user name: subhrcho   host name: slc04lyo
        process ID: 26176
While opening file ".vimrc"
             dated: Mon Jan 28 22:45:16 2013
      NEWER than swap file!

(1) Another program may be editing the same file.
    If this is the case, be careful not to end up with two
    different instances of the same file when making changes.
    Quit, or continue with caution.

(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r .vimrc"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file ".vimrc.swp"
    to avoid this message.

Swap file ".vimrc.swp" already exists!
Run Code Online (Sandbox Code Playgroud)

Ing*_*kat 8

交换文件已有一个月(12 月 26 日),因此可能需要保存以将其删除。那天,你可能杀死了一个 Vim 实例(或者它崩溃了),留下了交换文件。Vim 永远不会自己清理这些,你必须自己删除它(或者当 Vim 询问你时选择删除选项)。

顺便说一句,recover.vim - 显示恢复文件的差异插件极大地增强了交换文件的体验,例如通过提供显示更改的差异。

  • 其他编辑器在幕后可能有类似的机制,但交换文件在 Vim 中是特定的(并且相当可见)。有关详细信息,请参阅 `:help swap-file`。 (3认同)