if vim crashes while i'm editing a new file _but_ prior to my
having saved the file can i recover the edit session?
i imagine that i can recover the edit session from the "_.swp"
file that gvim creates. but i don't know how to associate a
.swp file with a text file so that attempting to edit the text
file (in the same directory as it's associated .swp file) will
trigger the gvim recovery process.
in other words, why can't i take example.txt.swp, rename it to
newname.txt.swp, and get gvim to initiate the recovery process
when i go to edit an empty newname.txt file?
thanks,
david
Yes. At a prompt, typing
vim -r
will give you a list of recoverable sessions in the current directory; typing
vim -r .swp
will recover from one of them, allowing you to save elsewhere.
> i imagine that i can recover the edit session from the "_.swp"
> file that gvim creates. but i don't know how to associate a
> .swp file with a text file so that attempting to edit the text
> file (in the same directory as it's associated .swp file) will
> trigger the gvim recovery process.
>
> in other words, why can't i take example.txt.swp, rename it to
> newname.txt.swp, and get gvim to initiate the recovery process
> when i go to edit an empty newname.txt file?
Unless the windows build of vim names things differently, you should
be able to rename .example.txt.swp to .newname.txt.swp to trigger
recovery the next time you edit newname.txt - but, at least on unix,
the names of swap files start with a leading "."; that's important.
~Matt
Or do the same with the :recover command in Vim.
:recover .swp
Also, swap files are not always named what you expect, particularly if you have
multiple sessions editing the same file, or multiple unnamed buffers when you were
in the same working directory. To see the swap files, it might help to show
invisible files or folders in Explorer, or do DIR /A:H (I think...something like
that to show hidden files) at a command prompt.
Cheers,
Ben.
Send instant messages to your online friends http://au.messenger.yahoo.com
> On Jan 8, 2008 5:31 PM, David M. Besonen wrote:
>>
>> i use gvim 7.1 primarily on windows 2000.
>>
>> if vim crashes while i'm editing a new file _but_ prior
>> to my having saved the file can i recover the edit
>> session?
>
> Yes. At a prompt, typing
> vim -r
> will give you a list of recoverable sessions in the current
> directory; typing
> vim -r .swp
> will recover from one of them, allowing you to save elsewhere.
thanks. that worked perfectly.
>> i imagine that i can recover the edit session from the
>> "_.swp" file that gvim creates. but i don't know how to
>> associate a .swp file with a text file so that attempting
>> to edit the text file (in the same directory as it's
>> associated .swp file) will trigger the gvim recovery
>> process.
>>
>> in other words, why can't i take example.txt.swp, rename
>> it to newname.txt.swp, and get gvim to initiate the
>> recovery process when i go to edit an empty newname.txt
>> file?
>
> Unless the windows build of vim names things differently,
> you should be able to rename .example.txt.swp to
> .newname.txt.swp to trigger recovery the next time you
> edit newname.txt - but, at least on unix, the names of
> swap files start with a leading "."; that's important.
i forgot to add the leading "." in my above example but i did
in fact include a leading "." in my testing. for whatever
reason, vim for windows does not seem to automatically recover
.swp files. the same .swp files will however be successfully
recovered when vim for windows is forced to recover them with
"vim -r .swp".
-- david
>> Yes. At a prompt, typing
>> vim -r
>> will give you a list of recoverable sessions in the current
>> directory; typing
>> vim -r .swp
>> will recover from one of them, allowing you to save
>> elsewhere.
>
> Or do the same with the :recover command in Vim.
>
> :recover .swp
this technique doesn't seem to work with vim for windows.
possibly for the same reason that the automatic recovery based
on the correctly named files being present doesn't seem to work
with vim for windows.
but since vim -r .swp does work with with vim for windows i'm a
happy camper.
-- david
Though I'm away from my work (Windows) PC at the moment, you
might try
:recover _.swp
with the underscore which may do the trick for you. No
guarantees, but I remember the unnamed buffer being given the
name "_.swp".
-tim