Manual Pages for UNIX Darwin command on man zshzle
MyWebUniversity

Manual Pages for UNIX Darwin command on man zshzle

ZSHZLE(1) ZSHZLE(1)

NAME

zshzle - zsh command line editor

DESCRIPTION

If the ZZLLEE 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. There are two display modes. The first, multiline mode, is the

default. It only works if the TTEERRMM parameter is set to a valid termi-

nal type that can move the cursor up. The second, single line mode, is used if TTEERRMM is invalid or incapable of moving the cursor up, or if the SSIINNGGLLEELLIINNEEZZLLEE option is set. This mode is similar to kksshh, and uses no termcap sequences. If TTEERRMM is "emacs", the ZZLLEE option will be unset by default.

The parameters BBAAUUDD, CCOOLLUUMMNNSS, and LLIINNEESS are also used by the line edi-

tor. See Parameters Used By The Shell in zshparam(1). KKEEYYMMAAPPSS A keymap in ZLE contains a set of bindings between key sequences and ZLE commands. The empty key sequence cannot be bound. 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. bbiinnddkkeeyy can be used to manipulate keymap names. Initially, there are four keymaps: eemmaaccss EMACS emulation

vviiiinnss vi emulation - insert mode

vviiccmmdd vi emulation - command mode

..ssaaffee fallback keymap The `..ssaaffee' 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 `..' for their own keymaps. In addition to these four names, either `eemmaaccss' or `vviiiinnss' is also linked to the name `mmaaiinn'. If one of the VVIISSUUAALL or EEDDIITTOORR environment variables contain the string `vvii' when the shell starts up then it will

be `vviiiinnss', otherwise it will be `eemmaaccss'. bbiinnddkkeeyy's -ee and -vv options

provide a convenient way to override this default choice. When the editor starts up, it will select the `mmaaiinn' keymap. If that keymap doesn't exist, it will use `..ssaaffee' instead.

In the `..ssaaffee' keymap, each single key is bound to sseellff-iinnsseerrtt, except

for ^J (line feed) and ^M (return) which are bound to aacccceepptt-lliinnee.

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. RReeaaddiinngg CCoommmmaannddss 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 char-

acters are typed, and if not (or they don't match any longer string) it will execute the binding. This timeout is defined by the KKEEYYTTIIMMEEOOUUTT parameter; its default is 0.4 sec. There is no timeout if the prefix string is not itself bound to a command. As well as ZLE commands, key sequences can be bound to other strings,

by using `bbiinnddkkeeyy -ss'. 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 fur-

ther 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. ZZLLEE BBUUIILLTTIINNSS The ZLE module contains three related builtin commands. The bbiinnddkkeeyy command manipulates keymaps and key bindings; the vvaarreedd command invokes ZLE on the value of a shell parameter; and the zzllee command manipulates editing widgets and allows command line access to ZLE commands from within shell functions.

bbiinnddkkeeyy [ options ] -ll

bbiinnddkkeeyy [ options ] -dd

bbiinnddkkeeyy [ options ] -DD keymap ...

bbiinnddkkeeyy [ options ] -AA old-keymap new-keymap

bbiinnddkkeeyy [ options ] -NN new-keymap [ old-keymap ]

bbiinnddkkeeyy [ options ] -mm

bbiinnddkkeeyy [ options ] -rr in-string ...

bbiinnddkkeeyy [ options ] -ss in-string out-string ...

bbiinnddkkeeyy [ options ] in-string command ...

bbiinnddkkeeyy [ options ] [ in-string ]

bbiinnddkkeeyy's options can be divided into three categories: keymap

selection, operation selection, and others. The keymap selec-

tion options are:

-ee Selects keymap `eemmaaccss', and also links it to `mmaaiinn'.

-vv Selects keymap `vviiiinnss', and also links it to `mmaaiinn'.

-aa Selects keymap `vviiccmmdd'.

-MM keymap

The keymap specifies a keymap name. If a keymap selection is required and none of the options above are used, the `mmaaiinn' keymap is used. Some operations do not permit a keymap to be selected, namely:

-ll List all existing keymap names. If the -LL option is also

used, list in the form of bbiinnddkkeeyy commands to create the keymaps.

-dd Delete all existing keymaps and reset to the default

state.

-DD keymap ...

Delete the named keymaps.

-AA old-keymap new-keymap

Make the new-keymap name an alias for old-keymap, 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 new-keymap name, it

is deleted.

-NN new-keymap [ old-keymap ]

Create a new keymap, named new-keymap. If a keymap

already has that name, it is deleted. If an old-keymap

name is given, the new keymap is initialized to be a duplicate of it, otherwise the new keymap will be empty. To use a newly created keymap, it should be linked to mmaaiinn. Hence the sequence of commands to create and use a new keymap `mmyymmaapp' initialized from the eemmaaccss keymap (which remains unchanged) is:

bbiinnddkkeeyy -NN mmyymmaapp eemmaaccss

bbiinnddkkeeyy -AA mmyymmaapp mmaaiinn

Note that while `bbiinnddkkeeyy -AA newmap mmaaiinn' will work when newmap

is eemmaaccss or vviiiinnss, it will not work for vviiccmmdd, as switching from vi insert to command mode becomes impossible. The following operations act on the `mmaaiinn' keymap if no keymap selection option was given:

-mm Add the built-in set of meta-key bindings to the selected

keymap. Only keys that are unbound or bound to

sseellff-iinnsseerrtt are affected.

-rr in-string ...

Unbind the specified in-strings in the selected keymap.

This is exactly equivalent to binding the strings to

uunnddeeffiinneedd-kkeeyy.

When -RR is also used, interpret the in-strings as ranges.

When -pp is also used, the in-strings specify prefixes.

Any binding that has the given in-string as a prefix, not

including the binding for the in-string itself, if any,

will be removed. For example,

bbiinnddkkeeyy -rrppMM vviiiinnss ''^^[[''

will remove all bindings in the vi-insert keymap begin-

ning with an escape character (probably cursor keys), but

leave the binding for the escape character itself (proba-

bly vvii-ccmmdd-mmooddee). This is incompatible with the option

-RR.

-ss in-string out-string ...

Bind each in-string to each out-string. When in-string

is typed, out-string will be pushed back and treated as

input to the line editor. When -RR is also used, inter-

pret the in-strings as ranges.

in-string command ...

Bind each in-string to each command. When -RR is used,

interpret the in-strings as ranges.

[ in-string ]

List key bindings. If an in-string is specified, the

binding of that string in the selected keymap is dis-

played. Otherwise, all key bindings in the selected

keymap are displayed. (As a special case, if the -ee or

-vv option is used alone, the keymap is not displayed -

the implicit linking of keymaps is the only thing that happens.)

When the option -pp is used, the in-string must be

present. The listing shows all bindings which have the

given key sequence as a prefix, not including any bind-

ings for the key sequence itself.

When the -LL option is used, the list is in the form of

bbiinnddkkeeyy commands to create the key bindings.

When the -RR option is used as noted above, a valid range consists of

two characters, with an optional `-' between them. All characters

between the two specified, inclusive, are bound as specified.

For either in-string or out-string, the following escape sequences are

recognised: \\aa bell character \\bb backspace \\ee, \\EE escape \\ff form feed \\nn linefeed (newline) \\rr carriage return \\tt horizontal tab \\vv vertical tab \\NNN character code in octal \\xxNN character code in hexadecimal

\\MM[-]X character with meta bit set

\\CC[-]X control character

^^X control character In all other cases, `\\' escapes the following character. Delete is written as `^^??'. Note that `\\MM^^??' and `^^\\MM??' are not the same, and

that (unlike emacs), the bindings `\\MM-X' and `\\eeX' are entirely dis-

tinct, although they are initialized to the same bindings by `bbiinnddkkeeyy

-mm'.

vvaarreedd [ -AAaacchhee ] [ -pp prompt ] [ -rr rprompt ]

[ -M main-keymap ] [ -m vicmd-keymap ] name

The value of the parameter name is loaded into the edit buffer, and the line editor is invoked. When the editor exits, name is

set to the string value returned by the editor. When the -cc

flag is given, the parameter is created if it doesn't already

exist. The -aa flag may be given with -cc to create an array

parameter, or the -AA 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. If an array or array slice is being edited, separator characters

as defined in $$IIFFSS 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 fol-

lowing separator character or backslash; no other special han-

dling of backslashes, or any handling of quotes, is performed. Individual elements of existing array or associative array parameters may be edited by using subscript syntax on name. New

elements are created automatically, even without -cc.

If the -pp flag is given, the following string will be taken as

the prompt to display at the left. If the -rr flag is given, the

following string gives the prompt to display at the right. If

the -hh flag is specified, the history can be accessed from ZLE.

If the -ee flag is given, typing ^^DD (Control-D) on an empty line

causes vvaarreedd to exit immediately with a non-zero return value.

The -MM option gives a keymap to link to the mmaaiinn keymap during

editing, and the -mm option gives a keymap to link to the vviiccmmdd

keymap during editing. For vi-style editing, this allows a pair

of keymaps to override vviiiinnss and vviiccmmdd. For emacs-style edit-

ing, only -MM is normally needed but the -mm option may still be

used. On exit, the previous keymaps will be restored. zzllee

zzllee -ll [ -LL | -aa ] [ string ... ]

zzllee -DD widget ...

zzllee -AA old-widget new-widget

zzllee -NN widget [ function ]

zzllee -CC widget completion-widget function

zzllee -RR [ -cc ] [ display-string ] [ string ... ]

zzllee -MM string

zzllee -UU string

zzllee -KK keymap

zzllee -FF [ -LL ] [ fd [ handler ] ]

zzllee -II

zzllee widget [[ -nn num ]] [[ -NN ]] args ...

The zzllee builtin performs a number of different actions concern-

ing ZLE. 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. Otherwise, which operation it performs depends on its options:

-ll [ -LL | -aa ]

List all existing user-defined widgets. If the -LL option

is used, list in the form of zzllee commands to create the widgets.

When combined with the -aa option, all widget names are

listed, including the builtin ones. In this case the -LL

option is ignored. If at least one string is given, nothing will be printed but the return status will be zero if all strings are

names of existing widgets (or of user-defined widgets if

the -aa flag is not given) and non-zero if at least one

string is not a name of an defined widget.

-DD widget ...

Delete the named widgets.

-AA old-widget new-widget

Make the new-widget name an alias for old-widget, 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 new-widget name, it

is deleted.

-NN widget [ function ]

Create a user-defined widget. If there is already a wid-

get with the specified name, it is overwritten. When the

new widget is invoked from within the editor, the speci-

fied shell function is called. If no function name is specified, it defaults to the same name as the widget.

For further information, see the section Widgets in zsh-

zle(1).

-CC widget completion-widget function

Create a user-defined completion widget named widget. The

completion widget will behave like the built-in comple-

tion-widget whose name is given as completion-widget. To

generate the completions, the shell function function

will be called. For further information, see zshcomp-

wid(1).

-RR [ -cc ] [ display-string ] [ string ... ]

Redisplay the command line; this is to be called from

within a user-defined widget to allow changes to become

visible. If a display-string is given and not empty,

this is shown in the status line (immediately below the line being edited). If the optional strings are given they are listed below the prompt in the same way as completion lists are

printed. If no strings are given but the -cc option is

used such a list is cleared. 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. 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. The status is zero if zle was active, else one.

-MM string

As with the -RR option, the string will be displayed below

the command line; unlike the -RR option, the string will

not be put into the status line but will instead be printed normally below the prompt. This means that the string will still be displayed after the widget returns (until it is overwritten by subsequent commands).

-UU string

This pushes the characters in the string onto the input

stack of ZLE. After the widget currently executed fin-

ishes ZLE will behave as if the characters in the string were typed by the user. 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 string will be processed in the order in which they appear in the string.

-KK keymap

Selects the keymap named keymap. An error message will be displayed if there is no such keymap.

This keymap selection affects the interpretation of fol-

lowing keystrokes within this invocation of ZLE. Any following invocation (e.g., the next command line) will start as usual with the `mmaaiinn' keymap selected.

-FF [ -LL ] [ fd [ handler ] ]

Only available if your system supports one of the `poll' or `select' system calls; most modern systems do. Installs handler (the name of a shell function) to handle input from file descriptor fd. When zle is attempting to read data, it will examine both the terminal and the list of handled fd's. If data becomes available on a handled fd, zle will call handler with the fd which is ready for reading as the only argument. If the handler produces

output to the terminal, it should call `zzllee -II' 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. Any number of handlers for any number of readable file descriptors may be installed. Installing a handler for

an fd which is already handled causes the existing han-

dler to be replaced. If no handler is given, but an fd is present, any handler

for that fd is removed. If there is none, an error mes-

sage is printed and status 1 is returned.

If no arguments are given, or the -LL option is supplied,

a list of handlers is printed in a form which can be stored for later execution. An fd (but not a handler) may optionally be given with

the -LL option; in this case, the function will list the

handler if any, else silently return status 1.

Note that this feature should be used with care. Activ-

ity on one of the fd's which is not properly handled can cause the terminal to become unusable.

Here is a simple example of using this feature. A con-

nection to a remote TCP port is created using the ztcp command; see the description of the zzsshh//nneett//ttccpp module in zshmodules(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 connec-

tion; we handle that by testing for a failed read. iiff zzttccpp ppwwssppcc 22881111;; tthheenn

ttccppffdd==$$RREEPPLLYY

hhaannddlleerr(()) {{

zzllee -II

llooccaall lliinnee

iiff !! rreeaadd -rr lliinnee <<&&$$11;; tthheenn

## sseelleecctt mmaarrkkss tthhiiss ffdd iiff wwee rreeaacchh EEOOFF,,

## ssoo hhaannddllee tthhiiss ssppeecciiaallllyy..

pprriinntt ""[[RReeaadd oonn ffdd $$11 ffaaiilleedd,, rreemmoovviinngg..]]"" >>&&22

zzllee -FF $$11

rreettuurrnn 11 ffii

pprriinntt -rr - $$lliinnee

}}

zzllee -FF $$ttccppffdd hhaannddlleerr

ffii

-II 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 follow-

ing will print output in such a way as not to disturb the line being edited: TTRRAAPPUUSSRR11(()) {{

## IInnvvaalliiddaattee zzllee ddiissppllaayy

[[[[ -oo zzllee ]]]] &&&& zzllee -II

## SShhooww oouuttppuutt

pprriinntt HHeelllloo }} In general, the trap function may need to test whether zle is active before using this method (as shown in the example), since the zzsshh//zzllee module may not even be loaded; if it is not, the command can be skipped.

It is possible to call `zzllee -II' several times before con-

trol is returned to the editor; the display will only be invalidated the first time to minimise disruption. Note that there are normally better ways of manipulating the display from within zle widgets; see, for example,

`zzllee -RR' above.

The returned status is zero if zle was invalidated, even

though this may have been by a previous call to `zzllee -II'

or by a system notification. To test if a zle widget may be called at this point, execute zzllee with no arguments and examine the return status.

widget [[ -nn num ]] [[ -NN ]] args ...

Invoke the specified widget. This can only be done when ZLE is active; normally this will be within a

user-defined widget.

With the options -nn and -NN, the current numerical argu-

ment will be saved and then restored after the call to

wwiiddggeett; `-nn num' sets the numerical argument temporarily

to num, while `-NN' sets it to the default, i.e. as if

there were none. Any further arguments will be passed to the widget. If

it is a shell function, these are passed down as posi-

tional 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 com-

mands, the hhiissttoorryy-sseeaarrcchh-ffoorrwwaarrdd and -bbaacckkwwaarrdd and the

corresponding functions prefixed by vvii-, and by uunniivveerr-

ssaall-aarrgguummeenntt. No error is flagged if the command does

not use the arguments, or only uses some of them. 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 func-

tion.

A non-zero return status causes the shell to beep when

the widget exits, unless the BBEEEEPP options was unset or the widget was called via the zzllee command. Thus if a user defined widget requires an immediate beep, it should call the bbeeeepp widget directly. WWIIDDGGEETTSS 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.

The standard widgets built in to ZLE are listed in Standard Widgets

below. Other built-in widgets can be defined by other modules (see

zshmodules(1)). Each built-in widget has two names: its normal canoni-

cal name, and the same name preceded by a `..'. The `..' name is spe-

cial: it can't be rebound to a different widget. This makes the widget available even when its usual name has been redefined.

User-defined widgets are defined using `zzllee -NN', 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 `..'.

UUSSEERR-DDEEFFIINNEEDD WWIIDDGGEETTSS

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 zzllee builtin command. The standard

input of the function is closed to prevent external commands from unin-

tentionally blocking ZLE by reading from the terminal, but rreeaadd -kk or

rreeaadd -qq 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. 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 llooccaall. Inside completion widgets and traps called while ZLE is active, these

parameters are available read-only.

BBUUFFFFEERR (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. BBUUFFFFEERRLLIINNEESS (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.

CCOONNTTEEXXTT (scalar)

The context in which zle was called to read a line; read-only.

One of the values: start The start of a command line (at prompt PPSS11). cont A continuation to a command line (at prompt PPSS22). select In a sseelleecctt loop. vared Editing a variable in vvaarreedd. CCUURRSSOORR (integer) The offset of the cursor, within the edit buffer. This is in

the range 0 to $$##BBUUFFFFEERR, and is by definition equal to

$$##LLBBUUFFFFEERR. Attempts to move the cursor outside the buffer will

result in the cursor being moved to the appropriate end of the buffer. CCUUTTBBUUFFFFEERR (scalar)

The last item to be cut using one of the `kkiillll-' commands; the

string which the next yank would insert in the line. HHIISSTTNNOO (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 HHIISSTTCCMMDD, which always gives the number of the history line being added to the main shell's history. HHIISSTTNNOO refers to the line being retrieved within zle. KKEEYYMMAAPP (scalar)

The name of the currently selected keymap; read-only.

KKEEYYSS (scalar) The keys typed to invoke this widget, as a literal string;

read-only.

kkiillllrriinngg (array) The array of previously killed items, with the most recently killed first. This gives the items that would be retrieved by a

yyaannkk-ppoopp in the same order.

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 yyaannkk-ppoopp 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. LLAASSTTSSEEAARRCCHH (scalar) The last search string used by an interactive search ;

read-only.

LLAASSTTWWIIDDGGEETT (scalar)

The name of the last widget that was executed; read-only.

LLBBUUFFFFEERR (scalar)

The part of the buffer that lies to the left of the cursor posi-

tion. If it is assigned to, only that part of the buffer is

replaced, and the cursor remains between the new $$LLBBUUFFFFEERR and

the old $$RRBBUUFFFFEERR.

MMAARRKK (integer) Like CCUURRSSOORR, but for the mark. NNUUMMEERRIICC (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 zzllee 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. PPEENNDDIINNGG (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.

PPRREEBBUUFFFFEERR (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. PPRREEDDIISSPPLLAAYY (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 invoca-

tion) of zle. PPOOSSTTDDIISSPPLLAAYY (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. RRBBUUFFFFEERR (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 $$LLBBUUFFFFEERR and

the new $$RRBBUUFFFFEERR.

WWIIDDGGEETT (scalar)

The name of the widget currently being executed; read-only.

WWIIDDGGEETTFFUUNNCC (scalar) The name of the shell function that implements a widget defined

with either zzllee -NN or zzllee -CC. In the former case, this is the

second argument to the zzllee -NN 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 zzllee -CC command

that defined the widget. Read-only.

WWIIDDGGEETTSSTTYYLLEE (scalar)

Describes the implementation behind the completion widget cur-

rently being executed; the second argument that followed zzllee -CC

when the widget was defined. This is the name of a builtin com-

pletion widget. For widgets defined with zzllee -NN this is set to

the empty string. Read-only.

SSppeecciiaall WWiiddggeett

There is one user-defined widget which is special to the shell. If it

does not exist, no special action is taken. The environment provided is identical to that for any other editing widget.

zzllee-lliinnee-iinniitt

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.

zzllee-lliinnee-iinniitt(()) {{ zzllee -KK vviiccmmdd;; }}

zzllee -NN zzllee-lliinnee-iinniitt

(The command inside the function sets the keymap directly; it is

equivalent to zzllee vvii-ccmmdd-mmooddee.)

SSTTAANNDDAARRDD WWIIDDGGEETTSS 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 `eemmaaccss', `vviiccmmdd' and `vviiiinnss' keymaps, respectively). 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 vviiiinnss keymap, the initial escape character of the

sequences serves also to return to the vviiccmmdd keymap: whether this hap-

pens is determined by the KKEEYYTTIIMMEEOOUUTT parameter, see zshparam(1). MMoovveemmeenntt

vvii-bbaacckkwwaarrdd-bbllaannkk-wwoorrdd (unbound) (B) (unbound)

Move backward one word, where a word is defined as a series of

non-blank characters.

bbaacckkwwaarrdd-cchhaarr (^B ESC-[D) (unbound) (unbound)

Move backward one character.

vvii-bbaacckkwwaarrdd-cchhaarr (unbound) (^H h ^?) (ESC-[D)

Move backward one character, without changing lines.

bbaacckkwwaarrdd-wwoorrdd (ESC-B ESC-b) (unbound) (unbound)

Move to the beginning of the previous word.

eemmaaccss-bbaacckkwwaarrdd-wwoorrdd

Move to the beginning of the previous word.

vvii-bbaacckkwwaarrdd-wwoorrdd (unbound) (b) (unbound)

Move to the beginning of the previous word, vi-style.

bbeeggiinnnniinngg-ooff-lliinnee (^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.

vvii-bbeeggiinnnniinngg-ooff-lliinnee

Move to the beginning of the line, without changing lines.

eenndd-ooff-lliinnee (^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.

vvii-eenndd-ooff-lliinnee (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 (argu-

ment - 1) lines down.

vvii-ffoorrwwaarrdd-bbllaannkk-wwoorrdd (unbound) (W) (unbound)

Move forward one word, where a word is defined as a series of

non-blank characters.

vvii-ffoorrwwaarrdd-bbllaannkk-wwoorrdd-eenndd (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.

ffoorrwwaarrdd-cchhaarr (^F ESC-[C) (unbound) (unbound)

Move forward one character.

vvii-ffoorrwwaarrdd-cchhaarr (unbound) (space l) (ESC-[C)

Move forward one character.

vvii-ffiinndd-nneexxtt-cchhaarr (^X^F) (f) (unbound)

Read a character from the keyboard, and move to the next occur-

rence of it in the line.

vvii-ffiinndd-nneexxtt-cchhaarr-sskkiipp (unbound) (t) (unbound)

Read a character from the keyboard, and move to the position just before the next occurrence of it in the line.

vvii-ffiinndd-pprreevv-cchhaarr (unbound) (F) (unbound)

Read a character from the keyboard, and move to the previous occurrence of it in the line.

vvii-ffiinndd-pprreevv-cchhaarr-sskkiipp (unbound) (T) (unbound)

Read a character from the keyboard, and move to the position just after the previous occurrence of it in the line.

vvii-ffiirrsstt-nnoonn-bbllaannkk (unbound) (^) (unbound)

Move to the first non-blank character in the line.

vvii-ffoorrwwaarrdd-wwoorrdd (unbound) (w) (unbound)

Move forward one word, vi-style.

ffoorrwwaarrdd-wwoorrdd (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 WWOORRDDCCHHAARRSS parameter.

eemmaaccss-ffoorrwwaarrdd-wwoorrdd

Move to the end of the next word.

vvii-ffoorrwwaarrdd-wwoorrdd-eenndd (unbound) (e) (unbound)

Move to the end of the next word.

vvii-ggoottoo-ccoolluummnn (ESC-|) (|) (unbound)

Move to the column specified by the numeric argument.

vvii-ggoottoo-mmaarrkk (unbound) (`) (unbound)

Move to the specified mark.

vvii-ggoottoo-mmaarrkk-lliinnee (unbound) (') (unbound)

Move to beginning of the line containing the specified mark.

vvii-rreeppeeaatt-ffiinndd (unbound) (;) (unbound)

Repeat the last vvii-ffiinndd command.

vvii-rreevv-rreeppeeaatt-ffiinndd (unbound) (,) (unbound)

Repeat the last vvii-ffiinndd command in the opposite direction.

HHiissttoorryy CCoonnttrrooll

bbeeggiinnnniinngg-ooff-bbuuffffeerr-oorr-hhiissttoorryy (ESC-<) (unbound) (unbound)

Move to the beginning of the buffer, or if already there, move to the first event in the history list.

bbeeggiinnnniinngg-ooff-lliinnee-hhiisstt

Move to the beginning of the line. If already at the beginning of the buffer, move to the previous history line.

bbeeggiinnnniinngg-ooff-hhiissttoorryy

Move to the first event in the history list.

ddoowwnn-lliinnee-oorr-hhiissttoorryy (^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.

vvii-ddoowwnn-lliinnee-oorr-hhiissttoorryy (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.

ddoowwnn-lliinnee-oorr-sseeaarrcchh

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. If called from a function by the zzllee command with arguments, the first argument is taken as the string for which to search, rather than the first word in the buffer.

ddoowwnn-hhiissttoorryy (unbound) (^N) (unbound)

Move to the next event in the history list.

hhiissttoorryy-bbeeggiinnnniinngg-sseeaarrcchh-bbaacckkwwaarrdd

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.

eenndd-ooff-bbuuffffeerr-oorr-hhiissttoorryy (ESC->) (unbound) (unbound)

Move to the end of the buffer, or if already there, move to the last event in the history list.

eenndd-ooff-lliinnee-hhiisstt

Move to the end of the line. If already at the end of the buffer, move to the next history line.

eenndd-ooff-hhiissttoorryy

Move to the last event in the history list.

vvii-ffeettcchh-hhiissttoorryy (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).

hhiissttoorryy-iinnccrreemmeennttaall-sseeaarrcchh-bbaacckkwwaarrdd (^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 `^^' to anchor the search to the beginning of the line. A restricted set of editing functions is available in the

mini-buffer. An interrupt signal, as defined by the stty set-

ting, will stop the search and go back to the original line. An undefined key will have the same effect. The supported functions

are: bbaacckkwwaarrdd-ddeelleettee-cchhaarr, vvii-bbaacckkwwaarrdd-ddeelleettee-cchhaarr,

cclleeaarr-ssccrreeeenn, rreeddiissppllaayy, qquuootteedd-iinnsseerrtt, vvii-qquuootteedd-iinnsseerrtt,

aacccceepptt-aanndd-hhoolldd, aacccceepptt-aanndd-iinnffeerr-nneexxtt-hhiissttoorryy, aacccceepptt-lliinnee and

aacccceepptt-lliinnee-aanndd-ddoowwnn-hhiissttoorryy.

mmaaggiicc-ssppaaccee just inserts a space. vvii-ccmmdd-mmooddee toggles between

the `mmaaiinn' and `vviiccmmdd' keymaps; the `mmaaiinn' keymap (insert mode)

will be selected initially. hhiissttoorryy-iinnccrreemmeennttaall-sseeaarrcchh-bbaacckkwwaarrdd

will get the next occurrence of the contents of the mini-buffer.

hhiissttoorryy-iinnccrreemmeennttaall-sseeaarrcchh-ffoorrwwaarrdd inverts the sense of the

search. vvii-rreeppeeaatt-sseeaarrcchh and vvii-rreevv-rreeppeeaatt-sseeaarrcchh are similarly

supported. The direction of the search is indicated in the

mini-buffer.

Any multi-character string that is not bound to one of the above

functions will beep and interrupt the search, leaving the last found line in the buffer. Any single character that is not bound

to one of the above functions, or sseellff-iinnsseerrtt or

sseellff-iinnsseerrtt-uunnmmeettaa, will have the same effect but the function

will be executed. When called from a widget function by the zzllee command, the incremental search commands can take a string argument. This will be treated as a string of keys, as for arguments to the bbiinnddkkeeyy 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,

zzllee hhiissttoorryy-iinnccrreemmeennttaall-sseeaarrcchh-bbaacckkwwaarrdd ffoorrcceeppss

will search backwards for ffoorrcceeppss, leaving the minibuffer con-

taining the string `ffoorrcceeppss'.

hhiissttoorryy-iinnccrreemmeennttaall-sseeaarrcchh-ffoorrwwaarrdd (^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 `^^' to anchor the search to the beginning of the line. The

functions available in the mini-buffer are the same as for hhiiss-

ttoorryy-iinnccrreemmeennttaall-sseeaarrcchh-bbaacckkwwaarrdd.

hhiissttoorryy-sseeaarrcchh-bbaacckkwwaarrdd (ESC-P ESC-p) (unbound) (unbound)

Search backward in the history for a line beginning with the first word in the buffer. If called from a function by the zzllee command with arguments, the first argument is taken as the string for which to search, rather than the first word in the buffer.

vvii-hhiissttoorryy-sseeaarrcchh-bbaacckkwwaarrdd (unbound) (/) (unbound)

Search backward in the history for a specified string. The string may begin with `^^' to anchor the search to the beginning of the line. A restricted set of editing functions is available in the

mini-buffer. An interrupt signal, as defined by the stty set-

ting, will stop the search. The functions available in the

mini-buffer are: aacccceepptt-lliinnee, bbaacckkwwaarrdd-ddeelleettee-cchhaarr, vvii-bbaacckk-

wwaarrdd-ddeelleettee-cchhaarr, bbaacckkwwaarrdd-kkiillll-wwoorrdd, vvii-bbaacckkwwaarrdd-kkiillll-wwoorrdd,

cclleeaarr-ssccrreeeenn, rreeddiissppllaayy, qquuootteedd-iinnsseerrtt and vvii-qquuootteedd-iinnsseerrtt.

vvii-ccmmdd-mmooddee is treated the same as accept-line, and mmaaggiicc-ssppaaccee

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. If called from a function by the zzllee command with arguments, the first argument is taken as the string for which to search, rather than the first word in the buffer.

hhiissttoorryy-sseeaarrcchh-ffoorrwwaarrdd (ESC-N ESC-n) (unbound) (unbound)

Search forward in the history for a line beginning with the first word in the buffer. If called from a function by the zzllee command with arguments, the first argument is taken as the string for which to search, rather than the first word in the buffer.

vvii-hhiissttoorryy-sseeaarrcchh-ffoorrwwaarrdd (unbound) (?) (unbound)

Search forward in the history for a specified string. The string may begin with `^^' to anchor the search to the beginning

of the line. The functions available in the mini-buffer are the

same as for vvii-hhiissttoorryy-sseeaarrcchh-bbaacckkwwaarrdd. Argument handling is

also the same as for that command.

iinnffeerr-nneexxtt-hhiissttoorryy (^X^N) (unbound) (unbound)

Search in the history list for a line matching the current one and fetch the event following it.

iinnsseerrtt-llaasstt-wwoorrdd (ESC- ESC-.) (unbound) (unbound)

Insert the last word from the previous history event at the cur-

sor 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 com-

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

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 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 his-

tory line examined by the previous execution of the command will be reexamined. Note that negative numbers should be preceded

with a `--' argument to avoid confusing them with options.

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.

If a third argument is given, its value is ignored, but it is

used to signify that the history offset is relative to the cur-

rent history line, rather than the one remembered after the pre-

vious invocations of iinnsseerrtt-llaasstt-wwoorrdd.

For example, the default behaviour of the command corresponds to

zzllee iinnsseerrtt-llaasstt-wwoorrdd -- -11 -11

while the command

zzllee iinnsseerrtt-llaasstt-wwoorrdd -- -11 11 -

always copies the first word of the line in the history immedi-

ately before the line being edited. This has the side effect that later invocations of the widget will be relative to that line.

vvii-rreeppeeaatt-sseeaarrcchh (unbound) (n) (unbound)

Repeat the last vi history search.

vvii-rreevv-rreeppeeaatt-sseeaarrcchh (unbound) (N) (unbound)

Repeat the last vi history search, but in reverse.

uupp-lliinnee-oorr-hhiissttoorryy (^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.

vvii-uupp-lliinnee-oorr-hhiissttoorryy (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.

uupp-lliinnee-oorr-sseeaarrcchh

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. If called from a function by the zzllee command with arguments, the first argument is taken as the string for which to search, rather than the first word in the buffer.

uupp-hhiissttoorryy (unbound) (^P) (unbound)

Move to the previous event in the history list.

hhiissttoorryy-bbeeggiinnnniinngg-sseeaarrcchh-ffoorrwwaarrdd

Search forward in the history for a line beginning with the cur-

rent line up to the cursor. This leaves the cursor in its orig-

inal position. MMooddiiffyyiinngg TTeexxtt

vvii-aadddd-eeooll (unbound) (A) (unbound)

Move to the end of the line and enter insert mode.

vvii-aadddd-nneexxtt (unbound) (a) (unbound)

Enter insert mode after the current cursor position, without changing lines.

bbaacckkwwaarrdd-ddeelleettee-cchhaarr (^H ^?) (unbound) (unbound)

Delete the character behind the cursor.

vvii-bbaacckkwwaarrdd-ddeelleettee-cchhaarr (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.

bbaacckkwwaarrdd-ddeelleettee-wwoorrdd

Delete the word behind the cursor.

bbaacckkwwaarrdd-kkiillll-lliinnee

Kill from the beginning of the line to the cursor position.

bbaacckkwwaarrdd-kkiillll-wwoorrdd (^W ESC-^H ESC-^?) (unbound) (unbound)

Kill the word behind the cursor.

vvii-bbaacckkwwaarrdd-kkiillll-wwoorrdd (unbound) (unbound) (^W)

Kill the word behind the cursor, without going past the point where insert mode was last entered.

ccaappiittaalliizzee-wwoorrdd (ESC-C ESC-c) (unbound) (unbound)

Capitalize the current word and move past it.

vvii-cchhaannggee (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 vvii-cchhaannggee, change the current

line.

vvii-cchhaannggee-eeooll (unbound) (C) (unbound)

Kill to the end of the line and enter insert mode.

vvii-cchhaannggee-wwhhoollee-lliinnee (unbound) (S) (unbound)

Kill the current line and enter insert mode.

ccooppyy-rreeggiioonn-aass-kkiillll (ESC-W ESC-w) (unbound) (unbound)

Copy the area from the cursor to the mark to the kill buffer.

ccooppyy-pprreevv-wwoorrdd (ESC-^) (unbound) (unbound)

Duplicate the word to the left of the cursor.

ccooppyy-pprreevv-sshheellll-wwoorrdd

Like ccooppyy-pprreevv-wwoorrdd, but the word is found by using shell pars-

ing, whereas ccooppyy-pprreevv-wwoorrdd looks for blanks. This makes a dif-

ference when the word is quoted and contains spaces.

vvii-ddeelleettee (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 vvii-ddeelleettee, kill the current line.

ddeelleettee-cchhaarr

Delete the character under the cursor.

vvii-ddeelleettee-cchhaarr (unbound) (x) (unbound)

Delete the character under the cursor, without going past the end of the line.

ddeelleettee-wwoorrdd

Delete the current word.

ddoowwnn-ccaassee-wwoorrdd (ESC-L ESC-l) (unbound) (unbound)

Convert the current word to all lowercase and move past it.

kkiillll-wwoorrdd (ESC-D ESC-d) (unbound) (unbound)

Kill the current word.

ggoossmmaaccss-ttrraannssppoossee-cchhaarrss

Exchange the two characters behind the cursor.

vvii-iinnddeenntt (unbound) (>) (unbound)

Indent a number of lines.

vvii-iinnsseerrtt (unbound) (i) (unbound)

Enter insert mode.

vvii-iinnsseerrtt-bbooll (unbound) (I) (unbound)

Move to the first non-blank character on the line and enter

insert mode.

vvii-jjooiinn (^X^J) (J) (unbound)

Join the current line with the next one.

kkiillll-lliinnee (^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.

vvii-kkiillll-lliinnee (unbound) (unbound) (^U)

Kill from the cursor back to wherever insert mode was last entered.

vvii-kkiillll-eeooll (unbound) (D) (unbound)

Kill from the cursor to the end of the line.

kkiillll-rreeggiioonn

Kill from the cursor to the mark.

kkiillll-bbuuffffeerr (^X^K) (unbound) (unbound)

Kill the entire buffer.

kkiillll-wwhhoollee-lliinnee (^U) (unbound) (unbound)

Kill the current line.

vvii-mmaattcchh-bbrraacckkeett (^X^B) (%) (unbound)

Move to the bracket character (one of {{}}, (()) or [[]]) 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.

vvii-ooppeenn-lliinnee-aabboovvee (unbound) (O) (unbound)

Open a line above the cursor and enter insert mode.

vvii-ooppeenn-lliinnee-bbeellooww (unbound) (o) (unbound)

Open a line below the cursor and enter insert mode.

vvii-ooppeerr-sswwaapp-ccaassee

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 vvii-ooppeerr-sswwaapp-ccaassee, swap

the case of all characters on the current line.

oovveerrwwrriittee-mmooddee (^X^O) (unbound) (unbound)

Toggle between overwrite mode and insert mode.

vvii-ppuutt-bbeeffoorree (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.

vvii-ppuutt-aafftteerr (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 charac-

ters), paste it below the current line.

qquuootteedd-iinnsseerrtt (^V) (unbound) (unbound)

Insert the next character typed into the buffer literally. An interrupt character will not be inserted.

vvii-qquuootteedd-iinnsseerrtt (unbound) (unbound) (^Q ^V)

Display a `^^' at the cursor position, and insert the next char-

acter typed into the buffer literally. An interrupt character will not be inserted.

qquuoottee-lliinnee (ESC-') (unbound) (unbound)

Quote the current line; that is, put a `''' character at the beginning and the end, and convert all `''' characters to `''\\'''''.

qquuoottee-rreeggiioonn (ESC-") (unbound) (unbound)

Quote the region from the cursor to the mark.

vvii-rreeppllaaccee (unbound) (R) (unbound)

Enter overwrite mode.

vvii-rreeppeeaatt-cchhaannggee (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 remem-

bered for future uses of this command. The cut buffer specifi-

cation is similarly remembered.

vvii-rreeppllaaccee-cchhaarrss (unbound) (r) (unbound)

Replace the character under the cursor with a character read from the keyboard.

sseellff-iinnsseerrtt (printable characters) (unbound) (printable characters and

some control characters) Insert a character into the buffer at the cursor position.

sseellff-iinnsseerrtt-uunnmmeettaa (ESC-^I ESC-^J ESC-^M) (unbound) (unbound)

Insert a character into the buffer after stripping the meta bit and converting ^M to ^J.

vvii-ssuubbssttiittuuttee (unbound) (s) (unbound)

Substitute the next character(s).

vvii-sswwaapp-ccaassee (unbound) (~) (unbound)

Swap the case of the character under the cursor and move past it.

ttrraannssppoossee-cchhaarrss (^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.

ttrraannssppoossee-wwoorrddss (ESC-T ESC-t) (unbound) (unbound)

Exchange the current word with the one before it.

vvii-uunniinnddeenntt (unbound) (<) (unbound)

Unindent a number of lines.

uupp-ccaassee-wwoorrdd (ESC-U ESC-u) (unbound) (unbound)

Convert the current word to all caps and move past it. yyaannkk (^Y) (unbound) (unbound) Insert the contents of the kill buffer at the cursor position.

yyaannkk-ppoopp (ESC-y) (unbound) (unbound)

Remove the text just yanked, rotate the kill-ring, and yank the

new top. Only works following yyaannkk or yyaannkk-ppoopp.

vvii-yyaannkk (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 vvii-yyaannkk, copy the current

line.

vvii-yyaannkk-wwhhoollee-lliinnee (unbound) (Y) (unbound)

Copy the current line into the kill buffer.

vvii-yyaannkk-eeooll

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

ddiiggiitt-aarrgguummeenntt (ESC-0..ESC-9) (1-9) (unbound)

Start a new numeric argument, or add to the current one. See

also vvii-ddiiggiitt-oorr-bbeeggiinnnniinngg-ooff-lliinnee. This only works if bound to

a key sequence ending in a decimal digit. Inside a widget function, a call to this function treats the last key of the key sequence which called the widget as the digit.

nneegg-aarrgguummeenntt (ESC-) (unbound) (unbound)

Changes the sign of the following argument.

uunniivveerrssaall-aarrgguummeenntt

Multiply the argument of the next command by 4. Alternatively,

if this command is followed by an integer (positive or nega-

tive), use that as the argument for the next command. Thus dig-

its cannot be repeated using this command. For example, if this

command occurs twice, followed immediately by ffoorrwwaarrdd-cchhaarr, move

forward sixteen spaces; if instead it is followed by -22, then

ffoorrwwaarrdd-cchhaarr, move backward two spaces.

Inside a widget function, if passed an argument, i.e. `zzllee uunnii-

vveerrssaall-aarrgguummeenntt num', the numerical argument will be set to num;

this is equivalent to `NNUUMMEERRIICC==num'. CCoommpplleettiioonn

aacccceepptt-aanndd-mmeennuu-ccoommpplleettee

In a menu completion, insert the current completion into the buffer, and advance to the next possible completion.

ccoommpplleettee-wwoorrdd

Attempt completion on the current word.

ddeelleettee-cchhaarr-oorr-lliisstt (^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.

eexxppaanndd-ccmmdd-ppaatthh

Expand the current command to its full pathname.

eexxppaanndd-oorr-ccoommpplleettee (TAB) (unbound) (TAB)

Attempt shell expansion on the current word. If that fails, attempt completion.

eexxppaanndd-oorr-ccoommpplleettee-pprreeffiixx

Attempt shell expansion on the current word up to cursor.

eexxppaanndd-hhiissttoorryy (ESC-space ESC-!) (unbound) (unbound)

Perform history expansion on the edit buffer.

eexxppaanndd-wwoorrdd (^X*) (unbound) (unbound)

Attempt shell expansion on the current word.

lliisstt-cchhooiicceess (ESC-^D) (^D =) (^D)

List possible completions for the current word.

lliisstt-eexxppaanndd (^Xg ^XG) (^G) (^G)

List the expansion of the current word.

mmaaggiicc-ssppaaccee

Perform history expansion and insert a space into the buffer. This is intended to be bound to space.

mmeennuu-ccoommpplleettee

Like ccoommpplleettee-wwoorrdd, except that menu completion is used. See

the MMEENNUUCCOOMMPPLLEETTEE option.

mmeennuu-eexxppaanndd-oorr-ccoommpplleettee

Like eexxppaanndd-oorr-ccoommpplleettee, except that menu completion is used.

rreevveerrssee-mmeennuu-ccoommpplleettee

Perform menu completion, like mmeennuu-ccoommpplleettee, except that if a

menu completion is already in progress, move to the previous completion rather than the next.

eenndd-ooff-lliisstt

When a previous completion displayed a list below the prompt, this widget can be used to move the prompt below the list. MMiisscceellllaanneeoouuss

aacccceepptt-aanndd-hhoolldd (ESC-A ESC-a) (unbound) (unbound)

Push the contents of the buffer on the buffer stack and execute it.

aacccceepptt-aanndd-iinnffeerr-nneexxtt-hhiissttoorryy

Execute the contents of the buffer. Then search the history

list for a line matching the current one and push the event fol-

lowing onto the buffer stack.

aacccceepptt-lliinnee (^J ^M) (^J ^M) (^J ^M)

Finish editing the buffer. Normally this causes the buffer to be executed as a shell command.

aacccceepptt-lliinnee-aanndd-ddoowwnn-hhiissttoorryy (^O) (unbound) (unbound)

Execute the current line, and push the next history event on the the buffer stack. bbeeeepp Beep, unless the BBEEEEPP option is unset.

vvii-ccmmdd-mmooddee (^X^V) (unbound) (^[)

Enter command mode; that is, select the `vviiccmmdd' keymap. Yes, this is bound by default in emacs mode.

vvii-ccaappss-lloocckk-ppaanniicc

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

cclleeaarr-ssccrreeeenn (^L ESC-^L) (^L) (^L)

Clear the screen and redraw the prompt.

ddeessccrriibbee-kkeeyy-bbrriieeffllyy

Reads a key sequence, then prints the function bound to that sequence.

eexxcchhaannggee-ppooiinntt-aanndd-mmaarrkk (^X^X) (unbound) (unbound)

Exchange the cursor position with the position of the mark.

eexxeeccuuttee-nnaammeedd-ccmmdd (ESC-x) (unbound) (unbound)

Read the name of an editor command and execute it. A restricted

set of editing functions is available in the mini-buffer. An

interrupt signal, as defined by the stty setting, will abort the

function. The allowed functions are: bbaacckkwwaarrdd-ddeelleettee-cchhaarr,

vvii-bbaacckkwwaarrdd-ddeelleettee-cchhaarr, cclleeaarr-ssccrreeeenn, rreeddiissppllaayy, qquuootteedd-iinnsseerrtt,

vvii-qquuootteedd-iinnsseerrtt, bbaacckkwwaarrdd-kkiillll-wwoorrdd, vvii-bbaacckkwwaarrdd-kkiillll-wwoorrdd,

kkiillll-wwhhoollee-lliinnee, vvii-kkiillll-lliinnee, bbaacckkwwaarrdd-kkiillll-lliinnee, lliisstt-cchhooiicceess,

ddeelleettee-cchhaarr-oorr-lliisstt, ccoommpplleettee-wwoorrdd, aacccceepptt-lliinnee, eexxppaanndd-oorr-ccoomm-

pplleettee and eexxppaanndd-oorr-ccoommpplleettee-pprreeffiixx.

kkiillll-rreeggiioonn 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 AAUUTTOOLLIISSTT option is set. Any other

character that is not bound to sseellff-iinnsseerrtt or sseellff-iinnsseerrtt-uunnmmeettaa

will beep and be ignored. The bindings of the current insert mode will be used.

eexxeeccuuttee-llaasstt-nnaammeedd-ccmmdd (ESC-z) (unbound) (unbound)

Redo the last function executed with eexxeeccuuttee-nnaammeedd-ccmmdd.

ggeett-lliinnee (ESC-G ESC-g) (unbound) (unbound)

Pop the top line off the buffer stack and insert it at the cur-

sor position.

ppoouunndd-iinnsseerrtt (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 IINNTTEERRAACCTTIIVVEECCOOMMMMEENNTTSS option must be set for this to have any usefulness.

vvii-ppoouunndd-iinnsseerrtt

If there is no # character at the beginning of the current line,

add one. If there is one, remove it. The IINNTTEERRAACCTTIIVVEECCOOMMMMEENNTTSS option must be set for this to have any usefulness.

ppuusshh-iinnppuutt

Push the entire current multiline construct onto the buffer

stack and return to the top-level (PPSS11) prompt. If the current

parser construct is only a single line, this is exactly like

ppuusshh-lliinnee. Next time the editor starts up or is popped with

ggeett-lliinnee, the construct will be popped off the top of the buffer

stack and loaded into the editing buffer.

ppuusshh-lliinnee (^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 edit-

ing buffer.

ppuusshh-lliinnee-oorr-eeddiitt

At the top-level (PPSS11) prompt, equivalent to ppuusshh-lliinnee. At a

secondary (PPSS22) prompt, move the entire current multiline con-

struct into the editor buffer. The latter is equivalent to

ppuusshh-iinnppuutt followed by ggeett-lliinnee.

rreeccuurrssiivvee-eeddiitt

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

aacccceepptt-lliinnee 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 com-

mand line or key bindings temporarily.

The following widget, ccaappss-lloocckk, serves as an example.

sseellff-iinnsseerrtt-uuccaassee(()) {{

LLBBUUFFFFEERR++==$${{((UU))KKEEYYSS[[-11]]}}

}} integer stat

zle -N self-insert self-insert-ucase

zle -A caps-lock save-caps-lock

zle -A accept-line caps-lock

zle recursive-edit

stat=$?

zle -A .self-insert self-insert

zle -A save-caps-lock caps-lock

zle -D save-caps-lock

(( stat )) && zle send-break

return $stat

This causes typed letters to be inserted capitalised until

either aacccceepptt-lliinnee (i.e. typically the return key) is typed or

the ccaappss-lloocckk widget is invoked again; the later is handled by

saving the old definition of ccaappss-lloocckk as ssaavvee-ccaappss-lloocckk and

then rebinding it to invoke aacccceepptt-lliinnee. Note that an error

from the recursive edit is detected as a non-zero return status

and propagated by using the sseenndd-bbrreeaakk widget.

rreeddiissppllaayy (unbound) (^R) (^R) Redisplays the edit buffer.

rreesseett-pprroommpptt (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). 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 com-

mand line to be reprinted.

sseenndd-bbrreeaakk (^G ESC-^G) (unbound) (unbound)

Abort the current editor function, e.g. eexxeeccuuttee-nnaammeedd-ccoommmmaanndd,

or the editor itself, e.g. if you are in vvaarreedd. Otherwise abort the parsing of the current line.

rruunn-hheellpp (ESC-H ESC-h) (unbound) (unbound)

Push the buffer onto the buffer stack, and execute the command

`rruunn-hheellpp cmd', where cmd is the current command. rruunn-hheellpp is

normally aliased to mmaann.

vvii-sseett-bbuuffffeerr (unbound) (") (unbound)

Specify a buffer to be used in the following command. There are 35 buffers that can be specified: the 26 `named' buffers ""aa to ""zz and the nine `queued' buffers ""11 to ""99. The named buffers can also be specified as ""AA to ""ZZ. 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. If no buffer is specified for a cut command, ""11 is used, and the

contents of ""11 to ""88 are each shifted along one buffer; the con-

tents of ""99 is lost.

vvii-sseett-mmaarrkk (unbound) (m) (unbound)

Set the specified mark at the cursor position.

sseett-mmaarrkk-ccoommmmaanndd (^@) (unbound) (unbound)

Set the mark at the cursor position.

ssppeellll-wwoorrdd (ESC-$ ESC-S ESC-s) (unbound) (unbound)

Attempt spelling correction on the current word.

uunnddeeffiinneedd-kkeeyy

This command is executed when a key sequence that is not bound to any command is typed. By default it beeps. uunnddoo (^ ^Xu ^X^U) (unbound) (unbound) Incrementally undo the last text modification. rreeddoo Incrementally redo undone text modifications.

vvii-uunnddoo-cchhaannggee (unbound) (u) (unbound)

Undo the last text modification. If repeated, redo the modifi-

cation.

wwhhaatt-ccuurrssoorr-ppoossiittiioonn (^X=) (unbound) (unbound)

Print the character under the cursor, its code as an octal, dec-

imal and hexadecimal number, the current cursor position within the buffer and the column of the cursor in the current line.

wwhheerree-iiss

Read the name of an editor command and and print the listing of key sequences that invoke the specified command.

wwhhiicchh-ccoommmmaanndd (ESC-?) (unbound) (unbound)

Push the buffer onto the buffer stack, and execute the command

`wwhhiicchh-ccoommmmaanndd cmd'. where cmd is the current command.

wwhhiicchh-ccoommmmaanndd is normally aliased to whence.

vvii-ddiiggiitt-oorr-bbeeggiinnnniinngg-ooff-lliinnee (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.

zsh 4.2.3 January 13, 2005 ZSHZLE(1)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™