Time travelling with Vim
g- and g+ are useful, but there’s actually a much easier way to recover lost changes like the ones we talked about in the previous section.
Vim has two useful commands for time travelling in the document history: :earlier and :later. If you want to revert to the way that your document was 10 minutes ago, you can use the command :earlier 10m. To get back, use :later 10m.
There are a few ways you can use this:
:earlier 1is the same asg-, and:later 1is the same asg+.- You can use time units like
10s,10m,10h, and10dfor seconds, minutes, hours, and days respectively. - You can use
:earlier 3f, for example, to revert to the way that the file looked 3 file writes ago.
Try this in the editor. Make a series of changes, wait a short while, and try the :earlier and :later command.