Monday, August 1, 2011

Re: swap files reverting my work erroneously

On 02/08/11 06:38, ZyX wrote:
> Reply to message «Re: swap files reverting my work erroneously»,
> sent 08:20:31 02 August 2011, Tuesday
> by Gary Johnson:
>
>> The trouble with
>> continually saving, though, is that you lose your reference for the
>> changes you've made to the file since you started editing. That's
>> not always important, but sometimes it's very handy. And having
>> swap files means I can do that without worry.
> Was not this solved by persistent undo introduced in vim-7.3?
>
> Original message:
>> On 2011-08-02, ZyX wrote:
>>> Reply to message «Re: swap files reverting my work erroneously»,
>>> sent 04:27:35 02 August 2011, Tuesday
>>>
>>> by Gary Johnson:
>>>> will tell you that it has found a swap file, etc. Regardless of you
>>>> choice, Vim will use a new swap file for the current buffer, named
>>>> .foo.swo. That file will be deleted at the end of your Vim session
>>>> if you exit normally. The swap file from your previous Vim session,
>>>> .foo.swp, will remain. That's the one you have to delete manually.
>>>
>>> It is false: if I choose to delete swap file (in the vim prompt, not from
>>> shell) it will use .foo.swp, not .foo.swo.
>>
>> I stand corrected. Thanks.
>>
>>>>> I think noswapfile will checked into my env repo. When you have 30+
>>>>> buffers open, this is not very useful to me.
>>>>
>>>> I think that is a bad idea. Vim creates swap files to protect your
>>>> data. They only persist after Vim has crashed, which is a good
>>>> thing. Once you have decided to use their contents after a crash,
>>>> or not, you can delete them and not be bothered with them until the
>>>> next time Vim crashes.
>>>
>>> I have swap files to prevent myself from editing one file in two vim
>>> instances simultaneously. Though sometimes something goes wrong and vim
>>> or the whole system crashes, but I never needed them to recover
>>> anything. All you need to have the same behavior is to train yourself to
>>> do «paused for thinking - hit {lhs of your mapping to :up} to save
>>> file». For me it happens even more times then «stopped inserting - exit
>>> insert mode».
>>
>> That's another good reason to use swap files. The trouble with
>> continually saving, though, is that you lose your reference for the
>> changes you've made to the file since you started editing. That's
>> not always important, but sometimes it's very handy. And having
>> swap files means I can do that without worry.
>>
>> Regards,
>> Gary

If you need a snapshot of a certain state of the disk file, take a copy.
If you need successive snapshots, use numbered or dated backups, Vim
supports them, after a fashion: see ":help backupext".

I'm sure I'm not the only one on these lists who started editing at a
time (and with an editor) where such luxuries as automatically recorded
swapfiles simply didn't exist: for us old-timers, it has become a reflex
to save the files whenever we stop editing (even if it's just to take a
leak), and at least once every quarter-hour.

I have the following mappings for that:

:map <F3> :wa|wv<CR>
:imap <F3> <C-O>:wa|wv<CR>

Of course, it complains if I have text in an unnamed buffer, but those
are usually throwaways anyway.

This way, even in case of a crash or of an AC cutoff, at most one or
two, usually none of the 32 files which I have in various windows and
tab pages in gvim, needs any rebuilding: everything was already saved,
and when gvim comes back up, I can answer Delete to all (or almost all)
of the swapfiles that it finds on restart.


Best regards,
Tony.
--
"You are old," said the youth, "as I mentioned before,
And make errors few people could bear;
You complain about everyone's English but yours --
Do you really think this is quite fair?"

"I make lots of mistakes," Father William declared,
"But my stature these days is so great
That no critic can hurt me -- I've got them all scared,
And to stop me it's now far too late."

--
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

No comments:

Post a Comment