Undo and repeat

Last revision August 2, 2004

Table of Contents:
  1. Editor choices on Unix
  2. Characteristics, advantages, and disadvantages of vi
  3. Basic text editing operations in vi
  4. Regular expressions
  5. File searching with grep
  6. More about regular expressions
  7. Intermediate text editing with vi
  8. Vi Quick Reference

There is a general "undo" facility in vi to reverse any changes made to the buffer by the most recent command. Vi saves information about the most recent change in a separate buffer so it can do this. Typing u causes the most recent change to be undone; typing a second u in succession "undoes" the "undo", getting your change back. Typing U undoes all changes on the current line.

The command . (a single period) will repeat the last change. For example, if you type


(that is, press the I key and then press the space bar three times, and then press the ESC key), this will insert three blank spaces at the beginning of the current line. You can make the same change to the next line by moving the cursor to any position on the next line and pressing . (the period key).

Comments or Questions?