#print Basic Alteration - Undoing and Redoing The worst thing about the delete command is that sometimes you wish you hadn't. No matter what single change you make to the file, though, vi can unchange it. If you accidentally remove 64 lines of the choicest prose you've ever composed (presumably by typing 64dd), simply hit the u key. Voila, those priceless words are back in the file. If you change your mind and want to be rid of them again, just hit that u key once again. Whammo, vi has undone its previous undo! Of course, you could then undo that undo and bring the lines back again. This can go on a long time, one undo bringing the lines back, the next getting rid of them again. Be careful, however! Vi can only undo the very most recent change you've made to the file. As a special case of this undo feature, if you make several changes all to the same line and want to undo all of them, just type U and the line will be restored to the way it was when you came to it. Another great convenience is the . command, for redoing the last change. This can be handy if you want to insert the same text in several places. Just do it once and then, for each other occurence, move to the proper place and hit the period key. Vi will automatically make the same change in the new place. Type 'ready' once again to try out these features. #user #create UndoRedo The undoing and redoing commands are as follows: u will undo the most recent change, including another undo U will restore the current line to the way it was when you last came to it . will redo whatever the last change did Play around for a while with these commands and get a feel for what they can do and what their limits are. -------------------------------------------------------- # cat /usr/lib/learn/vi/longtext >> UndoRedo vi UndoRedo #next 3.4 10