Ben Schmidt wrote:
> >> Adding the ability to easily diff the recovered buffer
> >> against the on-disk file (the action recommended to the user)
> >> is a valid request.
> > I'm not proposing the following as a solution, but I will
> > mention that there is a related tip:
> > http://vim.wikia.com/wiki/Swap_file_%22...%22already_exists!_-_so_diff_it
>
>  And the 'Comment' at the end of the tip, IMHO, is the most useful part.

Yes, indeed.  Until this thread, I hadn't really understood all of the
options presented to the user when an old swapfile is detected, so I
hadn't thought to try the useful :DiffOrig user-defined command that
the help recommends under :help :DiffOrig.  That makes things much
smoother.

When I first started using Vim and got the 'Swap file exists' message, I
found it very hard to understand the difference between the options
presented.  Several things were unclear to me:

- If a previous Vim session crashed, did I lose any unsaved changes?
  How can I check?

- Why is recovery optional?  Wouldn't Vim just know how to pickup where
  it left off?

- Why is cleanup of dead swapfiles a manual step? Can't Vim figure that out?

- What gets opened when I choose "Open Read Only" - the swapfile or the
  real file?  What can I do with the read-only version once I open it?

- What happens if I Edit Anyway?  Do I have a swapfile?  Is that
  swapfile shared with another instance of Vim (which sounds bad)?
  How can I tell if I'm colliding with another live Vim instance instead
  of an old crashed one?

- How does Quit differ from Abort?

Questions like these make it very hard to know how to proceed.  I would
have been comforted to see "Help" among the listed options.  The message
does suggest :help recovery, which has lots of good explanation about
the options, but the user has to decide something before he can read
that help.  Perhaps a little more direct guidance would be helpful, such
as "To understand the options below, please read :help recovery, either
by starting a new instance of Vim or by choosing Abort below and
restarting Vim without trying to open any files".

>  Here's what I usually do. When I'm confronted with the 'Swap file
>  exists' message, I choose 'Recover' and then immediately issue
>  :DiffOrig (:help :DiffOrig). Once I've considered the changes, I
>  either (1) close the Scratch buffer that is the original file, to keep
>  the recovered file, and delete the old swap file, or (2) I edit the
>  file again and choose 'Delete' when confronted with the 'Swap file
>  exists' message.

Ben's suggestion above would be a welcome addition to the text of :help
recovery as an alternative to making a temporary file.

>  Now, perhaps a good solution is to have (1) a 'Recover and diff'
>  option that basically does 'Recover' and :DiffOrig in one step and (2)
>  a :KeepThis command that you can run in the buffer you're interested
>  in keeping, that writes the buffer you're editing to disk (you may
>  have even edited it, e.g. to incorporate *some* changes from a
>  recovered version), deletes all the stale swap files, closes any other
>  buffers that were editing that file (to avoid 'Buffer already editing
>  that file' issues, etc.), and re-edits the file so that its current
>  swap file is .swp not .swo and thus easily recoverable in future.

These options seem very friendly to me.

Michael Henry


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui