Original vi only supports single-level undo: the first time you press
u it performs an undo, and the second time you press it it undoes the undo, going back to the state before the undo.
Nvi (and possibly other implementations of vi) allow you to perform more undoes first by pressing
u, and then by pressing
. to repeat the undo operation.
Vim augments undo with two different undo behaviours.
In “vi-compatible” undo, the
u key behaves as above. If, however, you want to perform multiple undo operations, you first press
u to undo, and then press
Ctrl-R for further undoes.
In the Vim-style undo, pressing
u will always go backwards through the undolist, and pressing
Ctrl-R will always go forwards.
To switch from vi-compatible to Vim-style, you add the
u flag to your
'cpoptions' setting, but the most common way of doing this is by abandoning vi compatibility entirely, which is generally achieved simply by creating a .vimrc file*.
If you want to stop using vi compatibility in an existing session, you can use the command:
* Or by upgrading Vim past version 7.4.2111, which switches off
'compatible' in its