Wednesday, August 3, 2011

Re: swap files reverting my work erroneously

2011/8/2 David Ohlemacher <dohlemacher@scisol.com>:
> So once you have a swap file from a crash its there forever.   That is until
> you delete the swp manually.   And if you hit recover, your newer file
> contents will be wiped out by an older swap file's contents?
>
> I assumed (word chosen carefully), that once you've recovered from a swap
> file, the swap would be updated to mirror the current buffer.

If this happen and the swapfile results to be obsolete, then you could
easily loose the (updated) contets of the file (if you accidentally
save it).

Also, this obsolete swapfile may contains interesting changes not in
the last version in disk and you could be interested in examine (and
optionally merge) them.


To handle this situations I use two mappings:

command! Diff :w<space>!diff<space>-<space>%|less

...which lets me to examine the differences between the two files and
decide if I want to use the swapfile version (:w), the disk version
(:e %) or manually merge them starting from one or other.

(I didn't know about DiffOrig mentioned by Gary below --but sure I
will try it--)


When resolved the conflict, I have this other mapping to drop the
swapfile(s) easily and avoid future doubts.

command! Recovered
:!<space>rm<space>$(echo<space>%<space>|perl<space>-pe<space>'s/^(.*\/)?\.?(.*)$/\1.\2.swp\*/')

...this doesn't consider if there is more than one swapfiles and, off
course, sure can be fully implemented without external commands. But
it works for me ;-)


Regards.

--
Joan Miquel Torres__________________________________
Linux Registered User #164872
http://www.mallorcaweb.net/joanmiquel
BULMA: http://bulma.net http://breu.bulma.net/?l2301

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