> Thank you all for your enlightening responses.
>
> My problem is gone (it's was a PEBKAC).
>
> Here's what happened:
>
> I edited a file, typed something in, then decided that the file is
> better saved in a different directory so I moved the file to that
> other directory. I typed more stuff into the file and save it. I don't
> remember the exact steps I took to do the file move.
>
> Move forward a few hours later, I open the file in its new location
> and I only see the first content that I typed in before, not the
> latest! So I thought I must have made this mistake:
>
> <thinking>
> 1. Edited a file, saved (without quitting vim).
> 2. In another terminal, *copied* the file to its new location.
> 3. Edited the file (in the same vim session), added more content, saved.
> 4. In that other terminal, I deleted the 'old' file.
> </thinking>
>
> When I opened the file in its new location I see the old content.
>
> At this point my thought was *!#*!#&!*@W!Y&#*!&.
>
> Then I remember that vim have a swap file and in that old directory
> there's exactly one swap file left over from some previous vim editing
> session.
>
> I created a new file with the same name as the file that the swap file
> is associated with but when I opened it in vim vim just created a new
> swapfile, 'ignoring' the old one.
>
> That's when I decided to ask the list.
>
> My attempts at using the :recover command failed (after creating a
> file with the same name as what the swap file is associated with) with
> a message saying that the swap file is broken.
>
> That was last Friday.
>
> Fast forward to today (Monday):
>
> Frustrated by this I decided enough is enough. I gotta handle it like
> a man: Don't fret over the lost bytes. So I proceeded with deleting
> the stale swap file.
>
> Then I go to the new directory where the file was moved to and opened
> the file and vim happily told me that a swap file exist for that file
> and when I choose recover *blam* the latest content of that file that
> I thought is gone forever is there, every single character!
>
> Heheh.. if that is not a case of PEBKAC then I don't know what is :)
>
> nazri.
>
> P/S: If you are curious the file contains usernames and passwords for
> "fake" gmail accounts to test out the web app in my $day_job.
>
Well, that's an argument against acting on a single file from two
different programs at the same time if I ever saw one.
Instead of copying the file to the new location in another terminal, use
:saveas /new/directory/filename.ext
This creates a copy of the current file at the new location and starts
editing the new file. If you want to immediately delete the old file,
you can do
:if has('unix') | exe '!rm' expand('#') | else | exe '!del' expand('#')
| endif
( ;-) ) all on one line, and you will usually know whether or not you're
on Windows, so you can instead type either
:!rm #
or
:!del #
which will remove the alternate file (the file which you edited just
before the current file). To remove it later, use :!rm or :!del
(depending on platform) followed by enough of a pathfilename to avoid
removing something else.
Best regards,
Tony.
--
All of the true things I am about to tell you are shameless lies.
-- The Book of Bokonon / Kurt Vonnegut Jr.
--
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