Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I do "version control" in vim?

For example, I have a working code but not fast enough, so I want to record this version of the code and ten continue to optimize it, and maybe got a better version, then record this version again, so on.

If I eventually failed to get a fast code, I want to roll back to the original working code.

I guess this could be achieved by using undo branch, but I didn't find how to do it.

like image 324
Derrick Zhang Avatar asked Dec 09 '11 08:12

Derrick Zhang


2 Answers

Use a version control system. I recommend Git + Fugitive.

Seriously!

You won't look back.

like image 99
Johnsyweb Avatar answered Oct 18 '22 01:10

Johnsyweb


Yes, you can add undo branches functionality that makes it more like a version control system.

In vim 7.3 you can have persistent undo, as described here, you only need to add the following lines to your .vimrc.

set undodir=~/.vim/undodir
set undofile

To get the most of undo branches I highly recommend gundo since you can use it to visualize the tree and see the diffs of the commits.

like image 29
HaskellElephant Avatar answered Oct 18 '22 00:10

HaskellElephant