How can I undo all changes since opening a buffer? I imagine there may be some form of :earlier
that does this.
Update: Many are suggesting
To revert the current buffer to the state prior to the very first
change recorded in the Vim undo list (see :help undo-tree
), we
can use two consecutive invocations of the :undo
command:
:u1|u
The first command (:undo 1
) reverts to the state of the buffer after
the very first registered change, while the second command (:undo
)
reverts that first change itself.
Starting with version 8.1 (see :helpg Patch 8.0.1441
), Vim allows
to pass the change number 0 as an argument to the :undo
command
to refer to the state before any registered changes, thus making
it possible to achieve the same effect in a single-command invocation:
:u0