Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I recover my code lost during my last change in vim?

Tags:

linux

vim

I am very sad I deleted wrong function without commit to SVN server by using vim After I compiled it I found I made the mistake. I 'make' the file also via vim.

Now I haven't closed the file and it has .swp file. I tried to use 'u' command to restore my deletion but failed. vim said it's the latest changes. sigh.... Anyway I can restore my function?

Million thanks.

like image 577
CCC Avatar asked Apr 14 '11 11:04

CCC


1 Answers

To make Drasils pointer a lot more explicit:

 :undolist

g- to 'go back in time'

g+ to 'go forward in time'

Vim 7.3+ has undo 'branches': meaning that it will save state snapshots, even if linear history was overwritten (so it isn't reachable by simple u and )

like image 145
sehe Avatar answered Sep 25 '22 20:09

sehe