|
Cut, Copy and Paste |
1 Introduction
Red supports two different copy-and-paste styles: X Windows style and
the MacOS / MS Windows style. In X Windows, there is no copy operation -
as soon as a text is selected, it can be pasted. (You can think of it
as an immediate copy operation: as soon as the text is selected, it is
copied into the paste buffer.) In MacOS and Windows, there are explicit
copy and cut operations to move the selected text into the buffer. Both
models have their advantages.
Red supports two paste buffers, one for each model. The first buffer
is called the primary paste buffer. It is filled using the
X Windows model. Each selection is immediately entered into the primary
buffer. It can be pasted with the
paste-primary
function (which is, for example, bound to the middle mouse button).
The second buffer is the secondary paste buffer, and it
is filled using explicit cut
and copy operations. It can be pasted
using the paste-secondary
function.
Using the primary buffer is convenient for quickly copying text. Text
can be selected and immediately inserted elsewhere. (This is especially
quick with the mouse, since the second mouse button places the cursor
and pastes the buffer - text can be moved very quickly this way.)
The secondary buffer is good for keeping text in the buffer a bit longer.
If, for example, text has to be cut, then you want to find a word to
replace with the buffer, you could not use the primary buffer: since the
find function itself selects text to
mark the found location, the primary buffer is overwritten. You could
now replace the found word using paste-secondary.
2 How to make a selection
Cut and paste commands are closely connected to selections in the text, so
I'll say a few words about selections first.
Selections can be made both with the mouse or with keys.
2.1 Selecting with the mouse
Selections can be made using the mouse by
- dragging (that is: clicking and holding) with the left mouse
button over the text to be selected
- clicking with the first mouse button at the start of the text
to be selected (setting the cursor), then clicking with the right
mouse button at the end
- double click on a word to select that word
- triple click on a line to select that line
- continue clicking after a triple click to select additional lines
- continue clicking after a double click with the shift key held
down to select additional words
2.2 Selecting with keys
- To select a word, use
select-word.
- To select a line, use
select-line.
- To select an arbitrary region of text, move the cursor to the
beginning of the text you want to select, then use
set-mark to set a mark at that
position. After that, move the cursor to the end of the text to be
selected and use
select-region to select the region between the mark and the cursor.
Any selection function that is called while a selection is already on,
adds to the current selection rather than replacing it.
3 Copy
The copy function copies the text
currently selected into the secondary paste buffer.
4 Cut
Cut removes the selection from the text and
places it into both paste buffers.
Some different cut functions are available. Some of them require text to
be selected first, others don't. All text that is cut, whether it was selected
or not, is placed into both paste buffers.
- cut cuts the current selection.
- cut-word cuts the complete
word the cursor is in.
- cut-to-end-of-word
cuts the text from the cursor position to the end of the current word.
- cut-line cuts the current
line.
- cut-to-end-of-line
cuts the text from the cursor position to the end of the current line.
- cut-region cuts the text
from the mark (see set-mark) to
the cursor position.
All functions except cut can be
called without making a selection.
4.1 Collecting Cuttings
Most of the time, cutting some text replaces the previous text in the paste
buffer. There is an exception: when two cut functions are called in straight
succession (no other function is used inbetween) the second cut adds
to the cut buffer.
Using this technique, several lines, for instance, can be moved
easily. You can call cut-line several times in succession to
place all the lines into the paste buffer, move the cursor to
the destination position, and then call paste.
5 Paste
Paste-primary pastes the
primary paste buffer at the cursor position. It can be called by
using the middle mouse button (place cursor and paste), or with keys.
The primary paste buffer contains the text last cut or selected in
any X application (not only Red). You can select text in a
terminal window and paste it into Red.
Paste-secondary pastes
the secondary paste buffer at the cursor position. If a selection is
on when calling paste-secondary, the contents of the paste
buffer replace the current selection.
Main index