vi/vim 编辑文件发现有其他进程在使用无法编辑的解决

在linux下面进行对文件的操作,vi编辑器是最常用的了,当然也有一些尴尬的时候,比如正在编辑的文件由于电脑操作不当,关闭了终端,再次打开vi xxxx 文件时提示有其他进程在使用,这时候需要对已经无效的进程进行清理了。

错误提示:


E325: ATTENTION
Found a swap file by the name ".abc.cc.swp"
          owned by: root   dated: Tue May 21 20:43:46 2019
         file name: ~root/abc.cc
          modified: YES
         user name: root   host name: instance-6ocolrk6
        process ID: 32076
While opening file "abc.cc"
             dated: Tue May 21 20:43:35 2019

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

1.查看vi的进程

ps -ef |grep vi
2.删除对应的vi进程
kill -9 12345 
3.删除这个临时编辑文件
 rm -rf .abc.cc.swp
4.重新vi abc.cc 问题便恢复正常


评论/留言