Go to the previous, next section.

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.

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.

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 pastebuffer.

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 copybuffer, sets the left column, moves 5 columns down, sets the right column, and then marks the end of the copybuffer. 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 pastebuffer 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 copybuffer 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.

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

Paste

Command: paste [registers]

(C-a ], C-a C-])
Write the 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 given only the paste buffer is used. The paste buffer can be filled with the copy, history and readbuf commands.

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.

Registers

Command: copy_reg [key]

(none)
Store the current copybuffer contents in a register referenced by key. If the name is omitted you will be prompted to press the key.

Command: ins_reg [key]

(none)
Paste contents of register key into the current window's input stream.

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 users 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.

Screen-Exchange

Command: bufferfile [exchange-file]

(none)
Change the filename used for reading and writing with the copybuffer. 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:

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

Command: readbuf

(C-a <)
Reads the contents of the current screen-exchange file into the copy 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 previous, next section.