Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim - undo across all buffers / windows / open files etc

Tags:

vim

In vim, I would like to undo through all changes in all buffers, in chronological order.

e.g., in a vim session I typically have many tabs open, with many windows in each tab. Using u to undo (or g; / g, to move though the changelist), vim moves through changes made to that buffer, even if there are more recent made changes in other buffers. (Which I admit, is what I want most of the time.)

But is there a way to move back through changes in all buffers in chronological order? (I imagine vim would jump around from tab to tab, which would be ok.)

Why would this be useful? ... mostly so when I resume coding after a break I can remind myself of "where I'm up to", i.e all the changes I made last time.

(Using macvim 7.3)

UPDATE: responses about using git / mercurial make good points (thanks especially for git stash), but I'd still find this feature useful as it steps me back through recent changes, in order, with syntax coloring, inside vim etc.)

like image 887
mjeppesen Avatar asked May 23 '12 11:05

mjeppesen


1 Answers

You could come a long way with undolist:

:bufdo echo expand('%') | undolist

Results in, e.g. for a simple editing session:

SpiritParser.cpp
number changes  when               saved
     1       1  13:57:51
SpiritParser.h
number changes  when               saved
     1       1  13:57:55

To do this for all visible windows, do windo instead of bufdo. If you have multiple tabs, make that

:tabdo windo echo expand('%') | undolist
like image 136
sehe Avatar answered Sep 24 '22 06:09

sehe