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


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 30.6 Local Settings for vi and ex Chapter 30
vi Tips and Tricks
Next: 30.8 Get Back What You Deleted with Numbered Buffers
 

30.7 Using Buffers to Move or Copy Text

In a vi editing session, your last deletion ( d or x ) or yank ( y ) is saved in a buffer. You can access the contents of that buffer and put the saved text back in your file with the put command ( p or P ). A frequent sequence of commands is:

5dd   
delete 5 lines

   
move somewhere else


p   
put the 5 deleted lines back in a new

   
location, below the current line

What fewer new users are aware of is that vi stores the last nine ( 30.8 ) deletions in numbered buffers. You can access any of these numbered buffers to restore any (or all) of the last nine deletions. (Small deletions, of only parts of lines, are not saved in numbered buffers, however.) Small deletions can be recovered only by using the p or P command immediately after you've made the deletion.

vi also allows you to yank (copy) text to "named" buffers identified by letters. You can fill up to 26 (a-z) buffers with yanked text and restore that text with a put command at any time in your editing session. This is especially important if you want to transfer data between two files, because all buffers except named buffers are lost when you change files. See article 30.5 .

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


Previous: 30.6 Local Settings for vi and ex UNIX Power Tools Next: 30.8 Get Back What You Deleted with Numbered Buffers
30.6 Local Settings for vi and ex Book Index 30.8 Get Back What You Deleted with Numbered Buffers

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