Vim - discard all buffers / windows / open files, etc.

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

for example, in a vim session, I usually have a lot of tabs open, and each tab has many windows. Using u to undo (or g; / g, to move through the list of changes), vim moves through the changes made to this buffer, even if new changes are made to other buffers. (Which I admit is what I want most of the time.)

But is there a way to revert to changes in all buffers in chronological order? (I assume that vim jumped from tab to tab, which would be fine.)

Why is this useful? ... basically, when I resume coding after a break, I can remind myself of β€œwhere I am,” that is, all the changes that I made last time.

(Using macvim 7.3)

UPDATE: the answers about using git / mercurial make good points (especially thanks for git stash ), but I would still find this feature useful, as it forces me to revert to the latest changes so that, with syntax coloring, inside vim, etc. .)

+8
vim
source share
2 answers

You can go a long way with undolist :

 :bufdo echo expand('%') | undolist 

Results, for example. 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, do it

 :tabdo windo echo expand('%') | undolist 
+4
source share

You should use some kind of version control: Git, Mercurial, Subversion, whatever ...

Every morning you can read your project log and go through previous commits to find out what has changed, you can create branches to work on certain functions, you write a clean and descriptive commit message to better understand your previous changes, etc.

Or you can do something like :windo u . But that sounds messy.

+1
source share

All Articles