The closest thing the original vi
has to multiple undo (aside from U
which can revert multiple changes within a single line) is the numbered registers,
which hold the nine most recent changes or deletions.
If you put from a numbered register, subsequent dot commands
will increment that register when it repeats the command.
E.g. with the following text, with the cursor line indicated with >
,
aaaa
> bbbb
cccc
dddd
eeee
the command dd..
will result in:
aaaa
> eeee
If you then type "1P
, vi will put the most recent deletion
from register "1
:
aaaa
> dddd
eeee
Hitting .
will put the contents of the next most recent
register, by doing "2P
, and hitting .
again will put
the contents of register "3
.
So, in short, "P..
will put back all the text you deleted,
leaving you with
aaaa
> bbbb
cccc
dddd
eeee
Not brilliant, but better than nothing! More usefully you
can use it at the beginning or end of the buffer to quickly
inspect what's in your numbered registers. Then you can
easily delete what you don't need.
It's documented in
vim under :help redo-register
.