Last Updated: February 25, 2016
·
1.784K
· joegardiner

Revert documents in vim

You can revert files instead of using "u" to undo. It is not 100% accurate but can be useful if you've made a big mistake and need to revert an entire file back a rough number of minutes.

This creates a branch of the file you are editing.

Out of insert mode user the following commands:

:earlier (number of minutes)m

and...

:later (number of minutes)m

For example

:earlier 20m

You can also set more specific times by substituting m with the following:

s = seconds
m = minutes
h = hours
d = days

For example:

:later 4d

3 Responses
Add your response

That is awesome. I never knew that was possible.

over 1 year ago ·

Also: Use :e! to revert to the last saved version.

over 1 year ago ·

I also recommend the Gundo plugin. http://sjl.bitbucket.org/gundo.vim/

over 1 year ago ·