← All lessons

7. Undo And Redo

Step 4 of 5

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:

Try this in the editor. Make a series of changes, wait a short while, and try the :earlier and :later command.

Loading editor…