home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 30.7 Using Buffers to Move or Copy Text Chapter 30
vi Tips and Tricks
Next: 30.9 Using Search Patterns and Global Commands
 

30.8 Get Back What You Deleted with Numbered Buffers

Being able to delete large blocks of text at a single bound is all very well and good, but what if you mistakenly delete 53 lines that you need? There's a way to recover any of your past nine deletions, because they're saved in numbered buffers. The last delete is saved in buffer 1, the second-to-last in buffer 2, and so on.

To recover a deletion, type <"> (the double quote character), identify the buffered text by number, then give the put command. To recover your second-to-last deletion from buffer 2, type:

"2p

The deletion in buffer 2 is placed on the line below the cursor.

If you're not sure which buffer contains the deletion you want to restore, you don't have to keep typing <"> n p over and over again. If you use the repeat command ( . ) with p after u (undo), it automatically increments the buffer number. As a result, you can search through the numbered buffers as follows:

"1pu.u.u 
etc.

to put the contents of each succeeding buffer in the file one after the other. Each time you type u , the restored text is removed; when you type a dot (.), the contents of the next buffer is restored to your file. Keep typing u and . until you've recovered the text you're looking for.

- TOR from O'Reilly & Associates' Learning the vi Editor , Chapter 4


Previous: 30.7 Using Buffers to Move or Copy Text UNIX Power Tools Next: 30.9 Using Search Patterns and Global Commands
30.7 Using Buffers to Move or Copy Text Book Index 30.9 Using Search Patterns and Global Commands

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System