Home | man(7)


When  a program using the library prompts for an input string us‐
ing the function it reads characters from the terminal.   Invalid
input  bytes  that do not form characters are silently discarded.
For each character read, one editor  command  is  executed.   The
mapping  of  input  characters  to editor commands depends on the
editing mode.  There are three editing modes: vi insert mode,  vi
command  mode,  and  emacs  mode.  The default is vi insert mode.
The program can switch the default to emacs mode by using the  or
functions,  and  the  user can switch to emacs mode either in the
configuration file or interactively with the editor  command,  in
all three cases executing the builtin command.  If trying to read
from the terminal results in end of file or an error, the library
signals  end of file to the program and does not return a string.
All default bindings described below can be overridden  by  indi‐
vidual  programs and can be changed with the builtin command.  In
the following tables, indicates a character  with  the  bit  0x40
flipped,  and indicates a character with the bit 0x80 set.  In vi
insert mode and in emacs  mode,  all  Meta-characters  considered
printable  by  the  current are bound to instead of to the editor
command listed below.  Consequently, in UTF-8 mode, most  of  the
Meta-characters  are  not  directly accessible because their code
points are occupied by printable Unicode  characters,  and  Meta-
characters are usually input using the editor command.  For exam‐
ple,  to enter in order to call the editor command in emacs mode,
call by pressing and releasing the escape key  (or  equivalently,
Ctrl-[),  then press and release the key.  If you have configured
a Meta-key on your keyboard, for example with the Ctrl-Meta-char‐
acters are directly accessible.  For example, to enter  in  order
to  call the editor command in emacs mode, hold down the keys and
at the same time.  Alternatively, press and  release  the  escape
key,  then  press  and release In vi input mode, input characters
are bound to the following editor commands by default: All  other
input  characters  except the NUL character (Ctrl-@) are bound to
In vi command mode, input characters are bound to  the  following
editor  commands  by default: In emacs mode, input characters are
bound to the following editor commands by default: The  remaining
characters  in  the  range  0x20 to 0x7e are bound to If standard
output is not connected to a terminal device or was used  to  set
to  0,  all input character bindings are disabled and all charac‐
ters typed are appended to the edit buffer.  In  that  case,  the
edit  buffer  is  returned to the program after a newline or car‐
riage return character is typed, or  after  the  first  character
typed  if  was used to set to non-zero.  Most editor commands ac‐
cept an optional argument.  The argument is entered by  prefixing
the  editor  command  with  one or more of the editor commands or
When an argument is not provided, it defaults to 1.  For most ed‐
itor commands, the effect of an argument is to repeatedly execute
the command that number of times.  When talking about a character
string from a left character to a right character, the left char‐
acter is included in the string, while the right character is not
included.  If an editor command causes an error, the input  char‐
acter  is  discarded,  no action occurs, and the terminal bell is
rung.  In case of a non-fatal error, the terminal  bell  is  also
rung, but the editor command takes effect anyway.  In the follow‐
ing  list,  the default key bindings are listed after each editor
command.  If in argument input mode, append the  input  digit  to
the  argument  being  read.   Otherwise, switch to argument input
mode and use the input digit as the most significant digit of the
argument.  It is an error if the input character is not  a  digit
or  if  the  existing argument is already greater than a million.
Clear the screen and display the edit buffer at the top.   Ignore
any argument.  Read a line from the terminal bypassing the normal
line  editing  functionality  and execute that line as an builtin
command.  If in vi command mode, also switch back  to  vi  insert
mode.   Ignore  any argument.  Delete the character at the cursor
position.  With an argument, delete that  number  of  characters.
In  emacs mode, it is an error if the cursor is at the end of the
edit buffer.  In vi mode, the last character in the  edit  buffer
is  deleted  in  that  case,  and it is an error if the buffer is
empty.  Delete the character to the left of the cursor  position.
With an argument, delete that number of characters.  It is an er‐
ror  if  the cursor is at the beginning of the edit buffer.  Move
to the left to the closest beginning of a word, delete the string
from that position to the cursor, and save it to the cut  buffer.
With an argument, delete that number of words.  It is an error if
the  cursor  is at the beginning of the edit buffer.  If in argu‐
ment input mode, append the input digit  to  the  argument  being
read.   Otherwise,  call It is an error if the input character is
not a digit or if the existing argument is already greater than a
million.  Discard the edit buffer and indicate end of file to the
program.  Ignore any argument.  Discard the input  character  and
do  nothing.   In insert mode, insert the input character left of
the cursor position.  In replace mode, overwrite the character at
the cursor and move the cursor to the right by one character  po‐
sition.   Accept an argument to do this repeatedly.  It is an er‐
ror if the input character is the NUL character (Ctrl-@).   Fail‐
ure  to enlarge the edit buffer also results in an error.  Delete
the string from the cursor position to the end of  the  line  and
save  it  to  the  cut buffer.  Ignore any argument.  In vi mode,
move the cursor to the first  non-space  character  in  the  edit
buffer.   In  emacs mode, move the cursor to the beginning of the
edit buffer.  Ignore any argument.  Can be  used  as  a  movement
command  after  or Move the cursor to the end of the edit buffer.
Ignore any argument.  Can be used as a movement command after  or
Append a newline character to the edit buffer and return the edit
buffer to the program.  Ignore any argument.  Move the cursor one
character  position to the right.  With an argument, move by that
number of characters.  Can be used as a movement command after or
It is an error if the cursor is already at the end  of  the  edit
buffer.   Replace  the  edit  buffer  with the next history line.
That line is older than the current line.  With an  argument,  go
forward by that number of history lines.  It is a non-fatal error
to  advance  by  more  lines than are available.  Move the cursor
down one line.  With an argument, move down  by  that  number  of
lines.  It is an error if the edit buffer does not contain enough
newline characters to the right of the cursor position.  Move the
cursor  one  character  position  to the left.  With an argument,
move by that number of characters.  Can be  used  as  a  movement
command  after  or It is an error if the cursor is already at the
beginning of the edit buffer.  Replace the edit buffer  with  the
previous history line.  That line is newer than the current line.
With  an argument, go back by that number of lines.  It is a non-
fatal error to back up by more lines than  are  available.   Move
the cursor up one line.  With an argument, move up by that number
of  lines.   It  is  an error if the edit buffer does not contain
enough newline characters to the left  of  the  cursor  position.
Move  the  cursor to the left to the closest beginning of a word.
With an argument, repeat that number of times.  Can be used as  a
movement command after or It is an error if the cursor is already
at the beginning of the edit buffer.  Read one character from the
terminal bypassing the normal line editing functionality and call
on it.  If trying to read the character returns end of file or an
error, call instead.  Redisplay everything.  Ignore any argument.
Replace  the  edit  buffer  with the next matching history entry.
Replace the edit buffer with the previous matching history entry.
Call a macro.  See the section about below for details.   Discard
the  contents  of the edit buffer and start from scratch.  Ignore
any argument.  Exchange the character at the cursor position with
the one to the left of it and move the cursor to the character to
the right of the two exchanged characters.  Ignore any  argument.
It  is  an  error  if  the cursor is at the beginning of the edit
buffer or if the edit buffer contains less than  two  characters.
This  editor  command always results in an error.  Capitalize the
string from the cursor to the end of the current word.  That  is,
if  it  contains  at  least one alphabetic character, convert the
first alphabetic character to upper case, and convert all charac‐
ters to the right of it to lower case.  In  any  case,  move  the
cursor  to  the next character after the end of the current word.
Copy the string from the beginning of the  current  word  to  the
cursor  and insert it to the left of the cursor.  Move the cursor
to the character after the inserted string.  It is  an  error  if
the  cursor  is  at  the  beginning of the edit buffer.  Copy the
string from the cursor to the mark to the cut buffer.  It  is  an
error  if the mark is not set.  Delete the string from the cursor
to the end of the current word and save it to the cut buffer.  It
is an error if the cursor is at the end of the edit  buffer.   If
the cursor is not at the end of the line, delete the character at
the cursor.  If the edit buffer is empty, indicate end of file to
the  program.   It is an error if the cursor is at the end of the
edit buffer and the edit buffer is not empty.  Delete the charac‐
ter to the left of the cursor.  It is an error if the  cursor  is
at the beginning of the edit buffer.  Exchange the cursor and the
mark.  Exchange the two characters to the left of the cursor.  It
is  an error if the cursor is on the first or second character of
the edit buffer.  Emacs incremental next search.  Emacs incremen‐
tal reverse search.  Delete  the  entire  contents  of  the  edit
buffer and save it to the cut buffer.  Delete the string from the
cursor to the mark and save it to the cut buffer.  It is an error
if  the  mark is not set.  Convert the characters from the cursor
to the end of the current word to lower case.  Set the  bit  0x80
on  the next character typed.  Unless the resulting code point is
printable, holding down the key while typing that character is  a
simpler  way  to achieve the same effect.  Move the cursor to the
end of the current word.  Can be used as a movement command after
or It is an error if the cursor is already at the end of the edit
buffer.  Set the mark at the  current  cursor  position.   Switch
from  insert to overwrite mode or vice versa.  If in argument in‐
put mode, multiply the argument by 4.  Otherwise, switch to argu‐
ment input mode and set the argument to 4.  It is an error if the
existing argument is already greater than a million.  Convert the
characters from the cursor to the end of the current word to  up‐
per  case.   Paste  the  cut  buffer  to  the left of the cursor.
Switch to vi insert mode.  Unless the cursor is  already  at  the
end  of  the  edit  buffer, move it one character position to the
right.  Switch to vi insert mode and move the cursor to  the  end
of  the edit buffer.  If an alias function was defined by calling
the or function with the argument read  one  character  from  the
terminal  bypassing  the  normal line editing functionality, call
the alias function passing the argument that was  specified  with
as  the first argument and the character read, with an underscore
prepended, as the second argument, and pass the  string  returned
from the alias function to It is an error if no alias function is
defined or if trying to read the character results in end of file
or  an error.  Change the case of the character at the cursor and
move the cursor one character position to the right.   It  is  an
error  if  the  cursor  is already at the end of the edit buffer.
Delete the string from the cursor to the  position  specified  by
the  following  movement command and save a copy of it to the cut
buffer.  When given twice in a row, instead delete the whole con‐
tents of the edit buffer and save a copy of it to the cut buffer.
In either case, switch to vi insert mode after that.  Delete  the
string  from  the cursor position to the end of the line and save
it to the cut buffer, then switch to  vi  insert  mode.   Discard
pending actions and arguments and switch to vi command mode.  Un‐
less  the  cursor is already at the beginning of the edit buffer,
move it to the left by one character position.  Insert a  charac‐
ter  at  the  beginning  of  the  edit buffer and return the edit
buffer to the program.  Delete the string from the cursor to  the
position  specified  by the following movement command and save a
copy of it to the cut buffer.  When given twice in a row, instead
delete the whole contents of the edit buffer and save a  copy  of
it  to  the  cut buffer.  Delete the character to the left of the
cursor.  It is an error if the cursor is already at the beginning
of the edit buffer.  Move the cursor to the end  of  the  current
space delimited word.  Can be used as a movement command after or
It  is  an  error if the cursor is already at the end of the edit
buffer.  Move the cursor to the end of the current word.  Can  be
used  as a movement command after or It is an error if the cursor
is already at the end of the edit buffer.  Insert the first  word
from  the  most  recent  history entry after the cursor, move the
cursor after to the character after the inserted word, and switch
to vi insert mode.  It is an error if there is no  history  entry
or  the  most  recent history entry is empty.  Enter insert mode.
Move the cursor to the beginning of the edit buffer and switch to
vi insert mode.  Delete the string from the beginning of the edit
buffer to the cursor and save it to the cut buffer.  If the  edit
buffer  is  empty, indicate end of file to the program.  It is an
error if the edit buffer is  not  empty.   Consider  opening  and
closing  parentheses, braces, and brackets as delimiters.  If the
cursor is not at a delimiter, move it to the right until it  gets
to one, then move it to the matching delimiter.  Can be used as a
movement command after or It is an error if there is no delimiter
at  the cursor or in the string to the right of the cursor, or if
the first such delimiter has no  matching  delimiter.   Move  the
cursor  to the right to the beginning of the next space delimited
word.  Can be used as a movement command after or It is an  error
if  the cursor is already at the end of the edit buffer or on its
last character.  Read one character from the  terminal  bypassing
the  normal line editing functionality and move the cursor to the
right to the next instance of that character in the edit  buffer.
Can  be used as a movement command after or If trying to read the
character results in end of file or an error, call  instead.   It
is  an error if the character is not found searching to the right
in the edit buffer.  Move the cursor to the right to  the  begin‐
ning  of  the next word.  Can be used as a movement command after
or It is an error if the cursor is already at the end of the edit
buffer or on its last character.  Insert a copy of the cut buffer
to the right of the cursor.  It is an error if the cut buffer  is
empty.   Insert  a copy of the cut buffer to the left of the cur‐
sor.  It is an error if the cut buffer is empty.  Move the cursor
to the left to the next beginning of a space delimited word.  Can
be used as a movement command after or It is an error if the cur‐
sor is already at the beginning of the  edit  buffer.   Read  one
character  from  the  terminal  bypassing the normal line editing
functionality and move the cursor to the left  to  the  next  in‐
stance  of  that  character in the edit buffer.  Can be used as a
movement command after or If trying to read the character results
in end of file or an error, call instead.  It is an error if  the
character  is not found searching to the left in the edit buffer.
Move the cursor to the left to the next beginning of a word.  Can
be used as a movement command after or It is an error if the cur‐
sor is already at the beginning of the  edit  buffer.   Redo  the
last non-motion command.  Repeat the most recent character search
in  the same search direction.  Can be used as a movement command
after or Repeat the most recent character search in the  opposite
search direction.  Can be used as a movement command after or Re‐
peat the most recent history search in the same search direction.
Repeat  the most recent history search in the opposite search di‐
rection.  Switch to vi replace  mode,  and  automatically  switch
back  to vi command mode after the next character typed.  See for
a description of replace mode.  It is an error if the  cursor  is
at  the end of the edit buffer.  Switch to vi replace mode.  This
is a variant of vi insert mode; see for the difference.   Replace
the  edit  buffer  with the next matching history entry.  Replace
the edit buffer with the previous matching history entry.  Delete
the character at the cursor and switch to vi insert mode.  Delete
the entire contents of the edit buffer, save a copy of it in  the
cut  buffer,  and  enter  vi insert mode.  Move the cursor to the
column specified as the argument.  Can be used as a movement com‐
mand after or Replace the edit buffer with the specified  history
entry.  Read one character from the terminal bypassing the normal
line  editing  functionality  and move the cursor to the right to
the character before the next instance of that character  in  the
edit  buffer.  Can be used as a movement command after or If try‐
ing to read the character results in end of  file  or  an  error,
call  instead.   It  is  an  error  if the character is not found
searching to the right in the edit buffer.   Read  one  character
from the terminal bypassing the normal line editing functionality
and  move  the cursor to the left to the character after the next
instance of that character in the edit buffer.  Can be used as  a
movement command after or If trying to read the character results
in  end of file or an error, call instead.  It is an error if the
character is not found searching to the left in the edit  buffer.
Undo the last change.  Undo all changes to the edit buffer.  Copy
the  string from the cursor to the position specified by the fol‐
lowing movement command to the cut buffer.  When given twice in a
row, instead copy the whole contents of the edit  buffer  to  the
cut  buffer.   Copy  the string from the cursor to the end of the
edit buffer to the cut buffer.  If in argument input mode, multi‐
ply the argument by ten.  Otherwise, move the cursor to  the  be‐
ginning  of  the  edit buffer.  Can be used as a movement command
after or If an input character is bound to the editor command at‐
tempts to call a macro.  If the input character by  itself  forms
the  name  of  a macro, that macro is executed.  Otherwise, addi‐
tional input characters are read until the string read forms  the
name  of  a macro, in which case that macro is executed, or until
the string read matches the beginning of  none  of  the  existing
macro  names,  in which case the string including the final, mis‐
matching character is discarded and the terminal  bell  is  rung.
There  are  two kinds of macros.  Command macros execute a single
editor command.  Keyboard macros return a  string  of  characters
that  is  appended  as  a  new  line to the The following command
macros are defined by default in vi command  mode  and  in  emacs
mode:  In vi command mode, they are also defined by default with‐
out the initial escape character.  In addition, the library tries
to bind the strings generated by the arrow keys  as  reported  by
the  database to these editor commands, unless that would clobber
user settings.  In emacs mode, the two-character string is  bound
to  the editor command.  The library maintains an input queue op‐
erated in FIFO mode.  Whenever it needs an  input  character,  it
takes the first character from the first line of the input queue.
When  the queue is empty, it reads from the terminal.  A line can
be appended to the end of the input queue  in  several  ways:  By
calling  one  of  the  keyboard  By calling the editor command By
calling the editor command By pressing a key in emacs incremental
search mode that doesn't have a special meaning in that mode  but
returns to normal emacs mode.  If an application program directly
calls  the  functions  or it can provide additional, program-spe‐
cific ways of appending to the input  queue.   This  manual  page
first appeared in and This manual page was written by