Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 有没有办法禁用vim';s交换文件警告?_Git_Vim - Fatal编程技术网

Git 有没有办法禁用vim';s交换文件警告?

Git 有没有办法禁用vim';s交换文件警告?,git,vim,Git,Vim,每当我跑的时候 git commit --amend 我想还有其他一些命令 在编辑提交消息之前,我从vim收到一条警告,上面说: E325: ATTENTION Found a swap file by the name "~/Desktop/code/web/.git/.COMMIT_EDITMSG.swp" 我总是忽略警告,只写我的提交消息并保存文件。有什么方法可以永久禁用此警告吗?删除交换文件可以消除此警告: rm ~/Desktop/code/web/.git/.COMMIT_EDI

每当我跑的时候

git commit --amend
我想还有其他一些命令

在编辑提交消息之前,我从vim收到一条警告,上面说:

E325: ATTENTION
Found a swap file by the name "~/Desktop/code/web/.git/.COMMIT_EDITMSG.swp"

我总是忽略警告,只写我的提交消息并保存文件。有什么方法可以永久禁用此警告吗?

删除交换文件可以消除此警告:

rm ~/Desktop/code/web/.git/.COMMIT_EDITMSG.swp

如果使用vim/gvim编辑器编辑文件,则在.vimrc/.gvimrc文件中设置以下命令以避免生成交换文件

set noswapfile

将此添加到您的
.vimrc

" Don't let Vim's "Found a swap file" message block input
set shortmess=A

永远不要再担心恼人的交换文件信息

发生问题时,还可以从Vim内部的提示符中删除有问题的交换文件。您将看到如下内容:

E325: ATTENTION
Found a swap file by the name "~/.vim/tmp/test.txt.swp"
          owned by: jim   dated: Mon Nov 21 00:54:03 2016
         [cannot be read]
While opening file "test.txt"
             dated: Mon Nov 21 00:53:38 2016

(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 test.txt"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file "/Users/jim/.vim/tmp/test.txt.swp"
    to avoid this message.

Swap file "~/.vim/tmp/test.txt.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:
如果您点击此处的
D
,它将删除导致错误消息的交换文件,您将不会再次看到该文件。然后,您可以再次写入文件,而不会出现错误

不直接与您的问题有关,但您可能需要考虑的是更改<代码>目录< /Cord>选项,以便交换文件不是在与正在编辑的文件相同的目录中创建的。我使用:

set directory=~/.vim/tmp,/var/tmp,/tmp
将尝试按顺序使用这些目录。这有助于将交换文件保存在一个位置,因此,如果Vim在打开一堆文件时崩溃,则可以更轻松地一次删除所有文件:

rm ~/.vim/tmp/*

它还可以防止交换文件出现在Git树中,而不用担心
。gitignore

只需删除交换文件…删除交换文件将阻止出现警告。谢谢!没有意识到情况是这样的,问题解决了:)我这样做了吗,如果有“(R)recover”选项,我仍然可以通过swp恢复未保存的进度吗?