VIM hint E325 (lock mechanism)

Source: Internet
Author: User

Background

When dealing with some oversized files with the vim command, you sometimes encounter a deadlock and have to force the exit. However, when you use the VIM command again to access the file, a "e325:attention" prompt appears. If you do not handle it, it will appear every time.

Analysis

After some verification, this hint is a protection mechanism (or lock mechanism) of the VIM program to the file. When we open a file with the vim command, a hidden SWP file is automatically generated. If Vim is still working on this file, or if for some reason it does not exit normally, the SWP file will persist. When we open this file again with the VIM command, the program detects that a SWP file exists and reminds us not to do so. The original text reads as follows:

*
11.3*crashed or not?*
ATTENTION* *
E325*vim tries to protect-doing stupid things.  Suppose Innocentlystart editing a file, expecting the contents of the file to show up. Instead,vim produces a very long message:e325:attentionFound A swap file by the name ". Main.c.swp"owned By:mool Dated:tue May 21:09:28 2001file name: ~mool/vim/vim6/src/main.cModified:noUser Name:mool host Name:masaka.moolenaar.netprocess id:12559 (still running)While opening file "Main.c"dated:tue 19:46:12 2001(1) Another program may editing the same file.If This is the case, being careful not to enddifferent instances of the same file when making changes.Quit, or continue with caution.(2) an edit session for the this file crashed.If This is the case, use ": Recover" or "vim-r main.c"To recover the changes (see ": Help Recovery").If You do this already, delete the swap file ". Main.c.swp"To avoid the this message.You get the message, because, when starting to edit a file, Vim checks if Aswap file already exists for that file.  If There is one, there must besomething wrong. It may be one of these, situations.1.  Another edit session is active on the 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'll not get the this extra hint.  When editing a is file over a network, the hint, because the process might is running on another computer.      In those-cases you must find-out-what's the situation is yourself.  If there is another Vim editing the same file, continuing to edit would result in both versions of the same file.  The one that's written last would overwrite the other one, resulting in loss of changes. You better quit this vim.2.  The swap file might is 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:yesThen you very likely has a crashed edit session, which is worth recovering.  If the date of the file is newer than the date of the swap file and then either it's changed after the crash (perhaps Recovered it earlier, but didn ' t delete the swap file?), or else the file is saved before the crash but after the LA  St write of the swap file (then you ' re lucky:you don ' t even need this old swap file). Vim would warn you to this and this extra line:newer than swap file!Unreadable SWAP Filesometimes the line[cannot be read]Would appear under the name of the swap file. This can is good or bad,depending on circumstances.  It is good if a previous editing session crashed without have made anychanges to the file.  Then a directory listing of the swap file would showthat it has zero bytes. You may delete it and proceed.  It's slightly bad if you don't have Read permission for the swap file.  Youmay want to view the file Read-only, or quit.  On multi-user systems, if Youyourself does the last changes under a different login name, a logoutfollowed by a login under  That other name might cure the "read error". Orelse might want to find out who last edited (or are editing) the file andhave a talk with them.  It is very bad if it means there are a physical read error on the diskcontaining the swap file. Fortunately, this almost never happens.  Want to view the file Read-only in first (if you can) and to see Theextent of the changes that were "forgotten". If you is the one in charge Ofthat file, being prepared toRedo your last changes. What to do?*
swap-exists-choices*if dialogs is supported you'll be the 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.  If you just want to view the file and don ' t need to recover it.   You might want to use this if you know someone else is editing the file, but you just want Changes.  E Edit the file anyway.  Use the WITH caution!  If the file is being edited in another Vim, you might end up with the file versions of. Vim would try to warn if this happens, but better is safe then sorry.  R Recover the file from the swap file. Use this if you know that the swap file contains changes it want to recover.  Q Quit.  This avoids starting to edit the file.      Use this if there is another Vim editing the same file.  When your just started vim, this would exit vim.  When starting vim with files in several windows, Vim quits only if there are a swap file for the first one. When using an edit command, the file is not being loaded and you is taken back to the previously edited file.  A Abort. Like Quit, but also aBort further commands. This was useful when loading a script that edits several files, such as a session with multiple windows.  D Delete the swap file.   The use of this is sure you longer need it.      For example if it doesn ' t contain changes, or when the file itself is newer than the swap file. On Unix This choice was only offered when the process was created the swap file does not appear to be running.  If You don't get the dialog (running a version of Vim that does notsupport it), you'll have it manually. To recover the file, use Thiscommand:: RecoverVim cannot always detect this a swap file already exists for a file. This isthe if the other edit session puts the swap files in another directoryor when the path name for the file is  Different when editing it on Differentmachines. Therefore, don ' t rely on Vim all 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's need this. For remarks about encryption and the swap file, see |:recover-crypt|. ==============================================================================

Solve

Because I was not normal exit Vim program caused, and I want to edit the file is normal, so directly delete the Sep file (select (D) elete it) can. You also choose according to your own actual situation.

Reference
Vim Command document: http://vimdoc.sourceforge.net/htmldoc/usr_11.html

VIM hint E325 (lock mechanism)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.