Recover deleted lines in Vim?

So I wrote in Vim in Ubuntu, I did :wq

and then came back to Wim. I copied the part of the text I want, then deleted that part, :wq

'd, then went back to Wim and accidentally copied the other part. I want the part that I copied first. I can't just push u

because I have already exited Vim and returned, so my bounces don't go back to the previous session.

Is there a way to recover the first copied part? Perhaps some kind of restore in Vim or see previous copies in Ubuntu?

Any help would be life saving and I would appreciate it, thanks.

+3


source to share


2 answers


If the bright text isn't too big, you should look at the result :reg

. You were probably twitching in register 1 or 2.

Registers persist between sessions, but there is a hard limit on the size of their contents. You can see this limitation on your system with :set viminfo?

: the default should include <50

and s10

, which means that the contents of the registers are preserved if they are less than 50 lines and / or less than 10Kb.



If you've yanked a couple of lines long enough, you should be fine.

See :h 'viminfo'

if you want to change this value.

+7


source


My answer will not help you in this case, but in the future you can enable permanent rollback from session to session.

To do this, you need to set a parameter undofile

.

Cm. :help persistent-undo



This will allow you to undo even after closing and reopening the file.

This option is only available since Vim 7.3

+4


source







All Articles