[1] +停止vim食品错误,如何修复?

2024-06-01 02:00:02 发布

您现在位置:Python中文网/ 问答频道 /正文

每当我像这样从vim命令运行python程序时:

:!python foo.py

运行程序后,vim将停止并说:

^{pr2}$

我不知道为什么会有这样的错误。 我不使用食品文件在其他应用程序中,但它刚刚发生。在

如果需要,这是我的.exerc文件内容:

set nu
syntax on
filetype on
filetype indent on
filetype plugin on
set tabstop=4
set shiftwidth=4
set softtabstop=4
set shellcmdflag=-ic

当我打开食品运行之后,vim说:

E325: ATTENTION
Found a swap file by the name ".foo.py.swp"
          owned by: me   dated: Mon Sep 30 21:05:52 2013
         file name: ~foo/bar/foo.py
          modified: no
         user name: me   host name: hostname
        process ID: 3635 (still running)
While opening file "foo.py"
             dated: Sat Sep 28 23:04:15 2013

(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 foo.py"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file ".foo.py.swp"
    to avoid this message.

Swap file ".foo.py.swp" already exists!

谢谢。 (我正在使用mac os x)


Tags: thetonamepy程序食品iffoo
2条回答

说:

set shellcmdflag=-ic

使vim在尝试执行shell命令时打开交互式shell。在

为了打开一个交互式的shell,它将挂起vim进程。这就解释了你所观察到的行为(包括[1]+ Stopped ...和{})。在

(可以说fg从这样创建的shell恢复编辑器。)

如果你把

set shellcmdflag=-ic

从你的.exerc中,你不会注意到这个问题。在

为了执行python脚本,必须挂起Vim,以便脚本可以在shell中运行。在

您看到的不是一个错误,而是您的shell有用地告诉您Vim已挂起(或“backgrounded”或“in the background”或“in the background”或“stopped”)。这显然是第一个也是唯一一个被暂停的项目。在

要回到Vim,只需在提示符处输入fg(对于foreground)。在

所以,基本上,你得到的是正常的和预期的。在

相关问题 更多 >