The Use of Buffers

One useful function of an editor is to move and copy text from one position in a file to another, or to insert a different file into the file you are currently editing. "vi" gives you this capability through the use of buffers. "vi" has a General Purpose Buffer and 26 Named Buffers that you can use to hold text during an editing session. Whenever you use a delete command, the text you delete is automatically placed in the General Purpose Buffer. You can put this text at another location in your file by the use of the Put commands ([p] and [P]).

The contents of the General Purpose Buffer are reinitialized every time you issue a change, delete, or yank command (yank will be described below). You can put the text from the General Purpose Buffer into several different places in the Work Buffer as long as you do not issue one of these commands between Put commands. The use of named buffers comes in handy when you would like to move text around in your file but do not want to worry about accidently writing over text in the General Purpose Buffer. The 26 named buffers are named by the 26 letters of the alphabet (lower-case letters only). You can store 26 different blocks of text which can be used by later put commands. To specify which named buffer to use, type ["] and the letter of the buffer before typing the change, delete, or yank command.

You can find more information under:

Click here to go to the next section.

Or click here to go to the top of the chapter.