zshzle.1   [plain text]

.TH "ZSHZLE" "1" "December 20, 2010" "zsh 4\&.3\&.11"
.SH "NAME"
zshzle \- zsh command line editor
.\" Yodl file: Zsh/zle.yo
.SH "DESCRIPTION"
If the \fBZLE\fP option is set (which it is by default in interactive shells)
and the shell input is attached to the terminal, the user
is able to edit command lines\&.
.PP
There are two display modes\&.  The first, multiline mode, is the
default\&.  It only works if the \fBTERM\fP parameter is set to a valid
terminal type that can move the cursor up\&.  The second, single line
mode, is used if \fBTERM\fP is invalid or incapable of moving the
cursor up, or if the \fBSINGLE_LINE_ZLE\fP option is set\&.
This mode
is similar to \fBksh\fP, and uses no termcap sequences\&.  If \fBTERM\fP is
"emacs", the \fBZLE\fP option will be unset by default\&.
.PP
The parameters \fBBAUD\fP, \fBCOLUMNS\fP, and \fBLINES\fP are also used by the
line editor\&.
See \fIParameters Used By The Shell\fP in \fIzshparam\fP(1)\&.
.PP
The parameter \fBzle_highlight\fP is also used by the line editor;
see \fICharacter Highlighting\fP below\&.  Highlighting
of special characters and the region between the cursor and the
mark (as set with \fBset\-mark\-command\fP in Emacs mode) is enabled
conservatives will wish to know that all highlighting may be disabled by
the following setting:
.PP
.RS
.nf
\fBzle_highlight=(none)\fP
.fi
.RE
.PP
.PP
.SH "KEYMAPS"
A keymap in ZLE contains a set of bindings between key sequences
and ZLE commands\&.  The empty key sequence cannot be bound\&.
.PP
There can be any number of keymaps at any time, and each keymap has one
or more names\&.  If all of a keymap\&'s names are deleted, it disappears\&.
\fBbindkey\fP can be used to manipulate keymap names\&.
.PP
Initially, there are six keymaps:
.PP
.PD 0
.TP
\fBemacs\fP
EMACS emulation
.TP
\fBviins\fP
vi emulation \- insert mode
.TP
\fBvicmd\fP
vi emulation \- command mode
.TP
\fBisearch\fP
incremental search mode
.TP
\fBcommand\fP
.TP
\fB\&.safe\fP
fallback keymap
.PD
.PP
The \fB\&.safe\fP\&' keymap is special\&.  It can never be altered, and the name
can never be removed\&.  However, it can be linked to other names, which can
be removed\&.  In the future other special keymaps may be added; users should
avoid using names beginning with \fB\&.\fP\&' for their own keymaps\&.
.PP
In addition to these names, either \fBemacs\fP\&' or \fBviins\fP' is
also linked to the name \fBmain\fP\&'\&.  If one of the \fBVISUAL\fP or
\fBEDITOR\fP environment variables contain the string \fBvi\fP\&' when the shell
starts up then it will be \fBviins\fP\&', otherwise it will be \fBemacs\fP'\&.
\fBbindkey\fP\&'s \fB\-e\fP and \fB\-v\fP
options provide a convenient way to override this default choice\&.
.PP
When the editor starts up, it will select the \fBmain\fP\&' keymap\&.
If that keymap doesn\&'t exist, it will use \fB\&.safe\fP' instead\&.
.PP
In the \fB\&.safe\fP\&' keymap, each single key is bound to \fBself\-insert\fP,
except for ^J (line feed) and ^M (return) which are bound to \fBaccept\-line\fP\&.
This is deliberately not pleasant to use; if you are using it, it
means you deleted the main keymap, and you should put it back\&.
When ZLE is reading a command from the terminal, it may read a sequence
that is bound to some command and is also a prefix of a longer bound string\&.
In this case ZLE will wait a certain time to see if more characters
are typed, and if not (or they don\&'t match any longer string) it will
execute the binding\&.  This timeout is defined by the \fBKEYTIMEOUT\fP parameter;
its default is 0\&.4 sec\&.  There is no timeout if the prefix string is not
itself bound to a command\&.
.PP
The key timeout is also applied when ZLE is reading the bytes from a
multibyte character string when it is in the appropriate mode\&.  (This
requires that the shell was compiled with multibyte mode enabled; typically
also the locale has characters with the UTF\-8 encoding, although any
multibyte encoding known to the operating system is supported\&.)  If the
second or a subsequent byte is not read within the timeout period, the
shell acts as if \fB?\fP were typed and resets the input state\&.
.PP
As well as ZLE commands, key sequences can be bound to other strings, by using
\fBbindkey \-s\fP\&'\&.
When such a sequence is read, the replacement string is pushed back as input,
and the command reading process starts again using these fake keystrokes\&.
This input can itself invoke further replacement strings, but in order to
detect loops the process will be stopped if there are twenty such replacements
without a real command being read\&.
.PP
A key sequence typed by the user can be turned into a command name for use
in user\-defined widgets with the \fBread\-command\fP widget, described
below\&.
.PP
.SH "ZLE BUILTINS"
The ZLE module contains three related builtin commands\&. The \fBbindkey\fP
command manipulates keymaps and key bindings; the \fBvared\fP command invokes
ZLE on the value of a shell parameter; and the \fBzle\fP command manipulates
editing widgets and allows command line access to ZLE commands from within
shell functions\&.
.PP
.PD 0
.TP
.PD 0
\fBbindkey\fP [ \fIoptions\fP ] \fB\-l\fP [ \fB\-L\fP ] [ \fIkeymap\fP \&.\&.\&. ]
.TP
.PD 0
\fBbindkey\fP [ \fIoptions\fP ] \fB\-d\fP
.TP
.PD 0
\fBbindkey\fP [ \fIoptions\fP ] \fB\-D\fP \fIkeymap\fP \&.\&.\&.
.TP
.PD 0
\fBbindkey\fP [ \fIoptions\fP ] \fB\-A\fP \fIold\-keymap new\-keymap\fP
.TP
.PD 0
\fBbindkey\fP [ \fIoptions\fP ] \fB\-N\fP \fInew\-keymap\fP [ \fIold\-keymap\fP ]
.TP
.PD 0
\fBbindkey\fP [ \fIoptions\fP ] \fB\-m\fP
.TP
.PD 0
\fBbindkey\fP [ \fIoptions\fP ] \fB\-r\fP \fIin\-string\fP \&.\&.\&.
.TP
.PD 0
\fBbindkey\fP [ \fIoptions\fP ] \fB\-s\fP \fIin\-string out\-string\fP \&.\&.\&.
.TP
.PD 0
\fBbindkey\fP [ \fIoptions\fP ] \fIin\-string command\fP \&.\&.\&.
.TP
.PD
\fBbindkey\fP [ \fIoptions\fP ] [ \fIin\-string\fP ]
\fBbindkey\fP\&'s options can be divided into three categories: keymap
selection for the current command, operation selection, and others\&.  The
keymap selection options are:
.RS
.PP
.PD 0
.TP
.PD
\fB\-e\fP
Selects keymap \fBemacs\fP\&' for any operations by the current command,
and also links \fBemacs\fP\&' to \fBmain\fP' so that it is selected by
default the next time the editor starts\&.
.TP
\fB\-v\fP
Selects keymap \fBviins\fP\&' for any operations by the current command,
and also links \fBviins\fP\&' to \fBmain\fP' so that it is selected by default
the next time the editor starts\&.
.TP
\fB\-a\fP
Selects keymap \fBvicmd\fP\&' for any operations by the current command\&.
.TP
\fB\-M\fP \fIkeymap\fP
The \fIkeymap\fP specifies a keymap name that is selected for any
operations by the current command\&.
.PP
If a keymap selection is required and none of the options above are used, the
\fBmain\fP\&' keymap is used\&.  Some operations do not permit a keymap to be
selected, namely:
.PP
.PD 0
.TP
.PD
\fB\-l\fP
List all existing keymap names; if any arguments are given, list just
those keymaps\&.
.RS
.PP
If the \fB\-L\fP option is also used, list in the form of \fBbindkey\fP
commands to create or link the keymaps\&.  \fBbindkey \-lL
main\fP\&' shows which keymap is linked to \fBmain\fP', if any, and hence if
the standard emacs or vi emulation is in effect\&.  This option does
not show the \fB\&.safe\fP keymap because it cannot be created in that
fashion; however, neither is \fBbindkey \-lL \&.safe\fP\&' reported as an
error, it simply outputs nothing\&.
.RE
.TP
\fB\-d\fP
Delete all existing keymaps and reset to the default state\&.
.TP
\fB\-D\fP \fIkeymap\fP \&.\&.\&.
Delete the named \fIkeymap\fPs\&.
.TP
\fB\-A\fP \fIold\-keymap new\-keymap\fP
Make the \fInew\-keymap\fP name an alias for \fIold\-keymap\fP, so that
both names refer to the same keymap\&.  The names have equal standing;
if either is deleted, the other remains\&.  If there is already a keymap
with the \fInew\-keymap\fP name, it is deleted\&.
.TP
\fB\-N\fP \fInew\-keymap\fP [ \fIold\-keymap\fP ]
Create a new keymap, named \fInew\-keymap\fP\&.  If a keymap already has that
name, it is deleted\&.  If an \fIold\-keymap\fP name is given, the new keymap
is initialized to be a duplicate of it, otherwise the new keymap will
be empty\&.
.PP
To use a newly created keymap, it should be linked to \fBmain\fP\&.  Hence
the sequence of commands to create and use a new keymap \fBmymap\fP\&'
initialized from the \fBemacs\fP keymap (which remains unchanged) is:
.PP
.RS
.nf
\fBbindkey \-N mymap emacs
bindkey \-A mymap main\fP
.fi
.RE
.PP
Note that while \fBbindkey \-A\fP \fInewmap\fP \fBmain\fP\&' will work when
\fInewmap\fP is \fBemacs\fP or \fBviins\fP, it will not work for \fBvicmd\fP, as
switching from vi insert to command mode becomes impossible\&.
.PP
The following operations act on the \fBmain\fP\&' keymap if no keymap
selection option was given:
.PP
.PD 0
.TP
.PD
\fB\-m\fP
Add the built\-in set of meta\-key bindings to the selected keymap\&.
Only keys that are unbound or bound to \fBself\-insert\fP are affected\&.
.TP
\fB\-r\fP \fIin\-string\fP \&.\&.\&.
Unbind the specified \fIin\-string\fPs in the selected keymap\&.
This is exactly equivalent to binding the strings to \fBundefined\-key\fP\&.
.RS
.PP
When \fB\-R\fP is also used, interpret the \fIin\-string\fPs as ranges\&.
.PP
When \fB\-p\fP is also used, the \fIin\-string\fPs specify prefixes\&.  Any
binding that has the given \fIin\-string\fP as a prefix, not including the
binding for the \fIin\-string\fP itself, if any, will be removed\&.  For
example,
.PP
.RS
.nf
\fBbindkey \-rpM viins \&'^['\fP
.fi
.RE
.PP
will remove all bindings in the vi\-insert keymap beginning with an escape
character (probably cursor keys), but leave the binding for the escape
character itself (probably \fBvi\-cmd\-mode\fP)\&.  This is incompatible with the
option \fB\-R\fP\&.
.RE
.TP
\fB\-s\fP \fIin\-string out\-string\fP \&.\&.\&.
Bind each \fIin\-string\fP to each \fIout\-string\fP\&.
When \fIin\-string\fP is typed, \fIout\-string\fP will be
pushed back and treated as input to the line editor\&.
When \fB\-R\fP is also used, interpret the \fIin\-string\fPs as ranges\&.
.TP
\fIin\-string command\fP \&.\&.\&.
Bind each \fIin\-string\fP to each \fIcommand\fP\&.
When \fB\-R\fP is used, interpret the \fIin\-string\fPs as ranges\&.
.TP
[ \fIin\-string\fP ]
List key bindings\&.  If an \fIin\-string\fP is specified, the binding of
that string in the selected keymap is displayed\&.  Otherwise, all key
bindings in the selected keymap are displayed\&.  (As a special case,
if the \fB\-e\fP or \fB\-v\fP option is used alone, the keymap is \fInot\fP
displayed \- the implicit linking of keymaps is the only thing that
happens\&.)
.RS
.PP
When the option \fB\-p\fP is used, the \fIin\-string\fP must be present\&.
The listing shows all bindings which have the given key sequence as a
prefix, not including any bindings for the key sequence itself\&.
.PP
When the \fB\-L\fP option is used, the list is in the form of \fBbindkey\fP
commands to create the key bindings\&.
.RE
.RE
.PP
When the \fB\-R\fP option is used as noted above, a valid range consists of
two characters, with an optional \fB\-\fP\&' between them\&.  All characters
between the two specified, inclusive, are bound as specified\&.
.PP
For either \fIin\-string\fP or \fIout\-string\fP, the following
escape sequences are recognised:
.PP
.PD 0
.TP
\fB\ea\fP
bell character
.TP
\fB\eb\fP
backspace
.TP
\fB\ee\fP, \fB\eE\fP
escape
.TP
\fB\ef\fP
form feed
.TP
\fB\en\fP
linefeed (newline)
.TP
\fB\er\fP
carriage return
.TP
\fB\et\fP
horizontal tab
.TP
\fB\ev\fP
vertical tab
.TP
\fB\e\fP\fINNN\fP
character code in octal
.TP
\fB\ex\fP\fINN\fP
.TP
\fB\eM\fP[\fB\-\fP]\fIX\fP
character with meta bit set
.TP
\fB\eC\fP[\fB\-\fP]\fIX\fP
control character
.TP
\fB^\fP\fIX\fP
control character
.PD
.PP
In all other cases, \fB\e\fP\&' escapes the following character\&.  Delete is
written as \fB^?\fP\&'\&.  Note that \fB\eM^?\fP' and \fB^\eM?\fP' are not the same,
and that (unlike emacs), the bindings \fB\eM\-\fP\fIX\fP\&' and \fB\ee\fP\fIX\fP'
are entirely distinct, although they are initialized to the same bindings
by \fBbindkey \-m\fP\&'\&.
.RE
.TP
.PD 0
\fBvared\fP [ \fB\-Aache\fP ] [ \fB\-p\fP \fIprompt\fP ] [ \fB\-r\fP \fIrprompt\fP ]
.TP
.PD 0
[ \fB\-M\fP \fImain\-keymap\fP ] [ \fB\-m\fP \fIvicmd\-keymap\fP ]
.TP
.PD
[ \fB\-t\fP \fItty\fP ] \fIname\fP
The value of the parameter \fIname\fP is loaded into the edit
buffer, and the line editor is invoked\&.  When the editor exits,
\fIname\fP is set to the string value returned by the editor\&.
When the \fB\-c\fP flag is given, the parameter is created if it doesn\&'t
already exist\&.  The \fB\-a\fP flag may be given with \fB\-c\fP to create
an array parameter, or the \fB\-A\fP flag to create an associative array\&.
If the type of an existing parameter does not match the type to be
created, the parameter is unset and recreated\&.
.RS
.PP
If an array or array slice is being edited, separator characters as defined
in \fB$IFS\fP will be shown quoted with a backslash, as will backslashes themselves\&. Conversely, when the edited text is split into an array, a backslash quotes an immediately following separator character or backslash; no other special handling of backslashes, or any handling of quotes, is performed\&. .PP Individual elements of existing array or associative array parameters may be edited by using subscript syntax on \fIname\fP\&. New elements are created automatically, even without \fB\-c\fP\&. .PP If the \fB\-p\fP flag is given, the following string will be taken as the prompt to display at the left\&. If the \fB\-r\fP flag is given, the following string gives the prompt to display at the right\&. If the \fB\-h\fP flag is specified, the history can be accessed from ZLE\&. If the \fB\-e\fP flag is given, typing \fB^D\fP (Control\-D) on an empty line causes \fBvared\fP to exit immediately with a non\-zero return value\&. .PP The \fB\-M\fP option gives a keymap to link to the \fBmain\fP keymap during editing, and the \fB\-m\fP option gives a keymap to link to the \fBvicmd\fP keymap during editing\&. For vi\-style editing, this allows a pair of keymaps to override \fBviins\fP and \fBvicmd\fP\&. For emacs\-style editing, only \fB\-M\fP is normally needed but the \fB\-m\fP option may still be used\&. On exit, the previous keymaps will be restored\&. .PP If \fB\-t\fP \fItty\fP\&' is given, \fItty\fP is the name of a terminal device to be used instead of the default \fB/dev/tty\fP\&. If \fItty\fP does not refer to a terminal an error is reported\&. .RE .TP .PD 0 \fBzle\fP .TP .PD 0 \fBzle\fP \fB\-l\fP [ \fB\-L\fP | \fB\-a\fP ] [ \fIstring\fP \&.\&.\&. ] .TP .PD 0 \fBzle\fP \fB\-D\fP \fIwidget\fP \&.\&.\&. .TP .PD 0 \fBzle\fP \fB\-A\fP \fIold\-widget\fP \fInew\-widget\fP .TP .PD 0 \fBzle\fP \fB\-N\fP \fIwidget\fP [ \fIfunction\fP ] .TP .PD 0 \fBzle\fP \fB\-C\fP \fIwidget\fP \fIcompletion\-widget\fP \fIfunction\fP .TP .PD 0 \fBzle\fP \fB\-R\fP [ \fB\-c\fP ] [ \fIdisplay\-string\fP ] [ \fIstring\fP \&.\&.\&. ] .TP .PD 0 \fBzle\fP \fB\-M\fP \fIstring\fP .TP .PD 0 \fBzle\fP \fB\-U\fP \fIstring\fP .TP .PD 0 \fBzle\fP \fB\-K\fP \fIkeymap\fP .TP .PD 0 \fBzle\fP \fB\-F\fP [ \fB\-L\fP ] [ \fIfd\fP [ \fIhandler\fP ] ] .TP .PD 0 \fBzle\fP \fB\-I\fP .TP .PD \fBzle\fP \fIwidget\fP \fB[ \-n\fP \fInum\fP \fB]\fP \fB[ \-Nw ] [ \-K\fP \fIkeymap\fP \fB]\fP \fIargs\fP \&.\&.\&. The \fBzle\fP builtin performs a number of different actions concerning ZLE\&. .RS .PP With no options and no arguments, only the return status will be set\&. It is zero if ZLE is currently active and widgets could be invoked using this builtin command and non\-zero otherwise\&. Note that even if non\-zero status is returned, zle may still be active as part of the completion system; this does not allow direct calls to ZLE widgets\&. .PP Otherwise, which operation it performs depends on its options: .PP .PD 0 .TP .PD \fB\-l\fP [ \fB\-L\fP | \fB\-a\fP ] List all existing user\-defined widgets\&. If the \fB\-L\fP option is used, list in the form of \fBzle\fP commands to create the widgets\&. .RS .PP When combined with the \fB\-a\fP option, all widget names are listed, including the builtin ones\&. In this case the \fB\-L\fP option is ignored\&. .PP If at least one \fIstring\fP is given, nothing will be printed but the return status will be zero if all \fIstring\fPs are names of existing widgets (or of user\-defined widgets if the \fB\-a\fP flag is not given) and non\-zero if at least one \fIstring\fP is not a name of an defined widget\&. .RE .TP \fB\-D\fP \fIwidget\fP \&.\&.\&. Delete the named \fIwidget\fPs\&. .TP \fB\-A\fP \fIold\-widget\fP \fInew\-widget\fP Make the \fInew\-widget\fP name an alias for \fIold\-widget\fP, so that both names refer to the same widget\&. The names have equal standing; if either is deleted, the other remains\&. If there is already a widget with the \fInew\-widget\fP name, it is deleted\&. .TP \fB\-N\fP \fIwidget\fP [ \fIfunction\fP ] Create a user\-defined widget\&. If there is already a widget with the specified name, it is overwritten\&. When the new widget is invoked from within the editor, the specified shell \fIfunction\fP is called\&. If no function name is specified, it defaults to the same name as the widget\&. For further information, see the section \fIWidgets\fP in \fIzshzle\fP(1)\&. .TP \fB\-C\fP \fIwidget\fP \fIcompletion\-widget\fP \fIfunction\fP Create a user\-defined completion widget named \fIwidget\fP\&. The completion widget will behave like the built\-in completion\-widget whose name is given as \fIcompletion\-widget\fP\&. To generate the completions, the shell function \fIfunction\fP will be called\&. For further information, see \fIzshcompwid\fP(1)\&. .TP \fB\-R\fP [ \fB\-c\fP ] [ \fIdisplay\-string\fP ] [ \fIstring\fP \&.\&.\&. ] Redisplay the command line; this is to be called from within a user\-defined widget to allow changes to become visible\&. If a \fIdisplay\-string\fP is given and not empty, this is shown in the status line (immediately below the line being edited)\&. .RS .PP If the optional \fIstring\fPs are given they are listed below the prompt in the same way as completion lists are printed\&. If no \fIstring\fPs are given but the \fB\-c\fP option is used such a list is cleared\&. .PP Note that this option is only useful for widgets that do not exit immediately after using it because the strings displayed will be erased immediately after return from the widget\&. .PP This command can safely be called outside user defined widgets; if zle is active, the display will be refreshed, while if zle is not active, the command has no effect\&. In this case there will usually be no other arguments\&. .PP The status is zero if zle was active, else one\&. .RE .TP \fB\-M\fP \fIstring\fP As with the \fB\-R\fP option, the \fIstring\fP will be displayed below the command line; unlike the \fB\-R\fP option, the string will not be put into the status line but will instead be printed normally below the prompt\&. This means that the \fIstring\fP will still be displayed after the widget returns (until it is overwritten by subsequent commands)\&. .TP \fB\-U\fP \fIstring\fP This pushes the characters in the \fIstring\fP onto the input stack of ZLE\&. After the widget currently executed finishes ZLE will behave as if the characters in the \fIstring\fP were typed by the user\&. .RS .PP As ZLE uses a stack, if this option is used repeatedly the last string pushed onto the stack will be processed first\&. However, the characters in each \fIstring\fP will be processed in the order in which they appear in the string\&. .RE .TP \fB\-K\fP \fIkeymap\fP Selects the keymap named \fIkeymap\fP\&. An error message will be displayed if there is no such keymap\&. .RS .PP This keymap selection affects the interpretation of following keystrokes within this invocation of ZLE\&. Any following invocation (e\&.g\&., the next command line) will start as usual with the \fBmain\fP\&' keymap selected\&. .RE .TP \fB\-F\fP [ \fB\-L\fP ] [ \fIfd\fP [ \fIhandler\fP ] ] Only available if your system supports one of the poll\&' or select' system calls; most modern systems do\&. .RS .PP Installs \fIhandler\fP (the name of a shell function) to handle input from file descriptor \fIfd\fP\&. When zle is attempting to read data, it will examine both the terminal and the list of handled \fIfd\fP\&'s\&. If data becomes available on a handled \fIfd\fP, zle will call \fIhandler\fP with the fd which is ready for reading as the only argument\&. If the handler produces output to the terminal, it should call \fBzle \-I\fP\&' before doing so (see below)\&. The handler should not attempt to read from the terminal\&. Note that zle makes no attempt to check whether this fd is actually readable when installing the handler\&. The user must make their own arrangements for handling the file descriptor when zle is not active\&. .PP Any number of handlers for any number of readable file descriptors may be installed\&. Installing a handler for an \fIfd\fP which is already handled causes the existing handler to be replaced\&. .PP If no \fIhandler\fP is given, but an \fIfd\fP is present, any handler for that \fIfd\fP is removed\&. If there is none, an error message is printed and status 1 is returned\&. .PP If no arguments are given, or the \fB\-L\fP option is supplied, a list of handlers is printed in a form which can be stored for later execution\&. .PP An \fIfd\fP (but not a \fIhandler\fP) may optionally be given with the \fB\-L\fP option; in this case, the function will list the handler if any, else silently return status 1\&. .PP Note that this feature should be used with care\&. Activity on one of the \fIfd\fP\&'s which is not properly handled can cause the terminal to become unusable\&. .PP Here is a simple example of using this feature\&. A connection to a remote TCP port is created using the ztcp command; see the description of the \fBzsh/net/tcp\fP module in \fIzshmodules\fP(1)\&. Then a handler is installed which simply prints out any data which arrives on this connection\&. Note that select\&' will indicate that the file descriptor needs handling if the remote side has closed the connection; we handle that by testing for a failed read\&. .RS .nf \fBif ztcp pwspc 2811; then tcpfd=$REPLY
handler() {
zle \-I
local line
if ! read \-r line <&$1; then # select marks this fd if we reach EOF, # so handle this specially\&. print "[Read on fd$1 failed, removing\&.]" >&2
zle \-F $1 return 1 fi print \-r \-$line
}
zle \-F $tcpfd handler fi\fP .fi .RE .RE .TP \fB\-I\fP Unusually, this option is most useful outside ordinary widget functions, though it may be used within if normal output to the terminal is required\&. It invalidates the current zle display in preparation for output; typically this will be from a trap function\&. It has no effect if zle is not active\&. When a trap exits, the shell checks to see if the display needs restoring, hence the following will print output in such a way as not to disturb the line being edited: .RS .PP .RS .nf \fBTRAPUSR1() { # Invalidate zle display [[ \-o zle ]] && zle \-I # Show output print Hello }\fP .fi .RE .PP In general, the trap function may need to test whether zle is active before using this method (as shown in the example), since the \fBzsh/zle\fP module may not even be loaded; if it is not, the command can be skipped\&. .PP It is possible to call \fBzle \-I\fP\&' several times before control is returned to the editor; the display will only be invalidated the first time to minimise disruption\&. .PP Note that there are normally better ways of manipulating the display from within zle widgets; see, for example, \fBzle \-R\fP\&' above\&. .PP The returned status is zero if zle was invalidated, even though this may have been by a previous call to \fBzle \-I\fP\&' or by a system notification\&. To test if a zle widget may be called at this point, execute \fBzle\fP with no arguments and examine the return status\&. .RE .TP \fIwidget\fP \fB[ \-n\fP \fInum\fP \fB]\fP \fB[ \-Nw ] [ \-K\fP \fIkeymap\fP \fB]\fP \fIargs\fP \&.\&.\&. Invoke the specified widget\&. This can only be done when ZLE is active; normally this will be within a user\-defined widget\&. .RS .PP With the options \fB\-n\fP and \fB\-N\fP, the current numerical argument will be saved and then restored after the call to \fBwidget\fP; \fB\-n\fP \fInum\fP\&' sets the numerical argument temporarily to \fInum\fP, while \fB\-N\fP\&' sets it to the default, i\&.e\&. as if there were none\&. .PP With the option \fB\-K\fP, \fIkeymap\fP will be used as the current keymap during the execution of the widget\&. The previous keymap will be restored when the widget exits\&. .PP Normally, calling a widget in this way does not set the special parameter \fBWIDGET\fP and related parameters, so that the environment appears as if the top\-level widget called by the user were still active\&. With the option \fB\-w\fP, \fBWIDGET\fP and related parameters are set to reflect the widget being executed by the \fBzle\fP call\&. .PP Any further arguments will be passed to the widget; note that as standard argument handling is performed, any general argument list should be preceded by \fB\-\fP\fB\-\fP\&. If it is a shell function, these are passed down as positional parameters; for builtin widgets it is up to the widget in question what it does with them\&. Currently arguments are only handled by the incremental\-search commands, the \fBhistory\-search\-forward\fP and \fB\-backward\fP and the corresponding functions prefixed by \fBvi\-\fP, and by \fBuniversal\-argument\fP\&. No error is flagged if the command does not use the arguments, or only uses some of them\&. .PP The return status reflects the success or failure of the operation carried out by the widget, or if it is a user\-defined widget the return status of the shell function\&. .PP A non\-zero return status causes the shell to beep when the widget exits, unless the \fBBEEP\fP options was unset or the widget was called via the \fBzle\fP command\&. Thus if a user defined widget requires an immediate beep, it should call the \fBbeep\fP widget directly\&. .RE .RE .RE .RE .PP .SH "WIDGETS" All actions in the editor are performed by widgets\&'\&. A widget's job is simply to perform some small action\&. The ZLE commands that key sequences in keymaps are bound to are in fact widgets\&. Widgets can be user\-defined or built in\&. .PP The standard widgets built into ZLE are listed in Standard Widgets below\&. Other built\-in widgets can be defined by other modules (see \fIzshmodules\fP(1))\&. Each built\-in widget has two names: its normal canonical name, and the same name preceded by a \fB\&.\fP\&'\&. The \fB\&.\fP' name is special: it can't be rebound to a different widget\&. This makes the widget available even when its usual name has been redefined\&. .PP User\-defined widgets are defined using \fBzle \-N\fP\&', and implemented as shell functions\&. When the widget is executed, the corresponding shell function is executed, and can perform editing (or other) actions\&. It is recommended that user\-defined widgets should not have names starting with \fB\&.\fP\&'\&. .SH "USER\-DEFINED WIDGETS" User\-defined widgets, being implemented as shell functions, can execute any normal shell command\&. They can also run other widgets (whether built\-in or user\-defined) using the \fBzle\fP builtin command\&. The standard input of the function is closed to prevent external commands from unintentionally blocking ZLE by reading from the terminal, but \fBread \-k\fP or \fBread \-q\fP can be used to read characters\&. Finally, they can examine and edit the ZLE buffer being edited by reading and setting the special parameters described below\&. .PP These special parameters are always available in widget functions, but are not in any way special outside ZLE\&. If they have some normal value outside ZLE, that value is temporarily inaccessible, but will return when the widget function exits\&. These special parameters in fact have local scope, like parameters created in a function using \fBlocal\fP\&. .PP Inside completion widgets and traps called while ZLE is active, these parameters are available read\-only\&. .PP .PD 0 .TP .PD \fBBUFFER\fP (scalar) The entire contents of the edit buffer\&. If it is written to, the cursor remains at the same offset, unless that would put it outside the buffer\&. .TP \fBBUFFERLINES\fP (integer) The number of screen lines needed for the edit buffer currently displayed on screen (i\&.e\&. without any changes to the preceding parameters done after the last redisplay); read\-only\&. .TP \fBCONTEXT\fP (scalar) The context in which zle was called to read a line; read\-only\&. One of the values: .PD 0 .TP .PD start The start of a command line (at prompt \fBPS1\fP)\&. .TP cont A continuation to a command line (at prompt \fBPS2\fP)\&. .TP select In a \fBselect\fP loop\&. .TP vared Editing a variable in \fBvared\fP\&. .RE .TP \fBCURSOR\fP (integer) The offset of the cursor, within the edit buffer\&. This is in the range 0 to \fB$#BUFFER\fP, and is by definition equal to \fB$#LBUFFER\fP\&. Attempts to move the cursor outside the buffer will result in the cursor being moved to the appropriate end of the buffer\&. .TP \fBCUTBUFFER\fP (scalar) The last item cut using one of the \fBkill\-\fP\&' commands; the string which the next yank would insert in the line\&. Later entries in the kill ring are in the array \fBkillring\fP\&. Note that the command \fBzle copy\-region\-as\-kill\fP \fIstring\fP\&' can be used to set the text of the cut buffer from a shell function and cycle the kill ring in the same way as interactively killing text\&. .TP \fBHISTNO\fP (integer) The current history number\&. Setting this has the same effect as moving up or down in the history to the corresponding history line\&. An attempt to set it is ignored if the line is not stored in the history\&. Note this is not the same as the parameter \fBHISTCMD\fP, which always gives the number of the history line being added to the main shell\&'s history\&. \fBHISTNO\fP refers to the line being retrieved within zle\&. .TP \fBKEYMAP\fP (scalar) The name of the currently selected keymap; read\-only\&. .TP \fBKEYS\fP (scalar) The keys typed to invoke this widget, as a literal string; read\-only\&. .TP \fBkillring\fP (array) The array of previously killed items, with the most recently killed first\&. This gives the items that would be retrieved by a \fByank\-pop\fP in the same order\&. Note, however, that the most recently killed item is in \fB$CUTBUFFER\fP; \fB$killring\fP shows the array of previous entries\&. .RS .PP The default size for the kill ring is eight, however the length may be changed by normal array operations\&. Any empty string in the kill ring is ignored by the \fByank\-pop\fP command, hence the size of the array effectively sets the maximum length of the kill ring, while the number of non\-zero strings gives the current length, both as seen by the user at the command line\&. .RE .TP \fBLASTABORTEDSEARCH\fP (scalar) The last search string used by an interactive search that was aborted by the user (status 3 returned by the search widget)\&. .TP \fBLASTSEARCH\fP (scalar) The last search string used by an interactive search; read\-only\&. This is set even if the search failed (status 0, 1 or 2 returned by the search widget), but not if it was aborted by the user\&. .TP \fBLASTWIDGET\fP (scalar) The name of the last widget that was executed; read\-only\&. .TP \fBLBUFFER\fP (scalar) The part of the buffer that lies to the left of the cursor position\&. If it is assigned to, only that part of the buffer is replaced, and the cursor remains between the new \fB$LBUFFER\fP and the old \fB$RBUFFER\fP\&. .TP \fBMARK\fP (integer) Like \fBCURSOR\fP, but for the mark\&. .TP \fBNUMERIC\fP (integer) The numeric argument\&. If no numeric argument was given, this parameter is unset\&. When this is set inside a widget function, builtin widgets called with the \fBzle\fP builtin command will use the value assigned\&. If it is unset inside a widget function, builtin widgets called behave as if no numeric argument was given\&. .TP \fBPENDING\fP (integer) The number of bytes pending for input, i\&.e\&. the number of bytes which have already been typed and can immediately be read\&. On systems where the shell is not able to get this information, this parameter will always have a value of zero\&. Read\-only\&. .TP \fBPREBUFFER\fP (scalar) In a multi\-line input at the secondary prompt, this read\-only parameter contains the contents of the lines before the one the cursor is currently in\&. .TP \fBPREDISPLAY\fP (scalar) Text to be displayed before the start of the editable text buffer\&. This does not have to be a complete line; to display a complete line, a newline must be appended explicitly\&. The text is reset on each new invocation (but not recursive invocation) of zle\&. .TP \fBPOSTDISPLAY\fP (scalar) Text to be displayed after the end of the editable text buffer\&. This does not have to be a complete line; to display a complete line, a newline must be prepended explicitly\&. The text is reset on each new invocation (but not recursive invocation) of zle\&. .TP \fBRBUFFER\fP (scalar) The part of the buffer that lies to the right of the cursor position\&. If it is assigned to, only that part of the buffer is replaced, and the cursor remains between the old \fB$LBUFFER\fP and the new \fB$RBUFFER\fP\&. .TP \fBREGION_ACTIVE\fP (integer) Indicates if the region is currently active\&. It can be assigned 0 or 1 to deactivate and activate the region respectively; see \fICharacter Highlighting\fP below\&. .TP \fBregion_highlight\fP (array) Each element of this array may be set to a string that describes highlighting for an arbitrary region of the command line that will take effect the next time the command line is redisplayed\&. Highlighting of the non\-editable parts of the command line in \fBPREDISPLAY\fP and \fBPOSTDISPLAY\fP are possible, but note that the \fBP\fP flag is needed for character indexing to include \fBPREDISPLAY\fP\&. .RS .PP Each string consists of the following parts: .PP .PD 0 .TP Optionally, a \fBP\fP\&' to signify that the start and end offset that follow include any string set by the \fBPREDISPLAY\fP special parameter; this is needed if the predisplay string itself is to be highlighted\&. Whitespace may follow the \fBP\fP\&'\&. .TP A start offset in the same units as \fBCURSOR\fP, terminated by whitespace\&. .TP An end offset in the same units as \fBCURSOR\fP, terminated by whitespace\&. .TP A highlight specification in the same format as used for contexts in the parameter \fBzle_highlight\fP, see Character Highlighting below; for example, \fBstandout\fP or \fBfg=red,bold\fP\&. .PD .PP For example, .PP .RS .nf \fBregion_highlight=("P0 20 bold")\fP .fi .RE .PP specifies that the first twenty characters of the text including any predisplay string should be highlighted in bold\&. .PP Note that the effect of \fBregion_highlight\fP is not saved and disappears as soon as the line is accepted\&. The line editor makes no attempt to keep the highlighting effect synchronised with the line as it is edited; hence region highlighting is best limited to static effects within user widgets\&. .RE .TP \fBWIDGET\fP (scalar) The name of the widget currently being executed; read\-only\&. .TP \fBWIDGETFUNC\fP (scalar) The name of the shell function that implements a widget defined with either \fBzle \-N\fP or \fBzle \-C\fP\&. In the former case, this is the second argument to the \fBzle \-N\fP command that defined the widget, or the first argument if there was no second argument\&. In the latter case this is the the third argument to the \fBzle \-C\fP command that defined the widget\&. Read\-only\&. .TP \fBWIDGETSTYLE\fP (scalar) Describes the implementation behind the completion widget currently being executed; the second argument that followed \fBzle \-C\fP when the widget was defined\&. This is the name of a builtin completion widget\&. For widgets defined with \fBzle \-N\fP this is set to the empty string\&. Read\-only\&. .TP \fBZLE_STATE\fP (scalar) Contains a set of space\-separated words that describe the current \fBzle\fP state\&. .RS .PP Currently, the only state shown is the insert mode as set by the \fBoverwrite\-mode\fP or \fBvi\-replace\fP widgets\&. The string contains \fBinsert\fP\&' if characters to be inserted on the command line move existing characters to the right, \fBoverwrite\fP\&' if characters to be inserted overwrite existing characters\&. .RE .RE .PP .SS "Special Widgets" .PP There are a few user\-defined widgets which are special to the shell\&. If they do not exist, no special action is taken\&. The environment provided is identical to that for any other editing widget\&. .PP .PD 0 .TP .PD \fBzle\-isearch\-exit\fP Executed at the end of incremental search at the point where the isearch prompt is removed from the display\&. See \fBzle\-isearch\-update\fP for an example\&. .TP \fBzle\-isearch\-update\fP Executed within incremental search when the display is about to be redrawn\&. Additional output below the incremental search prompt can be generated by using \fBzle \-M\fP\&' within the widget\&. For example, .RS .PP .RS .nf \fBzle\-isearch\-update() { zle \-M "Line$HISTNO"; }
zle \-N zle\-isearch\-update\fP
.fi
.RE
.PP
Note the line output by \fBzle \-M\fP\&' is not deleted on exit from
incremental search\&.  This can be done from a \fBzle\-isearch\-exit\fP
widget:
.PP
.RS
.nf
\fBzle\-isearch\-exit() { zle \-M ""; }
zle \-N zle\-isearch\-exit\fP
.fi
.RE
.RE
.TP
\fBzle\-line\-init\fP
Executed every time the line editor is started to read a new line
of input\&.  The following example puts the line editor into vi command
mode when it starts up\&.
.RS
.PP
.RS
.nf
\fBzle\-line\-init() { zle \-K vicmd; }
zle \-N zle\-line\-init\fP
.fi
.RE
.PP
(The command inside the function sets the keymap directly; it is
equivalent to \fBzle vi\-cmd\-mode\fP\&.)
.RE
.TP
\fBzle\-line\-finish\fP
This is similar to \fBzle\-line\-init\fP but is executed every time the
line editor has finished reading a line of input\&.
.TP
\fBzle\-keymap\-select\fP
Executed every time the keymap changes, i\&.e\&. the special parameter
\fBKEYMAP\fP is set to a different value, while the line editor is active\&.
Initialising the keymap when the line editor starts does not cause the
widget to be called\&.
.RS
.PP
The value \fB$KEYMAP\fP within the function reflects the new keymap\&. The old keymap is passed as the sole argument\&. .PP This can be used for detecting switches between the vi command (\fBvicmd\fP) and insert (usually \fBmain\fP) keymaps\&. .RE .RE .PP .SH "STANDARD WIDGETS" The following is a list of all the standard widgets, and their default bindings in emacs mode, vi command mode and vi insert mode (the \fBemacs\fP\&', \fBvicmd\fP' and \fBviins\fP' keymaps, respectively)\&. .PP Note that cursor keys are bound to movement keys in all three keymaps; the shell assumes that the cursor keys send the key sequences reported by the terminal\-handling library (termcap or terminfo)\&. The key sequences shown in the list are those based on the VT100, common on many modern terminals, but in fact these are not necessarily bound\&. In the case of the \fBviins\fP keymap, the initial escape character of the sequences serves also to return to the \fBvicmd\fP keymap: whether this happens is determined by the \fBKEYTIMEOUT\fP parameter, see \fIzshparam\fP(1)\&. .SS "Movement" .PD 0 .TP .PD \fBvi\-backward\-blank\-word\fP (unbound) (B) (unbound) Move backward one word, where a word is defined as a series of non\-blank characters\&. .TP \fBbackward\-char\fP (^B ESC\-[D) (unbound) (unbound) Move backward one character\&. .TP \fBvi\-backward\-char\fP (unbound) (^H h ^?) (ESC\-[D) Move backward one character, without changing lines\&. .TP \fBbackward\-word\fP (ESC\-B ESC\-b) (unbound) (unbound) Move to the beginning of the previous word\&. .TP \fBemacs\-backward\-word\fP Move to the beginning of the previous word\&. .TP \fBvi\-backward\-word\fP (unbound) (b) (unbound) Move to the beginning of the previous word, vi\-style\&. .TP \fBbeginning\-of\-line\fP (^A) (unbound) (unbound) Move to the beginning of the line\&. If already at the beginning of the line, move to the beginning of the previous line, if any\&. .TP \fBvi\-beginning\-of\-line\fP Move to the beginning of the line, without changing lines\&. .TP \fBend\-of\-line\fP (^E) (unbound) (unbound) Move to the end of the line\&. If already at the end of the line, move to the end of the next line, if any\&. .TP \fBvi\-end\-of\-line\fP (unbound) ($) (unbound)
Move to the end of the line\&.
If an argument is given to this command, the cursor will be moved to
the end of the line (argument \- 1) lines down\&.
.TP
\fBvi\-forward\-blank\-word\fP (unbound) (W) (unbound)
Move forward one word, where a word is defined as a series of
non\-blank characters\&.
.TP
\fBvi\-forward\-blank\-word\-end\fP (unbound) (E) (unbound)
Move to the end of the current word, or, if at the end of the current word,
to the end of the next word,
where a word is defined as a series of non\-blank characters\&.
.TP
\fBforward\-char\fP (^F ESC\-[C) (unbound) (unbound)
Move forward one character\&.
.TP
\fBvi\-forward\-char\fP (unbound) (space l) (ESC\-[C)
Move forward one character\&.
.TP
\fBvi\-find\-next\-char\fP (^X^F) (f) (unbound)
Read a character from the keyboard, and move to
the next occurrence of it in the line\&.
.TP
\fBvi\-find\-next\-char\-skip\fP (unbound) (t) (unbound)
Read a character from the keyboard, and move to
the position just before the next occurrence of it in the line\&.
.TP
\fBvi\-find\-prev\-char\fP (unbound) (F) (unbound)
Read a character from the keyboard, and move to
the previous occurrence of it in the line\&.
.TP
\fBvi\-find\-prev\-char\-skip\fP (unbound) (T) (unbound)
Read a character from the keyboard, and move to
the position just after the previous occurrence of it in the line\&.
.TP
\fBvi\-first\-non\-blank\fP (unbound) (^) (unbound)
Move to the first non\-blank character in the line\&.
.TP
\fBvi\-forward\-word\fP (unbound) (w) (unbound)
Move forward one word, vi\-style\&.
.TP
\fBforward\-word\fP (ESC\-F ESC\-f) (unbound) (unbound)
Move to the beginning of the next word\&.
The editor\&'s idea of a word is specified with the \fBWORDCHARS\fP
parameter\&.
.TP
\fBemacs\-forward\-word\fP
Move to the end of the next word\&.
.TP
\fBvi\-forward\-word\-end\fP (unbound) (e) (unbound)
Move to the end of the next word\&.
.TP
\fBvi\-goto\-column\fP (ESC\-|) (|) (unbound)
Move to the column specified by the numeric argument\&.
.TP
\fBvi\-goto\-mark\fP (unbound) () (unbound)
Move to the specified mark\&.
.TP
\fBvi\-goto\-mark\-line\fP (unbound) (\&') (unbound)
Move to beginning of the line containing the specified mark\&.
.TP
\fBvi\-repeat\-find\fP (unbound) (;) (unbound)
Repeat the last \fBvi\-find\fP command\&.
.TP
\fBvi\-rev\-repeat\-find\fP (unbound) (,) (unbound)
Repeat the last \fBvi\-find\fP command in the opposite direction\&.
.SS "History Control"
.PD 0
.TP
.PD
\fBbeginning\-of\-buffer\-or\-history\fP (ESC\-<) (unbound) (unbound)
Move to the beginning of the buffer, or if already there,
move to the first event in the history list\&.
.TP
\fBbeginning\-of\-line\-hist\fP
Move to the beginning of the line\&.  If already at the
beginning of the buffer, move to the previous history line\&.
.TP
\fBbeginning\-of\-history\fP
Move to the first event in the history list\&.
.TP
\fBdown\-line\-or\-history\fP (^N ESC\-[B) (j) (ESC\-[B)
Move down a line in the buffer, or if already at the bottom line,
move to the next event in the history list\&.
.TP
\fBvi\-down\-line\-or\-history\fP (unbound) (+) (unbound)
Move down a line in the buffer, or if already at the bottom line,
move to the next event in the history list\&.
Then move to the first non\-blank character on the line\&.
.TP
\fBdown\-line\-or\-search\fP
Move down a line in the buffer, or if already at the bottom line,
search forward in the history for a line beginning with the first
word in the buffer\&.
.RS
.PP
If called from a function by the \fBzle\fP command with arguments, the first
argument is taken as the string for which to search, rather than the
first word in the buffer\&.
.RE
.TP
\fBdown\-history\fP (unbound) (^N) (unbound)
Move to the next event in the history list\&.
.TP
\fBhistory\-beginning\-search\-backward\fP
Search backward in the history for a line beginning with the current
line up to the cursor\&.
This leaves the cursor in its original position\&.
.TP
\fBend\-of\-buffer\-or\-history\fP (ESC\->) (unbound) (unbound)
Move to the end of the buffer, or if already there,
move to the last event in the history list\&.
.TP
\fBend\-of\-line\-hist\fP
Move to the end of the line\&.  If already at the end of
the buffer, move to the next history line\&.
.TP
\fBend\-of\-history\fP
Move to the last event in the history list\&.
.TP
\fBvi\-fetch\-history\fP (unbound) (G) (unbound)
Fetch the history line specified by the numeric argument\&.
This defaults to the current history line
(i\&.e\&. the one that isn\&'t history yet)\&.
.TP
\fBhistory\-incremental\-search\-backward\fP (^R ^Xr) (unbound) (unbound)
Search backward incrementally for a specified string\&.  The search is
case\-insensitive if the search string does not have uppercase letters and no
numeric argument was given\&.  The string may begin with \fB^\fP\&' to anchor the
search to the beginning of the line\&.  When called from a user\-defined
function returns the following statuses: 0, if the search succeeded;
1, if the search failed; 2, if the search term was a bad pattern;
3, if the search was aborted by the \fBsend\-break\fP command\&.
.RS
.PP
A restricted set of editing functions
is available in the mini\-buffer\&.  Keys are looked up in the special
\fBisearch\fP keymap, and if not found there in the main keymap (note
that by default the \fBisearch\fP keymap is empty)\&.
An interrupt signal, as defined by the stty
setting, will stop the search and go back to the original line\&.  An undefined
key will have the same effect\&.  Note that the following always
perform the same task within incremental searches and cannot be
replaced by user defined widgets, nor can the set of functions
be extended\&.  The supported functions are:
.PP
.PD 0
.TP
.PD 0
\fBaccept\-and\-hold\fP
.TP
.PD 0
\fBaccept\-and\-infer\-next\-history\fP
.TP
.PD 0
\fBaccept\-line\fP
.TP
.PD
\fBaccept\-line\-and\-down\-history\fP
Perform the usual function after exiting incremental search\&.
The command line displayed is executed\&.
.TP
.PD 0
\fBbackward\-delete\-char\fP
.TP
.PD
\fBvi\-backward\-delete\-char\fP
Back up one place in the search history\&.  If the search has been
repeated this does not immediately erase a character in the
minibuffer\&.
.TP
\fBaccept\-search\fP
Exit incremental search, retaining the command line but performing no
further action\&.  Note that this function is not bound by default
and has no effect outside incremental search\&.
.TP
.PD 0
\fBbackward\-delete\-word\fP
.TP
.PD 0
\fBbackward\-kill\-word\fP
.TP
.PD
\fBvi\-backward\-kill\-word\fP
Back up one character in the minibuffer; if multiple searches
have been performed since the character was inserted the search
history is rewound to the point just before the character was
entered\&.  Hence this has the effect of repeating
\fBbackward\-delete\-char\fP\&.
.TP
\fBclear\-screen\fP
Clear the screen, remaining in incremental search mode\&.
.TP
\fBhistory\-incremental\-search\-backward\fP
Find the next occurrence of the contents of the mini\-buffer\&.
.TP
\fBhistory\-incremental\-search\-forward\fP
Invert the sense of the search\&.
.TP
\fBmagic\-space\fP
Inserts a non\-magical space\&.
.TP
.PD 0
\fBquoted\-insert\fP
.TP
.PD
\fBvi\-quoted\-insert\fP
Quote the character to insert into the minibuffer\&.
.TP
\fBredisplay\fP
Redisplay the command line, remaining in incremental search mode\&.
.TP
\fBvi\-cmd\-mode\fP
Toggle between the \fBmain\fP\&' and \fBvicmd\fP' keymaps;
the \fBmain\fP\&' keymap (insert mode) will be selected initially\&.
.TP
.PD 0
\fBvi\-repeat\-search\fP
.TP
.PD
\fBvi\-rev\-repeat\-search\fP
Repeat the search\&.  The direction of the search is indicated in the
mini\-buffer\&.
.PP
Any character that is not bound to one of the above functions, or
\fBself\-insert\fP or \fBself\-insert\-unmeta\fP, will cause the mode to be
exited\&.  The character is then looked up and executed in the keymap in
effect at that point\&.
.PP
When called from a widget function by the \fBzle\fP command, the incremental
search commands can take a string argument\&.  This will be treated as a
string of keys, as for arguments to the \fBbindkey\fP command, and used as
initial input for the command\&.  Any characters in the string which are
unused by the incremental search will be silently ignored\&.  For example,
.PP
.RS
.nf
\fBzle history\-incremental\-search\-backward forceps\fP
.fi
.RE
.PP
will search backwards for \fBforceps\fP, leaving the minibuffer containing
the string \fBforceps\fP\&'\&.
.RE
.TP
\fBhistory\-incremental\-search\-forward\fP (^S ^Xs) (unbound) (unbound)
Search forward incrementally for a specified string\&.  The search is
case\-insensitive if the search string does not have uppercase letters and no
numeric argument was given\&.  The string may begin with \fB^\fP\&' to anchor the
search to the beginning of the line\&.  The functions available in the
mini\-buffer are the same as for \fBhistory\-incremental\-search\-backward\fP\&.
.TP
.PD 0
\fBhistory\-incremental\-pattern\-search\-backward\fP
.TP
.PD
\fBhistory\-incremental\-pattern\-search\-forward\fP
These widgets behave similarly to the corresponding widgets with
no \fB\-pattern\fP, but the search string typed by the user is treated
as a pattern, respecting the current settings of the various options
affecting pattern matching\&.  See
FILENAME GENERATION in \fIzshexpn\fP(1) for a description of patterns\&.
If no numeric argument was given lowercase letters in the search
string may match uppercase letters in the history\&.  The string may begin
with \fB^\fP\&' to anchor the search to the beginning of the line\&.
.RS
.PP
The prompt changes to indicate an invalid pattern; this may simply
indicate the pattern is not yet complete\&.
.PP
Note that only non\-overlapping matches are reported, so an expression
with wildcards may return fewer matches on a line than are visible
by inspection\&.
.RE
.TP
\fBhistory\-search\-backward\fP (ESC\-P ESC\-p) (unbound) (unbound)
Search backward in the history for a line beginning with the first
word in the buffer\&.
.RS
.PP
If called from a function by the \fBzle\fP command with arguments, the first
argument is taken as the string for which to search, rather than the
first word in the buffer\&.
.RE
.TP
\fBvi\-history\-search\-backward\fP (unbound) (/) (unbound)
Search backward in the history for a specified string\&.
The string may begin with \fB^\fP\&' to anchor the search to the
beginning of the line\&.
.RS
.PP
A restricted set of editing functions is available in
the mini\-buffer\&.  An interrupt signal, as defined by the stty setting,  will
stop the search\&.
The functions available in the mini\-buffer are:
\fBaccept\-line\fP,
\fBbackward\-delete\-char\fP,
\fBvi\-backward\-delete\-char\fP,
\fBbackward\-kill\-word\fP,
\fBvi\-backward\-kill\-word\fP,
\fBclear\-screen\fP,
\fBredisplay\fP,
\fBquoted\-insert\fP
and
\fBvi\-quoted\-insert\fP\&.
.PP
\fBvi\-cmd\-mode\fP is treated the same as accept\-line, and
\fBmagic\-space\fP is treated as a space\&.
Any other character that is not bound to self\-insert or
self\-insert\-unmeta will beep and be ignored\&. If the function is called from vi
command mode, the bindings of the current insert mode will be used\&.
.PP
If called from a function by the \fBzle\fP command with arguments, the first
argument is taken as the string for which to search, rather than the
first word in the buffer\&.
.RE
.TP
\fBhistory\-search\-forward\fP (ESC\-N ESC\-n) (unbound) (unbound)
Search forward in the history for a line beginning with the first
word in the buffer\&.
.RS
.PP
If called from a function by the \fBzle\fP command with arguments, the first
argument is taken as the string for which to search, rather than the
first word in the buffer\&.
.RE
.TP
\fBvi\-history\-search\-forward\fP (unbound) (?) (unbound)
Search forward in the history for a specified string\&.
The string may begin with \fB^\fP\&' to anchor the search to the
beginning of the line\&. The functions available in the mini\-buffer are the same
as for \fBvi\-history\-search\-backward\fP\&.  Argument handling is also the same
as for that command\&.
.TP
\fBinfer\-next\-history\fP (^X^N) (unbound) (unbound)
Search in the history list for a line matching the current one and
fetch the event following it\&.
.TP
\fBinsert\-last\-word\fP (ESC\-_ ESC\-\&.) (unbound) (unbound)
Insert the last word from the previous history event at the
cursor position\&.  If a positive numeric argument is given,
insert that word from the end of the previous history event\&.
If the argument is zero or negative insert that word from the
left (zero inserts the previous command word)\&.  Repeating this command
replaces the word just inserted with the last word from the
history event prior to the one just used; numeric arguments can be used in
the same way to pick a word from that event\&.
.RS
.PP
When called from a shell function invoked from a user\-defined widget, the
command can take one to three arguments\&.  The first argument specifies a
history offset which applies to successive calls to this widget: if it is \-1,
the default behaviour is used, while if it is 1, successive calls will move
forwards through the history\&.  The value 0 can be used to indicate that the
history line examined by the previous execution of the command will be
reexamined\&.  Note that negative numbers should be preceded by a
\fB\-\fP\fB\-\fP\&' argument to avoid confusing them with options\&.
.PP
If two arguments are given, the second specifies the word on the command
line in normal array index notation (as a more natural alternative to the
prefix argument)\&.  Hence 1 is the first word, and \-1 (the default) is the
last word\&.
.PP
If a third argument is given, its value is ignored, but it is used to
signify that the history offset is relative to the current history line,
rather than the one remembered after the previous invocations of
\fBinsert\-last\-word\fP\&.
.PP
For example, the default behaviour of the command corresponds to
.PP
.RS
.nf
\fBzle insert\-last\-word \-\- \-1 \-1\fP
.fi
.RE
.PP
while the command
.PP
.RS
.nf
\fBzle insert\-last\-word \-\- \-1 1 \-\fP
.fi
.RE
.PP
always copies the first word of the line in the history immediately before
the line being edited\&.  This has the side effect that later invocations of
the widget will be relative to that line\&.
.RE
.TP
\fBvi\-repeat\-search\fP (unbound) (n) (unbound)
Repeat the last vi history search\&.
.TP
\fBvi\-rev\-repeat\-search\fP (unbound) (N) (unbound)
Repeat the last vi history search, but in reverse\&.
.TP
\fBup\-line\-or\-history\fP (^P ESC\-[A) (k) (ESC\-[A)
Move up a line in the buffer, or if already at the top line,
move to the previous event in the history list\&.
.TP
\fBvi\-up\-line\-or\-history\fP (unbound) (\-) (unbound)
Move up a line in the buffer, or if already at the top line,
move to the previous event in the history list\&.
Then move to the first non\-blank character on the line\&.
.TP
\fBup\-line\-or\-search\fP
Move up a line in the buffer, or if already at the top line,
search backward in the history for a line beginning with the
first word in the buffer\&.
.RS
.PP
If called from a function by the \fBzle\fP command with arguments, the first
argument is taken as the string for which to search, rather than the
first word in the buffer\&.
.RE
.TP
\fBup\-history\fP (unbound) (^P) (unbound)
Move to the previous event in the history list\&.
.TP
\fBhistory\-beginning\-search\-forward\fP
Search forward in the history for a line beginning with the current
line up to the cursor\&.
This leaves the cursor in its original position\&.
.SS "Modifying Text"
.PD 0
.TP
.PD
Move to the end of the line and enter insert mode\&.
.TP
Enter insert mode after the current cursor position, without changing lines\&.
.TP
\fBbackward\-delete\-char\fP (^H ^?) (unbound) (unbound)
Delete the character behind the cursor\&.
.TP
\fBvi\-backward\-delete\-char\fP (unbound) (X) (^H)
Delete the character behind the cursor, without changing lines\&.
If in insert mode, this won\&'t delete past the point where insert mode was
last entered\&.
.TP
\fBbackward\-delete\-word\fP
Delete the word behind the cursor\&.
.TP
\fBbackward\-kill\-line\fP
Kill from the beginning of the line to the cursor position\&.
.TP
\fBbackward\-kill\-word\fP (^W ESC\-^H ESC\-^?) (unbound) (unbound)
Kill the word behind the cursor\&.
.TP
\fBvi\-backward\-kill\-word\fP (unbound) (unbound) (^W)
Kill the word behind the cursor, without going past the point where insert
mode was last entered\&.
.TP
\fBcapitalize\-word\fP (ESC\-C ESC\-c) (unbound) (unbound)
Capitalize the current word and move past it\&.
.TP
\fBvi\-change\fP (unbound) (c) (unbound)
Read a movement command from the keyboard, and kill
from the cursor position to the endpoint of the movement\&.
Then enter insert mode\&.
If the command is \fBvi\-change\fP, change the current line\&.
.TP
\fBvi\-change\-eol\fP (unbound) (C) (unbound)
Kill to the end of the line and enter insert mode\&.
.TP
\fBvi\-change\-whole\-line\fP (unbound) (S) (unbound)
Kill the current line and enter insert mode\&.
.TP
\fBcopy\-region\-as\-kill\fP (ESC\-W ESC\-w) (unbound) (unbound)
Copy the area from the cursor to the mark to the kill buffer\&.
.RS
.PP
If called from a ZLE widget function in the form \fBzle
copy\-region\-as\-kill\fP \fIstring\fP\&' then \fIstring\fP will be taken as the
text to copy to the kill buffer\&.  The cursor, the mark and the text on the
command line are not used in this case\&.
.RE
.TP
\fBcopy\-prev\-word\fP (ESC\-^_) (unbound) (unbound)
Duplicate the word to the left of the cursor\&.
.TP
\fBcopy\-prev\-shell\-word\fP
Like \fBcopy\-prev\-word\fP, but the word is found by using shell parsing,
whereas \fBcopy\-prev\-word\fP looks for blanks\&. This makes a difference
when the word is quoted and contains spaces\&.
.TP
\fBvi\-delete\fP (unbound) (d) (unbound)
Read a movement command from the keyboard, and kill
from the cursor position to the endpoint of the movement\&.
If the command is \fBvi\-delete\fP, kill the current line\&.
.TP
\fBdelete\-char\fP
Delete the character under the cursor\&.
.TP
\fBvi\-delete\-char\fP (unbound) (x) (unbound)
Delete the character under the cursor,
without going past the end of the line\&.
.TP
\fBdelete\-word\fP
Delete the current word\&.
.TP
\fBdown\-case\-word\fP (ESC\-L ESC\-l) (unbound) (unbound)
Convert the current word to all lowercase and move past it\&.
.TP
\fBkill\-word\fP (ESC\-D ESC\-d) (unbound) (unbound)
Kill the current word\&.
.TP
\fBgosmacs\-transpose\-chars\fP
Exchange the two characters behind the cursor\&.
.TP
\fBvi\-indent\fP (unbound) (>) (unbound)
Indent a number of lines\&.
.TP
\fBvi\-insert\fP (unbound) (i) (unbound)
Enter insert mode\&.
.TP
\fBvi\-insert\-bol\fP (unbound) (I) (unbound)
Move to the first non\-blank character on the line and enter insert mode\&.
.TP
\fBvi\-join\fP (^X^J) (J) (unbound)
Join the current line with the next one\&.
.TP
\fBkill\-line\fP (^K) (unbound) (unbound)
Kill from the cursor to the end of the line\&.
If already on the end of the line, kill the newline character\&.
.TP
\fBvi\-kill\-line\fP (unbound) (unbound) (^U)
Kill from the cursor back to wherever insert mode was last entered\&.
.TP
\fBvi\-kill\-eol\fP (unbound) (D) (unbound)
Kill from the cursor to the end of the line\&.
.TP
\fBkill\-region\fP
Kill from the cursor to the mark\&.
.TP
\fBkill\-buffer\fP (^X^K) (unbound) (unbound)
Kill the entire buffer\&.
.TP
\fBkill\-whole\-line\fP (^U) (unbound) (unbound)
Kill the current line\&.
.TP
\fBvi\-match\-bracket\fP (^X^B) (%) (unbound)
Move to the bracket character (one of \fB{}\fP, \fB()\fP or \fB[]\fP) that
matches the one under the cursor\&.
If the cursor is not on a bracket character, move forward without going
past the end of the line to find one, and then go to the matching bracket\&.
.TP
\fBvi\-open\-line\-above\fP (unbound) (O) (unbound)
Open a line above the cursor and enter insert mode\&.
.TP
\fBvi\-open\-line\-below\fP (unbound) (o) (unbound)
Open a line below the cursor and enter insert mode\&.
.TP
\fBvi\-oper\-swap\-case\fP
Read a movement command from the keyboard, and swap
the case of all characters
from the cursor position to the endpoint of the movement\&.
If the movement command is \fBvi\-oper\-swap\-case\fP,
swap the case of all characters on the current line\&.
.TP
\fBoverwrite\-mode\fP (^X^O) (unbound) (unbound)
Toggle between overwrite mode and insert mode\&.
.TP
\fBvi\-put\-before\fP (unbound) (P) (unbound)
Insert the contents of the kill buffer before the cursor\&.
If the kill buffer contains a sequence of lines (as opposed to characters),
paste it above the current line\&.
.TP
\fBvi\-put\-after\fP (unbound) (p) (unbound)
Insert the contents of the kill buffer after the cursor\&.
If the kill buffer contains a sequence of lines (as opposed to characters),
paste it below the current line\&.
.TP
\fBquoted\-insert\fP (^V) (unbound) (unbound)
Insert the next character typed into the buffer literally\&.
An interrupt character will not be inserted\&.
.TP
\fBvi\-quoted\-insert\fP (unbound) (unbound) (^Q ^V)
Display a \fB^\fP\&' at the cursor position, and
insert the next character typed into the buffer literally\&.
An interrupt character will not be inserted\&.
.TP
\fBquote\-line\fP (ESC\-\&') (unbound) (unbound)
Quote the current line; that is, put a \fB\&'\fP' character at the
beginning and the end, and convert all \fB\&'\fP' characters
to \fB\&'\e''\fP'\&.
.TP
\fBquote\-region\fP (ESC\-") (unbound) (unbound)
Quote the region from the cursor to the mark\&.
.TP
\fBvi\-replace\fP (unbound) (R) (unbound)
Enter overwrite mode\&.
.TP
\fBvi\-repeat\-change\fP (unbound) (\&.) (unbound)
Repeat the last vi mode text modification\&.
If a count was used with the modification, it is remembered\&.
If a count is given to this command, it overrides the remembered count,
and is remembered for future uses of this command\&.
The cut buffer specification is similarly remembered\&.
.TP
\fBvi\-replace\-chars\fP (unbound) (r) (unbound)
Replace the character under the cursor with a character
.TP
\fBself\-insert\fP (printable characters) (unbound) (printable characters and some control characters)
Insert a character into the buffer at the cursor position\&.
.TP
\fBself\-insert\-unmeta\fP (ESC\-^I ESC\-^J ESC\-^M) (unbound) (unbound)
Insert a character into the buffer after stripping the meta bit
and converting ^M to ^J\&.
.TP
\fBvi\-substitute\fP (unbound) (s) (unbound)
Substitute the next character(s)\&.
.TP
\fBvi\-swap\-case\fP (unbound) (~) (unbound)
Swap the case of the character under the cursor and move past it\&.
.TP
\fBtranspose\-chars\fP (^T) (unbound) (unbound)
Exchange the two characters to the left of the
cursor if at end of line, else exchange the
character under the cursor with the character
to the left\&.
.TP
\fBtranspose\-words\fP (ESC\-T ESC\-t) (unbound) (unbound)
Exchange the current word with the one before it\&.
.TP
\fBvi\-unindent\fP (unbound) (<) (unbound)
Unindent a number of lines\&.
.TP
\fBup\-case\-word\fP (ESC\-U ESC\-u) (unbound) (unbound)
Convert the current word to all caps and move past it\&.
.TP
\fByank\fP (^Y) (unbound) (unbound)
Insert the contents of the kill buffer at the cursor position\&.
.TP
\fByank\-pop\fP (ESC\-y) (unbound) (unbound)
Remove the text just yanked, rotate the kill\-ring (the history of
previously killed text) and yank the new top\&.  Only works following
\fByank\fP or \fByank\-pop\fP\&.
.TP
\fBvi\-yank\fP (unbound) (y) (unbound)
Read a movement command from the keyboard, and copy the region
from the cursor position to the endpoint of the movement
into the kill buffer\&.
If the command is \fBvi\-yank\fP, copy the current line\&.
.TP
\fBvi\-yank\-whole\-line\fP (unbound) (Y) (unbound)
Copy the current line into the kill buffer\&.
.TP
\fBvi\-yank\-eol\fP
Copy the region from the cursor position to the end of the line
into the kill buffer\&.
Arguably, this is what Y should do in vi, but it isn\&'t what it actually does\&.
.SS "Arguments"
.PD 0
.TP
.PD
\fBdigit\-argument\fP (ESC\-0\&.\&.ESC\-9) (1\-9) (unbound)
Start a new numeric argument, or add to the current one\&.
key sequence ending in a decimal digit\&.
.RS
.PP
Inside a widget function, a call to this function treats the last key of
the key sequence which called the widget as the digit\&.
.RE
.TP
\fBneg\-argument\fP (ESC\-\-) (unbound) (unbound)
Changes the sign of the following argument\&.
.TP
\fBuniversal\-argument\fP
Multiply the argument of the next command by 4\&.  Alternatively, if
this command is followed by an integer (positive or negative), use
that as the argument for the next command\&.  Thus digits cannot be
repeated using this command\&.  For example, if this command occurs
twice, followed immediately by \fBforward\-char\fP, move forward sixteen
spaces; if instead it is followed by \fB\-2\fP, then \fBforward\-char\fP,
move backward two spaces\&.
.RS
.PP
Inside a widget function, if passed an argument, i\&.e\&. \fBzle
universal\-argument\fP \fInum\fP\&', the numerical argument will be set to
\fInum\fP; this is equivalent to \fBNUMERIC=\fP\fInum\fP\&'\&.
.RE
.TP
\fBargument\-base\fP
Use the existing numeric argument as a numeric base, which must be in the
range 2 to 36 inclusive\&.  Subsequent use of \fBdigit\-argument\fP and
\fBuniversal\-argument\fP will input a new prefix in the given base\&.
The usual hexadecimal convention is used: the letter \fBa\fP or \fBA\fP
corresponds to 10, and so on\&.  Arguments in bases requiring digits from 10
upwards are more conveniently input with \fBuniversal\-argument\fP, since
\fBESC\-a\fP etc\&. are not usually bound to \fBdigit\-argument\fP\&.
.RS
.PP
The function can be used with a command argument inside a user\-defined
widget\&.  The following code sets the base to 16 and lets the user input a
hexadecimal argument until a key out of the digit range is typed:
.PP
.RS
.nf
\fBzle argument\-base 16
zle universal\-argument\fP
.fi
.RE
.RE
.RE
.SS "Completion"
.PD 0
.TP
.PD
In a menu completion, insert the current completion into the buffer,
and advance to the next possible completion\&.
.TP
\fBcomplete\-word\fP
Attempt completion on the current word\&.
.TP
\fBdelete\-char\-or\-list\fP (^D) (unbound) (unbound)
Delete the character under the cursor\&.  If the cursor
is at the end of the line, list possible completions for the
current word\&.
.TP
\fBexpand\-cmd\-path\fP
Expand the current command to its full pathname\&.
.TP
\fBexpand\-or\-complete\fP (TAB) (unbound) (TAB)
Attempt shell expansion on the current word\&.
If that fails,
attempt completion\&.
.TP
\fBexpand\-or\-complete\-prefix\fP
Attempt shell expansion on the current word up to cursor\&.
.TP
\fBexpand\-history\fP (ESC\-space ESC\-!) (unbound) (unbound)
Perform history expansion on the edit buffer\&.
.TP
\fBexpand\-word\fP (^X*) (unbound) (unbound)
Attempt shell expansion on the current word\&.
.TP
\fBlist\-choices\fP (ESC\-^D) (^D =) (^D)
List possible completions for the current word\&.
.TP
\fBlist\-expand\fP (^Xg ^XG) (^G) (^G)
List the expansion of the current word\&.
.TP
\fBmagic\-space\fP
Perform history expansion and insert a space into the
buffer\&.  This is intended to be bound to space\&.
.TP
Like \fBcomplete\-word\fP, except that menu completion is used\&.
.TP
Like \fBexpand\-or\-complete\fP, except that menu completion is used\&.
.TP
completion rather than the next\&.
.TP
\fBend\-of\-list\fP
When a previous completion displayed a list below the prompt, this
widget can be used to move the prompt below the list\&.
.SS "Miscellaneous"
.PD 0
.TP
.PD
\fBaccept\-and\-hold\fP (ESC\-A ESC\-a) (unbound) (unbound)
Push the contents of the buffer on the buffer stack
and execute it\&.
.TP
\fBaccept\-and\-infer\-next\-history\fP
Execute the contents of the buffer\&.
Then search the history list for a line matching the current one
and push the event following onto the buffer stack\&.
.TP
\fBaccept\-line\fP (^J ^M) (^J ^M) (^J ^M)
Finish editing the buffer\&.  Normally this causes the buffer to be
executed as a shell command\&.
.TP
\fBaccept\-line\-and\-down\-history\fP (^O) (unbound) (unbound)
Execute the current line, and push the next history
event on the the buffer stack\&.
.TP
\fBauto\-suffix\-remove\fP
If the previous action added a suffix (space, slash, etc\&.) to the word on
the command line, remove it\&.  Otherwise do nothing\&.  Removing the suffix
.RS
.PP
This widget is intended to be called from user\-defined widgets to enforce
a desired suffix\-removal behavior\&.
.RE
.TP
\fBauto\-suffix\-retain\fP
If the previous action added a suffix (space, slash, etc\&.) to the word on
the command line, force it to be preserved\&.  Otherwise do nothing\&.
.RS
.PP
This widget is intended to be called from user\-defined widgets to enforce
a desired suffix\-preservation behavior\&.
.RE
.TP
\fBbeep\fP
Beep, unless the \fBBEEP\fP option is unset\&.
.TP
\fBvi\-cmd\-mode\fP (^X^V) (unbound) (^[)
Enter command mode; that is, select the \fBvicmd\fP\&' keymap\&.
Yes, this is bound by default in emacs mode\&.
.TP
\fBvi\-caps\-lock\-panic\fP
Hang until any lowercase key is pressed\&.
This is for vi users without the mental capacity to keep
track of their caps lock key (like the author)\&.
.TP
\fBclear\-screen\fP (^L ESC\-^L) (^L) (^L)
Clear the screen and redraw the prompt\&.
.TP
\fBdescribe\-key\-briefly\fP
Reads a key sequence, then prints the function bound to that sequence\&.
.TP
\fBexchange\-point\-and\-mark\fP (^X^X) (unbound) (unbound)
Exchange the cursor position (point) with the position of the mark\&.
Unless a negative prefix argument is given, the region between
point and mark is activated so that it can be highlighted\&.
If a zero prefix argument is given, the region is activated but
point and mark are not swapped\&.
.TP
\fBexecute\-named\-cmd\fP (ESC\-x) (:) (unbound)
Read the name of an editor command and
execute it\&.  A restricted set of editing functions is available in the
mini\-buffer\&.  Keys are looked up in the special
An interrupt signal, as defined by the stty setting, will
abort the function\&.  Note that the following always
perform the same task within the \fBexecuted\-named\-cmd\fP environment and
cannot be replaced by user defined widgets, nor can the set of functions
be extended\&.  The allowed functions are:
\fBbackward\-delete\-char\fP,
\fBvi\-backward\-delete\-char\fP,
\fBclear\-screen\fP,
\fBredisplay\fP,
\fBquoted\-insert\fP,
\fBvi\-quoted\-insert\fP,
\fBbackward\-kill\-word\fP,
\fBvi\-backward\-kill\-word\fP,
\fBkill\-whole\-line\fP,
\fBvi\-kill\-line\fP,
\fBbackward\-kill\-line\fP,
\fBlist\-choices\fP,
\fBdelete\-char\-or\-list\fP,
\fBcomplete\-word\fP,
\fBaccept\-line\fP,
\fBexpand\-or\-complete\fP and
\fBexpand\-or\-complete\-prefix\fP\&.
.RS
.PP
\fBkill\-region\fP kills the last word,
and vi\-cmd\-mode is treated the same as accept\-line\&.
The space and tab characters, if not bound to one of
these functions, will complete the name and then list the
possibilities if the \fBAUTO_LIST\fP option is set\&.
Any other character that is not bound to \fBself\-insert\fP or
\fBself\-insert\-unmeta\fP will beep and be ignored\&.
The bindings of the current insert mode will be used\&.
.PP
Currently this command may not be redefined or called by name\&.
.RE
.TP
\fBexecute\-last\-named\-cmd\fP (ESC\-z) (unbound) (unbound)
Redo the last function executed with \fBexecute\-named\-cmd\fP\&.
.RS
.PP
Currently this command may not be redefined or called by name\&.
.RE
.TP
\fBget\-line\fP (ESC\-G ESC\-g) (unbound) (unbound)
Pop the top line off the buffer stack and insert it at the
cursor position\&.
.TP
\fBpound\-insert\fP (unbound) (#) (unbound)
If there is no # character at the beginning of the buffer,
add one to the beginning of each line\&.
If there is one, remove a # from each line that has one\&.
In either case, accept the current line\&.
The \fBINTERACTIVE_COMMENTS\fP option must be set
for this to have any usefulness\&.
.TP
\fBvi\-pound\-insert\fP
If there is no # character at the beginning of the current line,
add one\&.  If there is one, remove it\&.
The \fBINTERACTIVE_COMMENTS\fP option must be set
for this to have any usefulness\&.
.TP
\fBpush\-input\fP
Push the entire current multiline construct onto the buffer stack and
If the current parser construct is only a single line, this is exactly
like \fBpush\-line\fP\&.
Next time the editor starts up or is popped with \fBget\-line\fP, the
construct will be popped off the top of the buffer stack and loaded
into the editing buffer\&.
.TP
\fBpush\-line\fP (^Q ESC\-Q ESC\-q) (unbound) (unbound)
Push the current buffer onto the buffer stack and clear
the buffer\&.
Next time the editor starts up, the buffer will be popped
off the top of the buffer stack and loaded into the editing
buffer\&.
.TP
\fBpush\-line\-or\-edit\fP
At the top\-level (\fBPS1\fP) prompt, equivalent to \fBpush\-line\fP\&.
At a secondary (\fBPS2\fP) prompt, move the entire current multiline
construct into the editor buffer\&.
The latter is equivalent to \fBpush\-input\fP followed by \fBget\-line\fP\&.
.TP
Only useful from a user\-defined widget\&.  A keystroke is read just as in
normal operation, but instead of the command being executed the name
of the command that would be executed is stored in the shell parameter
\fBREPLY\fP\&.  This can be used as the argument of a future \fBzle\fP
command\&.  If the key sequence is not bound, status 1 is returned;
typically, however, \fBREPLY\fP is set to \fBundefined\-key\fP to indicate
a useless key sequence\&.
.TP
\fBrecursive\-edit\fP
Only useful from a user\-defined widget\&.  At this point in the function,
the editor regains control until one of the standard widgets which would
normally cause zle to exit (typically an \fBaccept\-line\fP caused by
hitting the return key) is executed\&.  Instead, control returns to the
user\-defined widget\&.  The status returned is non\-zero if the return was
caused by an error, but the function still continues executing and hence
may tidy up\&.  This makes it safe for the user\-defined widget to alter
the command line or key bindings temporarily\&.
.RS
.PP
The following widget, \fBcaps\-lock\fP, serves as an example\&.
.RS
.nf
\fBself\-insert\-ucase() {
LBUFFER+=${(U)KEYS[\-1]} } .PP integer stat .PP zle \-N self\-insert self\-insert\-ucase zle \-A caps\-lock save\-caps\-lock zle \-A accept\-line caps\-lock .PP zle recursive\-edit stat=$?
.PP
zle \-A \&.self\-insert self\-insert
zle \-A save\-caps\-lock caps\-lock
zle \-D save\-caps\-lock
.PP
(( stat )) && zle send\-break
.PP
return $stat \fP .fi .RE This causes typed letters to be inserted capitalised until either \fBaccept\-line\fP (i\&.e\&. typically the return key) is typed or the \fBcaps\-lock\fP widget is invoked again; the later is handled by saving the old definition of \fBcaps\-lock\fP as \fBsave\-caps\-lock\fP and then rebinding it to invoke \fBaccept\-line\fP\&. Note that an error from the recursive edit is detected as a non\-zero return status and propagated by using the \fBsend\-break\fP widget\&. .RE .TP \fBredisplay\fP (unbound) (^R) (^R) Redisplays the edit buffer\&. .TP \fBreset\-prompt\fP (unbound) (unbound) (unbound) Force the prompts on both the left and right of the screen to be re\-expanded, then redisplay the edit buffer\&. This reflects changes both to the prompt variables themselves and changes in the expansion of the values (for example, changes in time or directory, or changes to the value of variables referred to by the prompt)\&. .RS .PP Otherwise, the prompt is only expanded each time zle starts, and when the display as been interrupted by output from another part of the shell (such as a job notification) which causes the command line to be reprinted\&. .RE .TP \fBsend\-break\fP (^G ESC\-^G) (unbound) (unbound) Abort the current editor function, e\&.g\&. \fBexecute\-named\-command\fP, or the editor itself, e\&.g\&. if you are in \fBvared\fP\&. Otherwise abort the parsing of the current line; in this case the aborted line is available in the shell variable \fBZLE_LINE_ABORTED\fP\&. .TP \fBrun\-help\fP (ESC\-H ESC\-h) (unbound) (unbound) Push the buffer onto the buffer stack, and execute the command \fBrun\-help\fP \fIcmd\fP\&', where \fIcmd\fP is the current command\&. \fBrun\-help\fP is normally aliased to \fBman\fP\&. .TP \fBvi\-set\-buffer\fP (unbound) (") (unbound) Specify a buffer to be used in the following command\&. There are 35 buffers that can be specified: the 26 named\&' buffers \fB"a\fP to \fB"z\fP and the nine queued\&' buffers \fB"1\fP to \fB"9\fP\&. The named buffers can also be specified as \fB"A\fP to \fB"Z\fP\&. .RS .PP When a buffer is specified for a cut command, the text being cut replaces the previous contents of the specified buffer\&. If a named buffer is specified using a capital, the newly cut text is appended to the buffer instead of overwriting it\&. .PP If no buffer is specified for a cut command, \fB"1\fP is used, and the contents of \fB"1\fP to \fB"8\fP are each shifted along one buffer; the contents of \fB"9\fP is lost\&. .RE .TP \fBvi\-set\-mark\fP (unbound) (m) (unbound) Set the specified mark at the cursor position\&. .TP \fBset\-mark\-command\fP (^@) (unbound) (unbound) Set the mark at the cursor position\&. If called with a negative prefix argument, do not set the mark but deactivate the region so that it is no longer highlighted (it is still usable for other purposes)\&. Otherwise the region is marked as active\&. .TP \fBspell\-word\fP (ESC\-$ ESC\-S ESC\-s) (unbound) (unbound)
Attempt spelling correction on the current word\&.
.TP
\fBundefined\-key\fP
This command is executed when a key sequence that is not bound to any
command is typed\&.  By default it beeps\&.
.TP
\fBundo\fP (^_ ^Xu ^X^U) (unbound) (unbound)
Incrementally undo the last text modification\&.
.TP
\fBredo\fP
Incrementally redo undone text modifications\&.
.TP
\fBvi\-undo\-change\fP (unbound) (u) (unbound)
Undo the last text modification\&.
If repeated, redo the modification\&.
.TP
\fBwhat\-cursor\-position\fP (^X=) (unbound) (unbound)
Print the character under the cursor, its code as an octal, decimal and
hexadecimal number, the current cursor position within the buffer and the
column of the cursor in the current line\&.
.TP
\fBwhere\-is\fP
Read the name of an editor command and and print the listing of key
sequences that invoke the specified command\&.
A restricted set of editing functions is available in the
mini\-buffer\&.  Keys are looked up in the special
.TP
\fBwhich\-command\fP (ESC\-?) (unbound) (unbound)
Push the buffer onto the buffer stack, and execute the
command \fBwhich\-command\fP \fIcmd\fP\&'\&. where \fIcmd\fP is the current
command\&.  \fBwhich\-command\fP is normally aliased to \fIwhence\fP\&.
.TP
\fBvi\-digit\-or\-beginning\-of\-line\fP (unbound) (0) (unbound)
If the last command executed was a digit as part of an argument,
continue the argument\&.  Otherwise, execute vi\-beginning\-of\-line\&.
.PP
.SH "CHARACTER HIGHLIGHTING"
.PP
The line editor has the ability to highlight characters or regions
of the line that have a particular significance\&.  This is controlled
by the array parameter \fBzle_highlight\fP, if it has been set by the user\&.
.PP
If the parameter contains the single entry \fBnone\fP all highlighting
is turned off\&.  Note the parameter is still expected to be an array\&.
.PP
Otherwise each entry of the array should consist of a word indicating a
context for highlighting, then a colon, then a comma\-separated list of
the types of highlighting to apply in that context\&.
.PP
The contexts available for highlighting are the following:
.PP
.PD 0
.TP
.PD
\fBdefault\fP
Any text within the command line not affected by any other highlighting\&.
Text outside the editable area of the command line is not affected\&.
.TP
\fBisearch\fP
When one of the incremental history search widgets is active, the
area of the command line matched by the search string or pattern\&.
.TP
\fBregion\fP
The region between the cursor (point) and the mark as set with
\fBset\-mark\-command\fP\&.  The region is only highlighted if it is active,
which is the case if \fBset\-mark\-command\fP or \fBexchange\-point\-and\-mark\fP
has been called and the line has not been subsequently modified\&.  The
region can be deactivated by calling \fBset\-mark\-command\fP with a
negative prefix argument, or reactivated by calling
\fBexchange\-point\-and\-mark\fP with a zero prefix argument\&.  Note
that whether or not the region is active has no effect on its
use within widgets, it simply determines whether it is highlighted\&.
.TP
\fBspecial\fP
Individual characters that have no direct printable
representation but are shown in a special manner by the line editor\&.
These characters are described below\&.
.TP
\fBsuffix\fP
This context is used in completion for characters that are
marked as suffixes that will be removed if the completion ends
at that point, the most obvious example being a slash (\fB/\fP) after
a directory name\&.  Note that suffix removal is configurable; the
circumstances under which the suffix will be removed may differ
for different completions\&.
.PP
\fBzle_highlight\fP may contain additional fields for controlling how
terminal sequences to change colours are output\&.  Each of the following is
followed by a colon and a string in the same form as for key bindings\&.
This will not be necessary for the vast majority of terminals as the
defaults shown in parentheses are widely used\&.
.PP
.PD 0
.TP
.PD
\fBfg_start_code\fP (\fB\ee[3\fP)
The start of the escape sequence for the foreground colour\&.
This is followed by an ASCII digit representing the colour\&.
.TP
\fBfg_default_code\fP (\fB9\fP)
The number to use instead of the colour to reset the default foreground
colour\&.
.TP
\fBfg_end_code\fP (\fBm\fP)
The end of the escape sequence for the foreground colour\&.
.TP
\fBbg_start_code\fP (\fB\ee[4\fP)
The start of the escape sequence for the background colour\&.
This is followed by an ASCII digit representing the colour\&.
.TP
\fBbg_default_code\fP (\fB9\fP)
The number to use instead of the colour to reset the default
background colour\&.
.TP
\fBbg_end_code\fP (\fBm\fP)
The end of the escape sequence for the background colour\&.
.PP
The available types of highlighting are the following\&.  Note that
not all types of highlighting are available on all terminals:
.PP
.PD 0
.TP
.PD
\fBnone\fP
No highlighting is applied to the given context\&.  It is not useful for
this to appear with other types of highlighting; it is used to override
a default\&.
.TP
\fBfg=\fP\fIcolour\fP
The foreground colour should be set to \fIcolour\fP, a decimal integer
or the name of one of the eight most widely\-supported colours\&.
.RS
.PP
Not all terminals support this and, of those that do, not all provide
facilities to test the support, hence the user should decide based on the
terminal type\&.  Most terminals support the colours \fBblack\fP, \fBred\fP,
\fBgreen\fP, \fByellow\fP, \fBblue\fP, \fBmagenta\fP, \fBcyan\fP and \fBwhite\fP,
which can be set by name\&.  In addition\&. \fBdefault\fP may be used to
set the terminal\&'s default foreground colour\&.  Abbreviations are allowed;
\fBb\fP or \fBbl\fP selects black\&.  Some terminals may generate additional
colours if the \fBbold\fP attribute is also present\&.
.PP
On recent terminals and on systems with an up\-to\-date terminal database the
number of colours supported may be tested by the command \fBechotc
Co\fP\&'; if this succeeds, it indicates a limit on the number of colours which
will be enforced by the line editor\&.  The number of colours is in any case
limited to 256 (i\&.e\&. the range 0 to 255)\&.
.PP
Colour is also known as color\&.
.RE
.TP
\fBbg=\fP\fIcolour\fP
The background colour should be set to \fIcolour\fP\&.
This works similarly to the foreground colour, except the background is
not usually affected by the bold attribute\&.
.TP
\fBbold\fP
The characters in the given context are shown in a bold font\&.
Not all terminals distinguish bold fonts\&.
.TP
\fBstandout\fP
The characters in the given context are shown in the terminal\&'s standout
mode\&.  The actual effect is specific to the terminal; on many terminals it
is inverse video\&.  On some such terminals, where the cursor does not blink
it appears with standout mode negated, making it less than clear where
the cursor actually is\&.  On such terminals one of the other effects
may be preferable for highlighting the region and matched search string\&.
.TP
\fBunderline\fP
The characters in the given context are shown underlined\&.  Some
terminals show the foreground in a different colour instead; in this
case whitespace will not be highlighted\&.
.PP
The characters described above as special\&' are as follows\&.  The
formatting described here is used irrespective of whether the characters
are highlighted:
.PP
.PD 0
.TP
.PD
ASCII control characters
Control characters in the ASCII range are shown as
\fB^\fP\&' followed by the base character\&.
.TP
Unprintable multibyte characters
This item applies to control characters not in the ASCII range,
plus other characters as follows\&.  If the \fBMULTIBYTE\fP option is in
effect, multibyte characters not in the ASCII character set that are
reported as having zero width are treated as combining characters when the
option \fBCOMBINING_CHARS\fP is on\&.  If the option is off, or if a character
appears where a combining character is not valid, the character
is treated as unprintable\&.
.RS
.PP
Unprintable multibyte characters are shown as a hexadecimal number between
angle brackets\&.  The number is the code point of the character in the wide
character set; this may or may not be Unicode, depending on the operating
system\&.
.RE
.TP
Invalid multibyte characters
If the \fBMULTIBYTE\fP option is in effect, any sequence of one or more
bytes that does not form a valid character in the current character
set is treated as a series of bytes each shown as a special character\&.
This case can be distinguished from other unprintable characters
as the bytes are represented as two hexadecimal digits between angle
brackets, as distinct from the four or eight digits that are used for
unprintable characters that are nonetheless valid in the current
character set\&.
.RS
.PP
Not all systems support this: for it to work, the system\&'s representation of
wide characters must be code values from the Universal Character Set,
as defined by IS0 10646 (also known as Unicode)\&.
.RE
.RE
.PP
If \fBzle_highlight\fP is not set or no value applies to a particular
context, the defaults applied are equivalent to
.PP
.RS
.nf
\fBzle_highlight=(region:standout special:standout
suffix:bold isearch:underline)\fP
.fi
.RE
.PP
i\&.e\&. both the region and special characters are shown in standout mode\&.
.PP
Within widgets, arbitrary regions may be highlighted by setting the
special array parameter \fBregion_highlight\fP; see
above\&.
.PP
`