Home > Articles

Basic vi Skills

  • Print
  • + Share This
This chapter is from the book

Named and Unnamed Buffers

The vi editor has a total of 27 buffers: 26 named buffers (a–z) and 1 unnamed buffer that is overwritten by each new operation.

Unless you have specified a named buffer, all operations use the unnamed buffer, and two operations right after each other have the second operation overwrite the data from the first operation.

Named buffer operations are always preceded by the double quotation mark ("), which tells the machine that a named buffer operation is to follow.

When you perform named buffer operations, the buffers must be referred to in the command as either a lowercase or uppercase letter of the alphabet (which is part of the command, and not sent to the buffer):

  • Lowercase buffer letter—Overwrites the buffer

  • Uppercase buffer letter—Appends to buffer

For example, the following string, when entered in Command mode with the cursor in column 1, causes line 1 to copy the next four lines to the named buffer (a), overwriting any contents of that named buffer:

"a3yy

The Message Line echoes the number of lines and the operation, such as

3 lines yanked

The syntax for the editing commands remains the same; just remember to precede the operation with a double quotation mark, a lower- or uppercase character, and then whatever operation you want to perform with that named buffer.

Other examples include

  • "ayy—Yanks a line to the named buffer (a), overwriting the current contents

  • "Ayy—Appends the current line to the a buffer

  • "A3yy—Yanks three lines from the current cursor position and appends the lines to the A buffer

  • "ap—Pastes the a buffer to the right of the cursor (the case of the buffer letter is meaningless in paste operations)

NOTE

Performing single-line operations with named buffers usually doesn't echo anything to the Message Line, but anything involving more than one line of data echoes the number of lines affected. Word operations are usually not noted in the Message Line either.

  • + Share This
  • 🔖 Save To Your Account