Recovering data after massive deletions

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Recovering data after massive deletions

ericmsmith
Due to a faulty keyboard, an `x' was sent repeatedly to the
terminal with a file open in vim.
The large file was reduced to a few lines as a result.

I have salvaged some data from backups and the screen buffer. I
thought that I could recover the balance from vim's undo
buffer. However, I am not able to  access more data through g- and g+.
They report "You are already at the earliest/latest version"
respectively."

Also this message;
Swap file ".guys.swp" already exists!          "guys" 4L, 70C                                 E825: Corrupted undo file (num_head): /home/   eric/.guys.un~

And when executing undotree(), this alert;
E731: using Dictionary as a String

Is there anything worth trying to recover data before giving up?

--
Eric Smith

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Recovering data after massive deletions

Benjamin Fritz
On Thursday, January 2, 2014 8:44:41 AM UTC-6, Eric Smith wrote:

> Due to a faulty keyboard, an `x' was sent repeatedly to the
>
> terminal with a file open in vim.
>
> The large file was reduced to a few lines as a result.
>
>
>
> I have salvaged some data from backups and the screen buffer. I
>
> thought that I could recover the balance from vim's undo
>
> buffer. However, I am not able to  access more data through g- and g+.
>
> They report "You are already at the earliest/latest version"
>
> respectively."
>
>
>
> Also this message;
>
> Swap file ".guys.swp" already exists!          "guys" 4L, 70C                                 E825: Corrupted undo file (num_head): /home/   eric/.guys.un~
>
>
>
> And when executing undotree(), this alert;
>
> E731: using Dictionary as a String
>
>
>
> Is there anything worth trying to recover data before giving up?
>

Well you didn't mention how you tried using the return result of undotree(), but there are at least four plugins useful for viewing your undo history. See http://vim.wikia.com/wiki/Using_undo_branches#Plugins

But if you somehow exited Vim without saving, I think the undo information you're looking for may be lost, especially with that E825 message.

:help E825 says:

*E825*  The undo file does not contain valid contents and cannot be used.

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Recovering data after massive deletions

ericmsmith
Thanks Ben

I should have made it clear, I have not exited the edit session
in which these deletions occurred.

Ben Fritz wrote on Thu-02-Jan 14  4:19PM
> > And when executing undotree(), this alert;
> > E731: using Dictionary as a String
>
> Well you didn't mention how you tried using the return result of undotree(), but there are at least four plugins useful for viewing your undo history. See http://vim.wikia.com/wiki/Using_undo_branches#Plugins
These look good.
I fear there is a misconfiguration as I get this E731: error
message even when starting a fresh vim session and then exacting
undotree() after some editing. So seems to be a general issue with my
vim config and not only of the session in questions.

Some additional information:

The command wundo, writes a file identical to the automatic undofile
pepper:~> ls -l guys
-rw-r--r-- 1 eric eric 70 Dec 29 00:23 guys
pepper:~> ls -l .guys.un\~
-rw-r--r-- 1 eric eric 422693 Dec 29 00:23 .guys.un~
pepper:~> strings .guys.un\~
UnDo
A{ X
03 November 2013

>
> But if you somehow exited Vim without saving, I think the undo information you're looking for may be lost, especially with that E825 message.
>
> :help E825 says:
>
> *E825*  The undo file does not contain valid contents and cannot be used.
 I cannot remember the command that gave this message :(
(I ran the command some time ago - this problem has been pending
until I had some time to try a few things, before posting).

Eric

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Recovering data after massive deletions

Benjamin Fritz
On Thursday, January 2, 2014 5:08:03 PM UTC-6, Eric Smith wrote:
> I fear there is a misconfiguration as I get this E731: error
>
> message even when starting a fresh vim session and then exacting
>
> undotree() after some editing. So seems to be a general issue with my
>
> vim config and not only of the session in questions.
>

More likely you're using it wrong. undotree() actually does return a dictionary, not a string. So you can't do this:

:echo "undo tree is: ".undotree()

You should be able to do this, but it won't tell you very much without some heavy-duty parsing:

:echo string(undotree())

That's where the undo plugins come in.

You can try making sure the file is saved in its current state, making sure the undo file is written, then installing one of those plugins and starting a new Vim instance to edit the file. Ignore the swap exists error, you can always quit without saving in the new Vim. Then you should be able to navigate through your undo information more easily.

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Recovering data after massive deletions

LCD 47
In reply to this post by ericmsmith
On 2 January 2014, Eric Smith <[hidden email]> wrote:
> Due to a faulty keyboard, an `x' was sent repeatedly to the
> terminal with a file open in vim.
> The large file was reduced to a few lines as a result.
[...]

    Not a direct answer to your question, but there's a trick you can
use to avoid this kind of problems in the future:

        set undodir=~/.vim/undo
        set undofile

See ":help undo-persistence" for more details.

    You might also run something like this from a daily cron job, to
keep old undo files from piling up:

        find "$HOME"/.vim/undo -type f -name '%home%*' -mtime +30 -print0 | \
                xargs -0 rm -f

    /lcd

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Recovering data after massive deletions

ericmsmith
In reply to this post by Benjamin Fritz
Thanks Ben
> :echo string(undotree())

Indeed,
:echo undotree()
gives a lot of raw data.
> That's where the undo plugins come in.
After your previous mail, I installed Gundo and it worked just as
advertised. Regrettably, despite 988 entries, it did not contain
my missing data :(
>
> You can try making sure the file is saved in its current state, making sure the undo file is written, then installing one of those plugins and starting a new Vim instance to edit the file. Ignore the swap exists error, you can always quit without saving in the new Vim. Then you should be able to navigate through your undo information more easily.

Actually, I was surprised to fund that Gundo worked without
restarting my session.

Not often that I lose data in vim.

Thanks again for your help Ben.

Eric

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.