WhileMarcin's response it correct, I would like to add a different emphasis. I asked a similar question months ago.

Specifically, when I open a file and find a swap file, I _almost always_ want to _delete_ that swap file _immediately_. Rarely, I'll want to recover. If I did, it would be only be five minutes later after correcting the swap file creating event.

Ignoring seems dangerous. It leaves that swap file around. Next time you edit the file, you again will be prompted. However the swap may be way out of date. Using it might blow away newer edits.

There is probably a use case for ignoring swap files, but not in my work flow.

-d

On 04/09/2012 12:11 PM, Marcin Szamotulski wrote:
On 11:44 Mon 09 Apr     , Eric Weir wrote:
The last couple days I have been getting a "swap file already exists" message when I 
attempt to open a file. When that happens, as you are aware, the user is given several options, 
which to me are extremely confusing. A factor I feel certain is involved is that on a couple 
occasions either vim or a vim window was closed in other than normal fashion. [E.g., on one 
occasion, while I was running the computer on battery power, the battery ran down while I was away 
from my desk. Normally, when that happens the computer goes into suspend mode and when I attach the 
power cord the computer starts back up in the state it was in when it went into suspend mode. This 
time, however, it shut down. After restarting the computer I got the "swap file already 
exists" message when I restarted vim and attempted to load a file.]

When I get the message I am never certain what to do. Usually I know that the 
file had been saved after the last edit. Even in that case i'm not sure what to 
do to open the most recently saved copy of the file. When I'm uncertain, I 
don't know which option will give me the most recent copy of the file. Or if I 
make the wrong choice, how I might recover---if that is possible at all.

I imagine experienced programmer-users of vim would not have this problem. I am 
neither. I am a non-programming relative novice vim user. Help regarding my 
options and best choices in this situation would be greatly appreciated.

Thanks,
------------------------------------------------------------------------------------------
Eric Weir
[email protected]

"Human coexistence and social life constitute the good common to us all
from which and thanks to which all cultural and social goods derive."

- Zygmunt Bauman

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Hi,

Vim saved all the changes you are making in a swap file. It is updated
automatically (see :help 'updatetime' and :help 'updatecount') - i.e. the
changes you made even after your last :write are there (though some changes
might not be there depending on 'updatetime' and 'updatecount' settings).

Now, when you open a file "./file.txt" such that the swap file exists (it
usually has the name "./.file.txt.swp" or "./.file.txt.swo" if the first name
already existed, which means you already ignored one swap file) then vim gives
you the swap exists message with several choices:
                        'o'     Open read-only
                        'e'     Edit anyway
                        'r'     Recover
                        'd'     Delete swapfile
                        'q'     Quit
                        'a'     Abort
where 'o' and 'e' will read the "./file.txt" and vim will create for it a new
swap file (usually "./.file.txt.swo" since "./.file.txt.swp" already exists on
your disc), the 'r' (Recover) will couse vim to read the "./.file.txt.swp"
file (which should be more recent than the actual file "./file.txt"), 'd' will
delete the swap file (usually you don't want this, unless you know that the
disc file is the one that you want), 'q' will quit vim and 'a' will abort the
operation (vim will still run).

You should carefully read ":help swap-file". There are some plugins which
helps with viewing the changes between the contents of the swap file and the
disc file, for example:
http://www.vim.org/scripts/script.php?script_id=3068

There are some other useful settings which you might want to follow, for
example how to set incremental backup with vim:
http://vim.wikia.com/wiki/Keep_incremental_backups_of_edited_files

Best regards,
Marcin


--
David Ohlemacher
Principle Software Engineer
Scientific Solutions Inc.
99 Perimeter Rd Nashua New Hampshire 03063
603-880-3784

. o .
. . o
o o o

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to