Go to the first, previous, next, last section, table of contents.

Copy and Paste

For those confined to a hardware terminal, these commands provide a cut and paste facility more powerful than those provided by most windowing systems.

Copying

Command: copy
(C-a [, C-a C-[, C-a ESC)
Enter copy/scrollback mode. This allows you to copy text from the current window and its history into the paste buffer. In this mode a vi-like full screen editor is active, with controls as outlined below.

CR/LF

Command: crlf [state]
(none)
This affects the copying of text regions with the C-a [ command. If it is set to `on', lines will be separated by the two character sequence `CR'/`LF'. Otherwise only `LF' is used. crlf is off by default. When no parameter is given, the state is toggled.

Scrollback

Command: defscrollback num
(none)
Same as the scrollback command except that the default setting for new windows is changed. Defaults to 100.

Command: scrollback num
(none)
Set the size of the scrollback buffer for new windows to num lines. The default scrollback is 100 lines. Use C-a i to view the current setting.

markkeys

Command: markkeys string
(none)
This is a method of changing the keymap used for copy/history mode. The string is made up of oldchar=newchar pairs which are separated by `:'. Example: The command markkeys h=^B:l=^F:$=^E would set some keys to be more familiar to emacs users. If your terminal sends characters, that cause you to abort copy mode, then this command may help by binding these characters to do nothing. The no-op character is `' and is used like this: markkeys @=L=H if you do not want to use the `H' or `L' commands any longer. As shown in this example, multiple keys can be assigned to one function in a single statement.

Movement Keys

h, j, k, l move the cursor line by line or column by column.

0, ^ and $ move to the leftmost column or to the first or last non-whitespace character on the line.

H, M and L move the cursor to the leftmost column of the top, center or bottom line of the window.

+ and - move the cursor to the leftmost column of the next or previous line.

G moves to the specified absolute line (default: end of buffer). | moves to the specified absolute column.

w, b, e move the cursor word by word. C-u and C-d scroll the display up/down by the specified amount of lines while preserving the cursor position. (Default: half screenfull).

C-b and C-f move the cursor up/down a full screen.

g moves to the beginning of the buffer.

% jumps to the specified percentage of the buffer.

Note that Emacs-style movement keys can be specified by a .screenrc command. (markkeys "h=^B:l=^F:$=^E") There is no simple method for a full emacs-style keymap, however, as this involves multi-character codes.

Marking

The copy range is specified by setting two marks. The text between these marks will be highlighted. Press space to set the first or second mark respectively.

Y and y can be used to mark one whole line or to mark from start of line.

W marks exactly one word.

Repeat Count

Any command in copy mode can be prefixed with a number (by pressing digits 0...9) which is taken as a repeat count. Example: C-a C-[ H 10 j 5 Y will copy lines 11 to 15 into the paste buffer.

Searching

/ vi-like search forward.

? vi-like search backward.

C-a s emacs style incremental search forward.

C-r emacs style reverse i-search.

Specials

There are, however, some keys that act differently here from in vi. Vi does not allow to yank rectangular blocks of text, but screen does. Press

c or C to set the left or right margin respectively. If no repeat count is given, both default to the current cursor position.
Example: Try this on a rather full text screen: C-a [ M 20 l SPACE c 10 l 5 j C SPACE.

This moves one to the middle line of the screen, moves in 20 columns left, marks the beginning of the paste buffer, sets the left column, moves 5 columns down, sets the right column, and then marks the end of the paste buffer. Now try:
C-a [ M 20 l SPACE 10 l 5 j SPACE

and notice the difference in the amount of text copied.

J joins lines. It toggles between 3 modes: lines separated by a newline character (012), lines glued seamless, or lines separated by a single space. Note that you can prepend the newline character with a carriage return character, by issuing a set crlf on.

v is for all the vi users who use :set numbers - it toggles the left margin between column 9 and 1.

a before the final space key turns on append mode. Thus the contents of the paste buffer will not be overwritten, but appended to.

A turns on append mode and sets a (second) mark.

> sets the (second) mark and writes the contents of the paste buffer to the screen-exchange file (`/tmp/screen-exchange' per default) once copy-mode is finished. See section Screen-Exchange.
This example demonstrates how to dump the whole scrollback buffer to that file:
C-a [ g SPACE G $ >.

C-g gives information about the current line and column.

x exchanges the first mark and the current cursor position. You can use this to adjust an already placed mark.

@ does nothing. Absolutely nothing. Does not even exit copy mode.

All keys not described here exit copy mode.

Paste

Command: paste [registers [destination]]
(C-a ], C-a C-])
Write the (concatenated) contents of the specified registers to the stdin stream of the current window. The register `.' is treated as the paste buffer. If no parameter is specified the user is prompted to enter a single register. The paste buffer can be filled with the copy, history and readbuf commands. Other registers can be filled with the register, readreg and paste commands. If paste is called with a second argument, the contents of the specified registers is pasted into the named destination register rather than the window. If `.' is used as the second argument, the display's paste buffer is the destination. Note, that paste uses a wide variety of resources: Usually both, a current window and a current display are required. But whenever a second argument is specified no current window is needed. When the source specification only contains registers (not the paste buffer) then there need not be a current display (terminal attached), as the registers are a global resource. The paste buffer exists once for every user.

Command: pastefont [state]
Tell screen to include font information in the paste buffer. The default is not to do so. This command is especially usefull for multi character fonts like kanji.

Command: slowpaste msec
(none)
Define the speed text is inserted by the paste command. If the slowpaste value is nonzero text is written character by character. screen will pause for msec milliseconds after each write to allow the application to process the input. only use slowpaste if your underlying system exposes flow control problems while pasting large amounts of text.

Command: readreg [register [filename]]
(none)
Does one of two things, dependent on number of arguments: with zero or one arguments it it duplicates the paste buffer contents into the register specified or entered at the prompt. With two arguments it reads the contents of the named file into the register, just as readbuf reads the screen-exchange file into the paste buffer. The following example will paste the system's password file into the screen window (using register p, where a copy remains):

C-a : readreg p /etc/passwd
C-a : paste p

Registers

Command: copy_reg [key]
(none)
Removed. Use readreg instead.

Command: ins_reg [key]
(none)
Removed. Use paste instead.

Command: process [key]
(none)
Stuff the contents of the specified register into the screen input queue. If no argument is given you are prompted for a register name. The text is parsed as if it had been typed in from the user's keyboard. This command can be used to bind multiple actions to a single key.

Command: register key string
(none)
Save the specified string to the register key.

Command: stuff string
(none)
Stuff the string string in the input buffer of the current window. This is like the paste command, but with much less overhead. You cannot paste large buffers with the stuff command. It is most useful for key bindings. See section Bindkey

Screen-Exchange

Command: bufferfile [exchange-file]
(none)
Change the filename used for reading and writing with the paste buffer. If the exchange-file parameter is omitted, screen reverts to the default of `/tmp/screen-exchange'. The following example will paste the system's password file into the screen window (using the paste buffer, where a copy remains):

C-a : bufferfile /etc/passwd
C-a < C-a ]
C-a : bufferfile

Command: readbuf
(C-a <)
Reads the contents of the current screen-exchange file into the paste buffer.

Command: removebuf
(C-a =)
Unlinks the screen-exchange file.

Command: writebuf
(C-a >)
Writes the contents of the paste buffer to a public accessible screen-exchange file. This is thought of as a primitive means of communication between screen users on the same host. See also C-a ESC (see section Copying).

History

Command: history
(C-a {)
Usually users work with a shell that allows easy access to previous commands. For example, csh has the command !! to repeat the last command executed. screen provides a primitive way of recalling "the command that started ...": You just type the first letter of that command, then hit C-a { and screen tries to find a previous line that matches with the prompt character to the left of the cursor. This line is pasted into this window's input queue. Thus you have a crude command history (made up by the visible window and its scrollback buffer).


Go to the first, previous, next, last section, table of contents.