The file /etc/termcap is a database describing terminals.
This database is used by packages such as
Lyrix[®], Multiplan, and sub-routine
packages such as
Terminals are described in termcap
by giving a set of capabilities and by describing
how operations are performed.
Padding requirements and initialization sequences
are included in termcap.
Entries in termcap
consist of a number of fields separated by colons (:).
The first entry for each terminal gives the names that are known
for the terminal, separated by vertical bars (|).
For compatibility with older systems the first name is always
2 characters long. The second name given is
the most common abbreviation for the terminal and the name
The last name given should be a long name fully identifying the terminal.
Only the last name can contain blanks for readability.
The following is a list of the capabilities that can
be defined for a given terminal. In this list,
(P) indicates that padding can be specified, and (P*) indicates
that padding can be based on the number of lines affected.
The capability type and padding fields are described in detail in
``Types of capabilities''.
Entries may continue over to multiple lines by giving a backslash (\)
as the last character of a line. Empty fields can be included for readability
between the last field on a line and the first field on the next.
Capabilities in termcap are of three types:
Boolean capabilities, which indicate that the terminal has
some particular feature, numeric capabilities giving the size of the terminal
or the size of particular delays, and string
capabilities, which give a sequence that
can be used to perform particular terminal operations.
Types of capabilities
All capabilities have two letter codes.
For instance, the fact that the Concept has ``automatic margins''
(i.e., an automatic return and linefeed when the end of a line is reached)
is indicated by the capability am.
The description of the Concept includes am.
Numeric capabilities are followed by the character ``#''
and then the value.
Thus co, which indicates the number of columns the terminal has,
gives the value ``80'' for the Concept.
Finally, string valued capabilities, such as ce (clear to end
of line sequence) are given by the two character code, an ``='',
and then a string ending at the next following ``:''.
A delay in milliseconds may appear after the ``='' in such a capability,
and padding characters are supplied by the editor after the rest of the string
is sent to provide this delay.
The delay can be either an integer, for example, ``20'',
or an integer followed by an ``'', such as ``3''.
A ``'' indicates that
the padding required is proportional to the number of lines affected by the
operation, and the amount given is the per-affected-unit padding required.
When a ``'' is specified, it is sometimes useful to give a delay of
the form ``3.5'' to specify a delay per unit to tenths of milliseconds.
A number of escape sequences are provided in the string valued capabilities
for easy encoding of characters there.
A \E maps to an ESCAPE character, ^x maps to
a Control x for any appropriate x, and the sequences
\n, \r, \t, \b, \f give a Newline,
Return, Tab, Backspace and Formfeed.
Finally, characters may be given as three octal digits after a ``\'',
and the characters ``^'' and ``\'' may be given as ``\^''
If it is necessary to place a colon (:) in a capability,
it must be escaped in octal as \072.
If it is necessary to place a null character in a string capability,
it must be encoded as \200.
The routines that deal with termcap use C strings,
and strip the high bits of the output very late so that
a \200 comes out as a \000 would.
The most effective way to prepare a terminal description is by imitating
the description of a similar terminal in termcap
and building up a description gradually, using partial descriptions
with ex to check that they are correct.
Be aware that a very unusual terminal may expose deficiencies in
the ability of the termcap file to describe it.
To test a new terminal description, you can set the environment variable
TERMCAP to a pathname of a file containing the description you
are working on and the editor will look there rather than in
/etc/termcap.TERMCAP can also be set to the termcap entry itself
to avoid reading the file when starting up the editor.
The number of columns on each line for the terminal is given by the
co numeric capability.
If the terminal is a CRT, the number of lines on the screen
is given by the li capability.
If the terminal wraps around to the beginning of the next line when
it reaches the right margin, it should have the am capability.
If the terminal can clear its screen, this is given by the
cl string capability.
If the terminal can backspace, it should have the bs capability,
unless a backspace is accomplished by a character other than ^H
in which case you should give this character as the bc
If it overstrikes (rather than clearing a position when a character is
struck over), it should have the os capability.
A very important point here is that the local cursor motions encoded
in termcap are undefined at the left and top edges of a
The editor will never attempt to backspace around the left edge, nor
will it attempt to go up locally off the top.
The editor assumes that feeding off the bottom of the screen will cause
the screen to scroll up, and the am capability tells whether
the cursor sticks at the right edge of the screen.
If the terminal has switch selectable automatic margins,
the termcap file usually assumes that this is on
(that is, am).
These capabilities suffice to describe hardcopy and ``glass-tty'' terminals.
Thus the Model 33 Teletype is described as:
while the Lear Siegler ADM-3 is described as:
Cursor addressing in the terminal is described by a
cm string capability. This capability uses
escapes (such as %x) in it.
These substitute to encodings of the current line or column position,
while other characters are passed through unchanged.
If the cm string is thought of as being a function, its
arguments are the line and then the column to which motion is desired,
and the ``%'' encodings have the following meanings:
%d replaced by line/column position, 0 origin
%2 like %2d - 2 digit field
%3 like %3d - 3 digit field
%. like printf(S) %c
%+x adds x to value, then %.
%>xy if value > x adds y, no output
%r reverses order of line and column, no output
%i increments line/column position (for 1 origin)
%% gives a single %
%n exclusive or row and column with 0140 (DM2500)
%B BCD (16*(x/10)) + (x%10), no output
%D Reverse coding (x-2(x%16)), no output (Delta Data).
Consider the HP2645, which, to get to row 3 and column 12, needs
to be sent \E&a12c03Y padded for 6 milliseconds. Note that the order
of the rows and columns is inverted here, and that the row and column
are printed as two digits.
Thus its cm capability is ``cm=6\E&%r%2c%2Y''.
The Microterm ACT-IV needs the current row and column sent
preceded by a ^T, with the row and column simply encoded in binary,
``cm=^T%.%.''. Terminals that use ``%.'' need to be able to
backspace the cursor (bs or bc), and to move the cursor
up one line on the screen (up introduced
This is necessary because it is not always safe to transmit
\t, \n^D and \r,
as the system may change or discard them.
A final example is the LSI ADM-3a, which uses row and column
offset by a blank character, thus ``cm=\E=%+ %+''.
If the terminal can move the cursor one position to the right, leaving
the character at the current position unchanged,
this sequence should be given as nd (non-destructive space).
If it can move the cursor up a line on the screen in the same column,
it should be given as up.
If the terminal has no cursor addressing capability,
but can home the cursor
(to very upper left corner of screen), this can be given as
ho; similarly, a fast way of getting to the lower left hand corner
can be given as ll; this may involve going up with up
from the home position, but the editor will never do this itself
(unless ll does) because it makes no assumption about
the effect of moving up from the home position.
If the terminal can clear from the current position to the end of the line,
leaving the cursor where it is, the sequence should be given as ce.
If the terminal can clear from the current position to the end of the
display, the sequence should be given as cd.
The editor only uses cd from the first column of a line.
If the terminal can open a new blank line before the line where the cursor
is, the sequence should be given as al. Note that this is done
only from the first position of a line.
The cursor must then appear on the newly blank line.
If the terminal can delete the line on which the cursor rests, the sequence
should be given as dl.
This is done only from the first position on the line to be deleted.
If the terminal can scroll the screen backwards,
the sequence can be given as sb, but al can suffice.
If the terminal can retain display memory above, the da capability
should be given, and if display memory can be retained below, then
db should be given.
These let the editor know that deleting a line on the screen may bring
non-blank lines up from below, or that scrolling back with sb
may bring down non-blank lines.
termcap has two ways of describing how intelligent
terminals handle insert/delete character operations.
The most common insert/delete character operations affect only the characters
on the current line and shift characters off the end of the line.
Other terminals, such as the Concept 100 and the Perkin Elmer Owl,
make a distinction between typed and untyped blanks on the screen, shifting
upon an insert or delete only to an untyped blank on the screen which is
either eliminated, or expanded to two untyped blanks.
You can find out
which kind of terminal you have by clearing the screen and entering
text separated by cursor motions. Enter ``abc def'', using local
cursor motions (not spaces) between the ``abc'' and the ``def''.
Then position the cursor before the ``abc'' and put the terminal in insert
mode. If entering characters causes the rest of the line to shift
rigidly and characters to fall off the end, your terminal does
not distinguish between blanks and untyped positions.
If the ``abc'' shifts over to the ``def'' which then move together around
the end of the current line and onto the next as you insert,
you have the second type of terminal, and should give the capability
in, which stands for ``insert null''.
No known terminals have an insert mode, not falling into one of
these two classes.
The editor can handle both terminals that have an insert mode
and terminals that send a simple sequence
to open a blank position on the current line.
Specify im as the sequence to get into insert mode,
or give it an empty value
if your terminal uses a sequence to insert a blank position.
Specify ei as the sequence to leave insert mode (specify this
with an empty value if you also gave im an empty value).
Now specify ic as any sequence needed to be sent just before sending
the character to be inserted.
Most terminals with a true insert mode will not support ic,
terminals that send a sequence to open a screen position should give it here.
(Insert mode is preferable to the sequence
to open a position on the screen if your terminal has both.)
If post insert padding is needed, give this as a number of milliseconds
in ip (a string option).
Any other sequence that may need to be sent after an insert of a
single character may also be given in ip.
It is occasionally necessary to move around while in insert mode
to delete characters on the same line (for example, if there is a tab after
the insertion position). If your terminal allows motion while in
insert mode, you can give the capability mi to speed up inserting
in this case.
Omitting mi will affect only speed. Some terminals
(notably Datamedia's) must not have mi because of the way their
insert mode works.
Finally, you can specify delete mode by giving dm and ed
to enter and exit delete mode, and dc to delete a single character
while in delete mode.
Highlighting, underlining, and visible bells
If your terminal has sequences to enter and exit standout mode, these
can be given as so and se respectively.
If there are several flavors of standout mode
(such as reverse video, blinking, or underlining -
half bright is not usually an acceptable standout mode
unless the terminal is in reverse video mode constantly),
the preferred mode is reverse video by itself.
It is acceptable, if the code to change into or out of standout
mode leaves one, or even two blank spaces on the screen,
as the TVI 912 and Teleray 1061 do.
Although it may confuse some programs slightly, it cannot be helped.
Codes to begin and end underlining can be given as us
and ue respectively.
If the terminal has a code to underline the current character and move
the cursor one space to the right,
such as the Microterm Mime,
the sequence can be given as uc.
(If the underline code does not move the cursor to the right,
specify the code followed by a nondestructive space.)
If the terminal has a way of flashing the screen
to indicate an error silently (a bell replacement),
the sequence can be given as vb; it must not move the cursor.
If the terminal should be placed in a different mode during
open and visual modes of ex, the sequence can be given as
vs and ve, sent at the start and end of these modes
respectively. These can be used to change from a underline
to a block cursor and back.
If the terminal needs to be in a special mode when running
a program that addresses the cursor, the codes to enter and exit
this mode can be given as ti and te.
This arises, for example,
from terminals like the Concept with more than one page of memory.
If the terminal has only memory relative cursor addressing and not
screen relative cursor addressing, a one screen-sized window must be
fixed into the terminal for cursor addressing to work properly.
If your terminal correctly generates underlined characters
(with no special codes needed),
even though it does not overstrike,
you should give the capability ul.
If overstrikes are erasable with a blank,
this should be indicated by specifying eo.
If the terminal has a keypad that transmits codes when the keys are pressed,
this information can be given. Note that it is not possible to handle
terminals where the keypad only works in local
(this applies, for example, to the unshifted HP 2621 keys).
If the keypad can be set to transmit or not to transmit,
enter these codes as ks and ke.
Otherwise, the keypad is assumed always to transmit.
The codes sent by the left arrow, right arrow, up arrow, down arrow,
and home keys can be given as kl, kr, ku, kd, and kh.
If there are function keys such as f0, f1, ..., f9, the codes they send
can be given as k0, k1, ..., k9.
If there are other keys that transmit the same code as the terminal expects
for the corresponding function, such as clear screen, the termcap
2 letter codes can be given in the ko capability,
for example, ``:ko=cl,ll,sf,sb:'', which says that the terminal has
clear, home down, scroll down, and scroll up keys that transmit
the same thing as the cl, ll, sf, and sb entries.
The ma entry is also used to indicate arrow keys on terminals
single character arrow keys. It is obsolete, but still in use in
version 2 of vi, which must be run on some minicomputers due to
This field is redundant with kl, kr, ku, kd, and kh.
It consists of groups of two characters.
In each group, the first character is what an arrow key sends, the
second character is the corresponding vi command.
These commands are h for kl, j
for kd, k for ku, l
for kr, and H for kh.
For example, the Mime would be :ma=^Kj^Zk^Xl:
indicating arrow keys left (^H), down (^K), up (^Z), and right (^X).
(There is no home key on the Mime.)
If the terminal requires other than a null (zero) character as a pad,
this can be given as pc.
If tabs on the terminal require padding, or if the terminal uses a
character other than ^I to tab, the sequence can be given as
Terminals that do not allow ``~'' characters to be displayed
(such as Hazeltines), should indicate hz.
Datamedia terminals that echo carriage-return-linefeed for carriage return,
and then ignore a following linefeed, should indicate nc.
Early Concept terminals, that ignore a linefeed immediately after an
am wrap, should indicate xn.
If an erase-eol is required to get rid of standout
(instead of merely writing on top of it), xs should be given.
Teleray terminals, where tabs turn all characters moved over to blanks,
should indicate xt.
Other specific terminal problems may be corrected by adding more
capabilities of the form xx.
If the leading character for commands to the terminal (normally
the escape character) can be set by the software, specify
the command character(s) with the capability CC.
Other capabilities include is, an initialization string
for the terminal,
and if, the name of a file containing long initialization strings.
These strings are expected to properly clear and then set the tabs
on the terminal, if the terminal has settable tabs.
If both are given, is is displayed before if.
This is useful where if is /usr/lib/tabset/std,
but is clears the tabs first.
If there are two very similar terminals, one can be defined as being
just like the other with certain exceptions.
The string capability, tc, can be given
with the name of the similar terminal.
This capability must be last and the combined length of the
two entries must not exceed 2048.
Since termlib routines search the entry from left to right,
and since the tc capability is replaced by the corresponding
entry, the capabilities given at the left override the ones in the similar
A capability can be canceled with xx@ where xx is the
This defines a 2621nl that does not have the ks or ke
capabilities, and does not turn on the function key labels when in visual mode.
This is useful for different modes for a terminal, or for different
This table lists XENIX extensions to the termcap capabilities.
It shows which codes generate information input from the
keyboard to the program reading the keyboard and which codes generate
information output from the program to the screen.
XENIX extension codes are additional to the standard entries
and are used by several application programs. As with the
standard entries, not all modes are supported by all
applications or terminals. Some of these entries refer
to specific terminal output capabilities (such as GS for
``graphics start''). Others describe character sequences
sent by keys that appear on a keyboard.
There are also entries that are used to attribute special
meanings to other keys (or combinations of keys) for use
in a particular software program. Some of the XENIX
extension capabilities have a similar function to standard
They are used to redefine specific keys (such
as using function keys as arrow keys).
capabilities are included in the /etc/termcap
file, as they are required for some utilities.
Sent by Char Left key
Delete attribute string
Sent by End key
Upper-right (1st quadrant) corner character
Upper-left (2nd quadrant) corner character
Lower-left (3rd quadrant) corner character
Lower-right (4th quadrant) corner character
Upper right (1st quadrant) corner character (double)
Upper left (2nd quadrant) corner character (double)
Lower left (3rd quadrant) corner character (double)
Lower right (4th quadrant) corner character (double)
Center graphics character (similar to +)
Center graphics character (double)
Down tick character (double)
Graphics mode end
Number of chars taken by GS and GE
Horizontal bar character
Horizontal bar character (double)
left-tick character (double)
right-tick character (double)
Graphics mode start
Up-tick character (double)
Vertical bar character
Vertical bar character (double)
Sent by <Home> key (if not kh)
Multiplan initialization string
Sent by Next unlocked celL key
Sent by Toggle reference key
Sent by <Return> key
Sent by Word Left key
Sent by Word Right key
Some application programs make use of special editing codes.
CR and CL move the cursor one character right and
WR and WL move the cursor one word right and left
CW changes windows, when they are used in the program.
Some application programs turn off the cursor. This is accomplished
using CF for cursor off and CO to turn it back on.
If the terminal has graphics capabilities, this mode can be turned on and
off with the GS and GE codes. Some terminals generate
graphics characters from all keys when in graphics mode
(such as the Visual 50). The other G codes specify particular
graphics characters accessed by escape sequences. These characters are
available on some terminals as alternate graphics character sets (not as
a bit-map graphic mode). The vt100 has access to this
kind of alternate graphics character set, but not to
a bit-map graphic mode.
allows only 256 characters for string capabilities, and the routines in
do not check for overflow of this buffer.
The total length of a single entry (excluding only escaped newlines)
may not exceed 2048.
The ma, vs, and ve entries are specific to the
Not all programs support all entries.
There are entries that are not supported by any program.
XENIX termcap extensions are explained in detail in the
software application documentation.
Refer to the
manual page, for a description of the character sequences used
by the monitor device on your specific system.