当“ vi”报告文件已打开时如何打开文件?


10

由于某些原因,当我尝试编辑时vi .profile,终端会不断告诉我我已经在编辑模式下使用了.profile。

E325: ATTENTION
Found a swap file by the name ".profile.swp"
          owned by: smaranh   dated: Fri Apr  6 09:46:45 2012
         file name: ~smaranh/.profile
          modified: YES
         user name: smaranh   host name: ubuntu
        process ID: 4394
While opening file ".profile"
             dated: Fri Apr 27 10:35:32 2012
      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 .profile"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file ".profile.swp"
    to avoid this message.
".profile" 23 lines, 713 characters
Press ENTER or type command to continue

因此,我试图终止以上消息所显示的过程,但是该过程一直在显示No such process

然后我使用ps -ef | grep 4394并获得了此输出,

smaranh   3491  3375  0 10:08 pts/3    00:00:00 grep --color=auto 4394

所以我尝试了kill -9 3491但是它仍然给了我No such process。不确定出什么问题了吗?

我如何关闭已经打开的.profile

Answers:


16

这是一个旧的交换文件,仍然存在,因为编辑器可能崩溃了或被杀死了。您可以安全地擦除它。

rm .profile.swp

1
我还会保留.profile文件的原始内容吗?
Sam007 '10

1
NO。检查编辑后的答案。
沙洛爵士(SirCharlo)2012年

@ Sam007对不起。我的错。我现在有点困...
埃里克·卡瓦略

@EricCarvalho总是当心rm命令!!
沙洛爵士(SirCharlo)2012年

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.