Solaris Advanced User's Guide

Undoing Changes

When you edit text and make changes to a vi file, you might occasionally wish that you had not changed something. vi's undo commands enable you to back up one operation and continue on from there.

Undoing the Previous Command

If you make a mistake in vi or if you just change your mind after an operation is completed, you can undo your last command by pressing u immediately after the command. You do not need to press Esc after you type u. By pressing u a second time you undo the undo.

Undoing Changes to a Line

Type U to undo all changes you've made to a line. This command works only if you haven't moved the cursor off the line. You do not need to press Esc after you type U.