背景

用vim命令处理一些超大文件时,有时会遇到卡死现象,不得不强制退出。但是,再次用vim命令访问这个文件时,会出现“E325:ATTENTION”提示。如果不做处理,以后每次都会出现。

分析

经过一番查证,此提示是vim程序对文件的一种保护机制(或锁机制)。当我们用vim命令打开一个文件时,会自动生成一个隐藏的swp文件。如果vim还在处理此文件,或者由于一些原因未正常退出,swp文件就会一直存在。当我们再次用vim命令打开此文件时,程序检测到有swp文件存在,就提醒我们不要误操作。原文如下:

*

11.3*	Crashed or not?					*

ATTENTION* *

E325*

Vim tries to protect you from doing stupid things.  Suppose you innocently
start editing a file, expecting the contents of the file to show up. Instead,
Vim produces a very long message: E325: ATTENTION
Found a swap file by the name ".main.c.swp"
 owned by: mool   dated: Tue May 29 21:09:28 2001
file name: ~mool/vim/vim6/src/main.c
 modified: no
user name: mool   host name: masaka.moolenaar.net
process ID: 12559 (still running)
While opening file "main.c"
    dated: Tue May 29 19:46:12 2001 (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 main.c"
   to recover the changes (see ":help recovery").
   If you did this already, delete the swap file ".main.c.swp"
   to avoid this message. You get this message, because, when starting to edit a file, Vim checks if a
swap file already exists for that file. If there is one, there must be
something wrong. It may be one of these two situations. 1. Another edit session is active on this file. Look in the message for the
line with "process ID". It might look like this: process ID: 12559 (still running) The text "(still running)" indicates that the process editing this file
runs on the same computer. When working on a non-Unix system you will not
get this extra hint. When editing a file over a network, you may not see
the hint, because the process might be running on another computer. In
those two cases you must find out what the situation is yourself.
If there is another Vim editing the same file, continuing to edit will
result in two versions of the same file. The one that is written last will
overwrite the other one, resulting in loss of changes. You better quit
this Vim. 2. The swap file might be the result from a previous crash of Vim or the
computer. Check the dates mentioned in the message. If the date of the
swap file is newer than the file you were editing, and this line appears: modified: YES Then you very likely have a crashed edit session that is worth recovering.
If the date of the file is newer than the date of the swap file, then
either it was changed after the crash (perhaps you recovered it earlier,
but didn't delete the swap file?), or else the file was saved before the
crash but after the last write of the swap file (then you're lucky: you
don't even need that old swap file). Vim will warn you for this with this
extra line:      NEWER than swap file! UNREADABLE SWAP FILE Sometimes the line [cannot be read] will appear under the name of the swap file. This can be good or bad,
depending on circumstances. It is good if a previous editing session crashed without having made any
changes to the file. Then a directory listing of the swap file will show
that it has zero bytes. You may delete it and proceed. It is slightly bad if you don't have read permission for the swap file. You
may want to view the file read-only, or quit. On multi-user systems, if you
yourself did the last changes under a different login name, a logout
followed by a login under that other name might cure the "read error". Or
else you might want to find out who last edited (or is editing) the file and
have a talk with them. It is very bad if it means there is a physical read error on the disk
containing the swap file. Fortunately, this almost never happens.
You may want to view the file read-only at first (if you can), to see the
extent of the changes that were "forgotten". If you are the one in charge of
that file, be prepared to redo your last changes. WHAT TO DO? *

swap-exists-choices*

If dialogs are supported you will be asked to select one of five choices:

  Swap file ".main.c.swp" already exists! 
 [O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort, (D)elete it: O Open the file readonly. Use this when you just want to view the file and
don't need to recover it. You might want to use this when you know someone
else is editing the file, but you just want to look in it and not make
changes. E Edit the file anyway. Use this with caution! If the file is being edited
in another Vim, you might end up with two versions of the file. Vim will
try to warn you when this happens, but better be safe then sorry. R Recover the file from the swap file. Use this if you know that the swap
file contains changes that you want to recover. Q Quit. This avoids starting to edit the file. Use this if there is another
Vim editing the same file.
When you just started Vim, this will exit Vim. When starting Vim with
files in several windows, Vim quits only if there is a swap file for the
first one. When using an edit command, the file will not be loaded and you
are taken back to the previously edited file. A Abort. Like Quit, but also abort further commands. This is useful when
loading a script that edits several files, such as a session with multiple
windows. D Delete the swap file. Use this when you are sure you no longer need it.
For example, when it doesn't contain changes, or when the file itself is
newer than the swap file.
On Unix this choice is only offered when the process that created the
swap file does not appear to be running. If you do not get the dialog (you are running a version of Vim that does not
support it), you will have to do it manually. To recover the file, use this
command: :recover Vim cannot always detect that a swap file already exists for a file. This is
the case when the other edit session puts the swap files in another directory
or when the path name for the file is different when editing it on different
machines. Therefore, don't rely on Vim always warning you. If you really don't want to see this message, you can add the 'A' flag to the
'shortmess' option. But it's very unusual that you need this. For remarks about encryption and the swap file, see |:recover-crypt|. ==============================================================================

解决

因为我是未正常退出vim程序导致,而且我要编辑的文件是正常的,所以直接将sep文件删除(选择(D)elete it)即可。你也根据自己的实际情况做选择吧。

参考

vim命令文档:http://vimdoc.sourceforge.net/htmldoc/usr_11.html

Vim提示E325(锁机制)的更多相关文章

  1. MySQL学习笔记十六:锁机制

    1.数据库锁就是为了保证数据库数据的一致性在一个共享资源被并发访问时使得数据访问顺序化的机制.MySQL数据库的锁机制比较独特,支持不同的存储引擎使用不同的锁机制. 2.MySQL使用了三种类型的锁机 ...

  2. 【转】MSSQLServer数据库事务锁机制分析

    锁是网络数据库中的一个非常重要的概念,它主要用于多用户环境下保证数据库完整性和一致性.各种大型数据库所采用的锁的基本理论是一致的,但在具体实现上各有差别.目前,大多数数据库管理系统都或多或少具有自我调 ...

  3. MySQL- 锁机制及MyISAM表锁

    锁是计算机协调多个进程或线程并发访问某一资源的机制.在数据库中,除传统的计算资源(如CPU.RAM.I/O等)的争用以外,数据也是一种供许 多用户 共享的资源.如何保证数据并发访问的一致性.有效性是所 ...

  4. SQL Server 锁机制 悲观锁 乐观锁 实测解析

    先引入一些概念,直接Copy其他Blogs中的,我就不单独写了. 一.为什么会有锁 多个用户同时对数据库的并发操作时会带来以下数据不一致的问题: 1.丢失更新 A,B两个用户读同一数据并进行修改,其中 ...

  5. 安卓电量优化之WakeLock锁机制全面解析

    版权声明:本文出自汪磊的博客,转载请务必注明出处. 一.WakeLock概述 wakelock是一种锁的机制,只要有应用拿着这个锁,CPU就无法进入休眠状态,一直处于工作状态.比如,手机屏幕在屏幕关闭 ...

  6. MySQL InnoDB锁机制

    概述: 锁机制在程序中是最常用的机制之一,当一个程序需要多线程并行访问同一资源时,为了避免一致性问题,通常采用锁机制来处理.在数据库的操作中也有相同的问题,当两个线程同时对一条数据进行操作,为了保证数 ...

  7. Mysql锁机制--乐观锁 & 悲观锁

    Mysql 系列文章主页 =============== 从 这篇 文章中,我们知道 Mysql 并发事务会引起更新丢失问题,解决办法是锁.所以本文将对锁(乐观锁.悲观锁)进行分析. 第一部分 悲观锁 ...

  8. Mysql锁机制--索引失效导致行锁变表锁

    Mysql 系列文章主页 =============== Tips:在阅读本文前,最好先阅读 这篇(Mysql锁机制--行锁)文章~ 在上篇文章中,我们看到InnoDB默认的行锁可以使得操作不同行时不 ...

  9. SQL SERVER的锁机制

    SQL SERVER的锁机制(一)——概述(锁的种类与范围) SQL SERVER的锁机制(二)——概述(锁的兼容性与可以锁定的资源) SQL SERVER的锁机制(三)——概述(锁与事务隔离级别) ...

随机推荐

  1. 深入浅出Docker(二):Docker命令行探秘

    1. Docker命令行 Docker官方为了让用户快速了解Docker,提供了一个交互式教程,旨在帮助用户掌握Docker命令行的使用方法.但是由于Docker技术的快速发展,此交互式教程已经无法满 ...

  2. ansible的入门级使用

      author: headsen  chen   date: 2018-08-02   11:46:35 1,ansible的安装 yum install epel-release yum -y i ...

  3. TweenLite简单运用

    参考:TweenLite说明 1 ease TweenLite.to(nextLevelTip, 1.5, { x:0, ease:Bounce.easeOut } ); 2 delayCall 语法 ...

  4. 前端模拟(mock)接口数据(koa)

    在前后端分离开发项目时,经常会有前后端进度不一致,可能前端界面开发已经完成,就等接口了,如果等接口出来再联调的话时间可能会来不及. 这个时候,前端就可以根据制定好的接口规范和接口文档来mock接口数据 ...

  5. jenkins之构建maven项目

    新建java项目 修改列子的pop.xml提交 在git的web界面打一个tag 再次修改代码 再次push 5.38

  6. C#操作word之插入图片

    假如我们导出一份简历到word文档,那势必可能要同时导出我们包含的简历,下面就来试一下如何和通过C#代码,将图片插入到word文档中. 为了简便起见,就简单一点.类似下面这样的 姓名 张三 照片   ...

  7. Introduction to Structured Data json的2种形式 JAVA解析JSON数据 - JsonArray JsonObject

    https://developers.google.com/search/docs/guides/intro-structured-data Structured data refers to kin ...

  8. 【Loadrunner】性能测试报告实战

    一.一份好的性能测试报告需要遵循什么规则? 好的报告只需要遵循3点即可:清晰的结构.简要的语言以及数据的对比. 二.如何用Loadrunner自动到处HTML以及word版的报告? 1.导出html格 ...

  9. mysql 约束条件介绍

     mysql 约束条件介绍 约束条件与数据类型的宽度一样,都是可选参数 作用:用于保证数据的完整性和一致性主要分为: PRIMARY KEY (PK) 标识该字段为该表的主键,可以唯一的标识记录 FO ...

  10. Callable 和Runnable

    1:Callable ,方法调用会有返回值. private void callableTest throws ExecutionException, InterruptedException { E ...