7

If I did several modifications to the original file, i.e.

1 delete a line
2 insert some text
3 delete another line
4 delete the text added in step 2
5 insert some other text
6 ...

Now I want to recover the text deleted in step 2, is there a way of showing modifications and pick up something?

2 Answers 2

3

You can use :reg to view all actions in vim then paste that deleted lines by pressing "2 ctrl + p

Read more

1

If those are the only steps you've done, the deleted text should still be in a numbered register, which you can paste via e.g. "2p. If there have been too many edits in between, or the yank / delete was less than a full line, you won't find it there, though.

Then, you have to use Vim's undo / redo functionality to go back to that editing state, yank the text, then redo the changes. This can be done with the built-in g- and :earlier commands; plugins like Gundo or undotree aid in that by visualizing the undo tree.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .