Learning Vim: Day 4



Undoing, Redoing, and Exiting

Undoing

Keys to type What they do
(n)u Undo changes. Here n is an integer. For instance, when n is 1, you type u (or 1u), then only the last change will be undone. If you type 4u, then four changes will be undone
:u Undo one change
U Undo all latest changes on one line

Redoing

Keys to type What they do
Ctrl+R Redoes changes which were undone
:red Redoes one change which was undone

Exiting

Keys to type What they do
:q Quit Vim. This fails when changes have been made
:q! Quit without writing
:cq Quit always, without writing
:wq Write the current file and exit
:wq! Write the current file and exit always
ZZ Write current file, if modified, and exit
ZQ Quit current file and exit