0

Can we set a restore point and restore a file's state while editing the file with VIM?...
I saw the "earlier" and "later" commands. But what if i dont remember the exact time to go back. So I want to know if there is a way to set restore points (and name them if possible) and restore the file using the restore point? Thanks..

2 Answers 2

3

There's no built in way to do this, but there's a superb plugin available here that allows you to do :UTMark tagName to mark the current state in the undo tree and use :UTMark tagName to restore that state.

Overall, using a source control system is much better for general long term history, but this can be useful for navigating small changes.

2
  • This is what I was looking for... Thanx
    – asdfg
    Feb 26, 2010 at 5:08
  • +1 Nice. Seems there's a vim plugin for everything :-).
    – sleske
    Feb 26, 2010 at 10:42
2

No, not that I'm aware of.

But you could just write (:w file) your file to a new name (e.g.with date+time appended). This will keep the original filename in your buffer (so :w, :x will continue to work normally).

If you write the temp files to a temp directory, the OS can clean them up automatically. For bonus points, make that into a small vim macro, so you can invoke it with one key.

2
  • 4
    or you could use source control.
    – Rook
    Feb 25, 2010 at 11:43
  • I have a source control system.. I wanted to revert state in one editing session... small changes... Thanx..
    – asdfg
    Feb 26, 2010 at 5:09

You must log in to answer this question.

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