Edits Between Files

When you give a yank buffer a one-letter name, you have a convenient way to move text from one file to another. Named buffers are not cleared when a new file is loaded into the vi buffer with the :e command (). Thus, by yanking (copying) or deleting text from one file (into multiple named buffers if necessary), calling in a new file with :e, and putting the named buffer into the new file, you can transfer material between files.

The following example illustrates how to transfer text from one file to another.

Keystrokes Results
"f4yy
With a screen editor you can scroll the page, move the cursor, delete lines, insert characters, and more, while seeing the results of the edits as you make them


Yank four lines into buffer f.
:w
"practice" 6 lines 238 characters


Save the file.
:e letter
Dear Mr. Henshaw: I thought that you would be interested to know that: Yours truly,


Enter the file letter with :e. Move cursor to where the copied text will be placed.
"fp
Dear Mr. Henshaw: I thought that you would be interested to know that: With a screen editor you can scroll the page, move the cursor, delete lines, insert characters, and more, while seeing the results of the edits as you make them Yours truly,


Place yanked text from named buffer f below the cursor.

If you yank into a buffer and type the buffer name as an uppercase letter, your new text will be added to the text already in the buffer. For example, you might use "f4yy to yank four lines into the buffer named f. If you then move somewhere else and type "F6yy, with an uppercase F, that will add six more lines to the same f buffer - for a total of ten lines. You can yank into the uppercase buffer name over and over. To output all of the yanked text, use the lowercase letter - like "fp. To clear the buffer and start over, use its lowercase name ("fy...) again.

- LL, JP