JohnBeckett (talk | contribs) (Ask person who reported problem to use vim_use mailing list (and tweak tip)) |
(Insert TipProposed template + manual clean) |
||
Line 1: | Line 1: | ||
+ | {{TipProposed |
||
− | {{Tip |
||
+ | |id=0 |
||
− | |title=Swap file "..."already exists! - so diff it |
||
+ | |previous=0 |
||
− | |created=2007-09-11 |
||
+ | |next=0 |
||
+ | |created=September 11, 2007 |
||
|complexity=intermediate |
|complexity=intermediate |
||
− | |author=[[User:RichardBronosky]] |
+ | |author=[[User:RichardBronosky|Richard Bronosky]] |
+ | |version=7.0 |
||
− | |version=<!-- minimal vim version that can be used --> |
||
− | |text= |
||
}} |
}} |
||
− | |||
When opening a file (in this case geocode.py) in Vim, I regularly encounter messages like: |
When opening a file (in this case geocode.py) in Vim, I regularly encounter messages like: |
||
Line 49: | Line 49: | ||
If you want to know more about the commands used, use <tt>:help</tt>, for example: |
If you want to know more about the commands used, use <tt>:help</tt>, for example: |
||
− | * |
+ | *{{help|CTRL-W_l}} |
− | * |
+ | *{{help|:diffthis}} |
− | == |
+ | ==Comments== |
See also {{help|:DiffOrig}}. |
See also {{help|:DiffOrig}}. |
||
− | |||
− | ---- |
||
− | '''Note to person who used ''report a problem''''' |
||
− | |||
− | The Vim Tips wiki doesn't work like a forum. If you want to ask a question about a problem in Vim, please see the mailing list: http://groups.google.com/group/vim_use |
||
− | |||
− | ''Todo: Delete this comment after 2007/12/16.'' |
||
---- |
---- |
Revision as of 03:59, 5 January 2008
Proposed tip Please edit this page to improve it, or add your comments below (do not use the discussion page).
When opening a file (in this case geocode.py) in Vim, I regularly encounter messages like:
E325: ATTENTION Found a swap file by the name ".geocode.py.swp" owned by: rbronosky dated: Fri Sep 7 17:17:37 2007 file name: geocode.py modified: YES user name: rbronosky process ID: 6490 While opening file "geocode.py" dated: Fri Sep 7 17:17:04 2007 (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 geocode.py" to recover the changes (see ":help recovery"). If you did this already, delete the swap file ".geocode.py.swp" to avoid this message. Swap file ".geocode.py.swp" already exists! [O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:
This is the result of not properly closing an open buffer, usually because of a lost ssh connection. If there where unsaved changes, they can be recovered from this swap file. In order to know if this swap file is of value to me, I need to do some investigating. I have developed a system for resolving this quickly with as few keystrokes as possible.
- r # at the prompt hit "r" to recover the swap file
- :sav! /tmp/%
- :vs
- :diffthis
- CTRL-W_l
- :bp
- e # at the prompt hit "e" to edit anyway
- :diffthis
The result will be a vertically split screen with the swap file on the left and the regular file on the right. You will be in diff mode and if the files are identical they will both be folded into one line.
Sure, this would make a good script, but I am a big fan of "learn to do it by hand!". That way you can do it on any system, and you can use each of the little steps to aid your daily vimming.
If you want to know more about the commands used, use :help, for example:
Comments
See also :help :DiffOrig.