Cutting and Pasting

The editor is equipped with two buffers that can be used to move pieces of text. These buffers are called the yank buffers. They are the buffers 9 and 10 of the file buffers. Buffer 9 is called the `YANK buffer' and buffer 10 (or 0) is called the `yank buffer'. The cut (also called yank) operation moves a piece of text from the currently active file buffer to the current yank buffer. This text is removed completely from the current file buffer. Which yank buffer is current can be seen in the status line. The fifth status character is either a `Y' or a `y' for YANK and yank respectively. If it is necessary to make the other yank buffer the current one in use, one can toggle between the two with Alt-Y. The first 8 buffers can have either yank buffer as their active yank buffer. As the yank buffers themselves can also be edited, one of these cannot be its own current yank buffer.

The copy operation copies a piece of text from the currently active file buffer to the current yank buffer. The paste operation copies the text in the current paste buffer to the position of the cursor in the currently active file buffer.

The first action taken by the editor when a cut or copy operation is given is to clear the yank buffer that is going to be used. Therefore it is rather dangerous to use a yank buffer for ordinary editing. Next the `range of action' is determined. This is the text between the mark and the cursor. The order of these is not important. Finally, for the copy operation the text in the range of action is then copied into the yank buffer. For the cut operation, the text in the range of action is also removed from the current buffer.

The paste command leaves the contents of the yank buffer unchanged so that it can be used again.

There are also some special cut, copy and paste commands for columns of text. The copy columns (or `block copy') command copies the text in the range of action, but only that which falls in the columns between those of the mark and the cursor (order unimportant) If this range involves empty spaces, they are filled with blanks. The cut columns (or `block cut') command also removes those columns from the current buffer. The paste columns (or 'block paste') command copies the contents of each line of the yank buffer into successive lines of the text of the current buffer, starting in each line in the column of the cursor. These operations can be convenient for moving tables or parts of a program for which you wish to maintain a certain column relation between lines. They can also be very handy to change the indentation of a range of text.

The cut, copy and paste commands can be performed with the function keys as follows.
F3 Cut (yank) the current range.
F4 Copy the current range.
F5 Paste to the cursor position.
sh-F3 Cut columns (block cut) from current range.
sh-F4 Copy columns (block copy) from current range.
sh-F5 Paste columns (block paste) to cursor position.

In addition all these commands can also be given from the command line. This feature is mainly useful for writing readable macro's. The command is given as a word in the command line or in the macro and the magic words are `cut', `copy', `paste', `bcut', `bcopy' and `bpaste'. The last three are for the cut, copy and paste in the block mode.

To see (or edit) the text in the yank buffers, one switches to these buffers with the Alt-9 or Alt-0 key combinations. This is explained further in the chapter on buffers.