Neovim's Undo List

Vim comes with a very powerful undo engine built in. While most editors support a linear undo/redo, where all changes are tracked sequentially, Vim maintains a tree of changes.

To start, let's demonstrate the basics with the following buffer:

Initial buffer content
one
two
three
four
five
six
seven
eight
NORMAL
Top
1:1
 

First, lets delete 4 lines:

Align Center
ciwten
ten
two
three
four
five
six
seven
eight
INSERT
Top
1:4
 

Now, to undo the most recent change, simply use u. The u command also takes a count, so if you want to undo the last 3 changes you can type 3u. If you prefer to use command-line mode, you can achieve the same result with the :undo command:

:undo [count]
Align Right
ten 
two
three
four
five
six
seven
eight
NORMAL
Top
1:3
 
:undolist
number changes  when               saved
     1       1  0 seconds ago

Now, let's redo the change, using C-R:

Align Left
<ESC>
ten
eleven
three
four
five
six
seven
eight
NORMAL
22%
2:6

C-R also accepts an optional count, and the command-line option is:

:redo [count]

Undolist