本文主要是介绍Vim打不开文件:Another program may be editing the same file./An edit session for this file crashed.,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Linux 下用 Vim 打开一个脚本文件“f03.sh”,直接报错:
vim f03.sh
遇到英文错误不要怕,先看一下报错的内容。
- Another program may be editing the same file.
- An edit session for this file crashed.
E325: ATTENTION
Found a swap file by the name ".f03.sh.swp"owned by: geofferysun dated: Wed Apr 28 14:28:12 2021file name: ~geofferysun/NDK/New/f03.shmodified: YESuser name: geofferysun host name: LAPTOP-G599D37Hprocess ID: 139 (STILL RUNNING)
While opening file "f03.sh"dated: Wed Apr 28 15:59:15 2021NEWER 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 samefile 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 f03.sh"to recover the changes (see ":help recovery").If you did this already, delete the swap file ".f03.sh.swp"to avoid this message.
解决思路: Linux 下两个人同时打开同一个文件会显示如下界面,而有的时候只有一个账户的时候也有这个提示,此时的处理思路是由于上次没有关闭打开的文件造成的,结束掉进程即可。
一、结束进程
- 查看
vi
进程
ps -ef | grep vi
geofferysun@LAPTOP-G599D37H:~/NDK/New$ ps -ef |grep vi
geoffer+ 139 8 0 14:27 tty1 00:00:00 vim f03.sh
geoffer+ 202 8 0 16:12 tty1 00:00:00 grep --color=auto vi
8个字段的含义:
UID | PID | PPID | C | STIME | TTY | TIME | CMD |
---|---|---|---|---|---|---|---|
geoffer+ | 139 | 8 | 0 | 14:27 | tty1 | 00:00:00 | vim f03.sh |
geoffer+ | 202 | 8 | 0 | 16:12 | tty1 | 00:00:00 | grep --color=auto vi |
- UID:程序被该 UID 所拥有
- PID:就是这个程序的 ID
- PPID:则是其上级父程序的ID
- C:CPU使用的资源百分比
- STIME:系统启动时间
- TTY:登入者的终端机位置
- TIME:使用掉的CPU时间。
- CMD:所下达的是什么指令
- 结束掉指定(PID为139)进程
kill -9 139
如果结束进程后仍然有这个提示,此时是由于缓存造成的删除缓存即可。
二、清除上次操作留下的缓存
“f03.sh” 文件后面添加 “.swp”,可以 tab
键补齐出来
rm -rf .f03.sh.swp
此时再打输入开文件指令即可恢复正常。
这篇关于Vim打不开文件:Another program may be editing the same file./An edit session for this file crashed.的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!