Wednesday, February 29, 2012

Re: Need help in recovering file in vi.

On Thursday 01 March 2012 05:46 AM, Tim Chase wrote:
> On 02/29/12 14:02, Tayade, Nilesh wrote:
>> While modifying my own code I accidently saved the file using
>> ".wq" (note the dot placed accidently) and lost the contents.
>> I am not really able to understand what this command did and
>> how the contents are lost.
>>
>> Could someone please provide any pointer on how can I recover
>> the contents?
>
> It would seem to me that you would have needed to issue ":.wq!" (note
> the exclamation point in addition to the period) or otherwise Vim would
> have cowardly refused with an E140. To understand what the period did,
> it's the range for the current line as detailed under ":help :w" with
> the ":[range]w[rite][!]" entry.
>
> If you have a rather recent version of Vim (I believe 7.3+) with
> persistent undo enabled, it might be possible to resurrect the file. Or,
> if you have backups enabled or keep your code/text in a VCS, you could
> use those to restore the original (though if you're asking here, it
> sounds like this isn't the case). Alternatively, you might be able to
> use a file-recovery tool at the OS level to resurrect the file from the
> disk.
I have an older version of vim installed (7.2) and as rightly guessed no
backups enabled.

>
> Otherwise, I'm afraid that you issued a "write the currently-named file
> with the contents of the range I specify ('.' is the current line) and I
> mean it!" command, so Vim obediently did as you asked even at the cost
> of your data.
Yes, this was the case, and I learned a lesson of being careful with the
"!".
Thanks for your response.

>
> -tim
>
>

--
Thanks,
Nilesh

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