]> git.ipfire.org Git - thirdparty/bash.git/blame - doc/readline.3
Imported from ../bash-2.02.tar.gz.
[thirdparty/bash.git] / doc / readline.3
CommitLineData
726f6388
JA
1.\"
2.\" MAN PAGE COMMENTS to
3.\"
4.\" Chet Ramey
5.\" Information Network Services
6.\" Case Western Reserve University
7.\" chet@ins.CWRU.Edu
8.\"
cce855bc 9.\" Last Change: Thu Feb 19 10:26:47 EST 1998
726f6388 10.\"
cce855bc 11.TH READLINE 3 "1998 Feb 19" GNU
726f6388
JA
12.\"
13.\" File Name macro. This used to be `.PN', for Path Name,
14.\" but Sun doesn't seem to like that very much.
15.\"
16.de FN
17\fI\|\\$1\|\fP
18..
19.SH NAME
20readline \- get a line from a user with editing
21.SH SYNOPSIS
22.LP
23.nf
24.ft B
25#include <readline.h>
26#include <history.h>
27.ft
28.fi
29.LP
30.nf
31.ft B
726f6388
JA
32char *readline (prompt)
33char *prompt;
34.ft
35.fi
726f6388 36.SH COPYRIGHT
ccc6cda3
JA
37.if n Readline is Copyright (C) 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc.
38.if t Readline is Copyright \(co 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc.
726f6388
JA
39.SH DESCRIPTION
40.LP
41.B readline
42will read a line from the terminal
43and return it, using
44.B prompt
45as a prompt. If
46.B prompt
47is null, no prompt is issued. The line returned is allocated with
48.IR malloc (3),
49so the caller must free it when finished. The line returned
50has the final newline removed, so only the text of the line
51remains.
52.LP
53.B readline
54offers editing capabilities while the user is entering the
55line.
56By default, the line editing commands
57are similar to those of emacs.
58A vi\-style line editing interface is also available.
726f6388
JA
59.SH RETURN VALUE
60.LP
61.B readline
62returns the text of the line read. A blank line
63returns the empty string. If
64.B EOF
65is encountered while reading a line, and the line is empty,
66.B NULL
67is returned. If an
68.B EOF
69is read with a non\-empty line, it is
70treated as a newline.
726f6388
JA
71.SH NOTATION
72.LP
ccc6cda3 73An emacs-style notation is used to denote
726f6388
JA
74keystrokes. Control keys are denoted by C\-\fIkey\fR, e.g., C\-n
75means Control\-N. Similarly,
76.I meta
77keys are denoted by M\-\fIkey\fR, so M\-x means Meta\-X. (On keyboards
78without a
79.I meta
80key, M\-\fIx\fP means ESC \fIx\fP, i.e., press the Escape key
81then the
82.I x
83key. This makes ESC the \fImeta prefix\fP.
84The combination M\-C\-\fIx\fP means ESC\-Control\-\fIx\fP,
85or press the Escape key
86then hold the Control key while pressing the
87.I x
88key.)
89.PP
90Readline commands may be given numeric
91.IR arguments ,
92which normally act as a repeat count. Sometimes, however, it is the
93sign of the argument that is significant. Passing a negative argument
94to a command that acts in the forward direction (e.g., \fBkill\-line\fP)
95causes that command to act in a backward direction. Commands whose
96behavior with arguments deviates from this are noted.
97.PP
98When a command is described as \fIkilling\fP text, the text
99deleted is saved for possible future retrieval
100(\fIyanking\fP). The killed text is saved in a
ccc6cda3 101\fIkill ring\fP. Consecutive kills cause the text to be
726f6388
JA
102accumulated into one unit, which can be yanked all at once.
103Commands which do not kill text separate the chunks of text
ccc6cda3 104on the kill ring.
726f6388
JA
105.SH INITIALIZATION FILE
106.LP
107Readline is customized by putting commands in an initialization
ccc6cda3
JA
108file (the \fIinputrc\fP file).
109The name of this file is taken from the value of the
726f6388 110.B INPUTRC
ccc6cda3 111environment variable. If that variable is unset, the default is
726f6388
JA
112.IR ~/.inputrc .
113When a program which uses the readline library starts up, the
114init file is read, and the key bindings and variables are set.
115There are only a few basic constructs allowed in the
116readline init file. Blank lines are ignored.
117Lines beginning with a \fB#\fP are comments.
ccc6cda3
JA
118Lines beginning with a \fB$\fP indicate conditional constructs.
119Other lines denote key bindings and variable settings.
726f6388
JA
120Each program using this library may add its own commands
121and bindings.
122.PP
123For example, placing
124.RS
125.PP
126M\-Control\-u: universal\-argument
127.RE
128or
129.RS
130C\-Meta\-u: universal\-argument
131.RE
132into the
ccc6cda3 133.I inputrc
726f6388
JA
134would make M\-C\-u execute the readline command
135.IR universal\-argument .
136.PP
137The following symbolic character names are recognized while
138processing key bindings:
139.IR RUBOUT ,
140.IR DEL ,
141.IR ESC ,
142.IR LFD ,
143.IR NEWLINE ,
144.IR RET ,
145.IR RETURN ,
146.IR SPC ,
147.IR SPACE ,
148and
149.IR TAB .
150In addition to command names, readline allows keys to be bound
151to a string that is inserted when the key is pressed (a \fImacro\fP).
152.PP
153.SS Key Bindings
154.PP
155The syntax for controlling key bindings in the
ccc6cda3 156.I inputrc
726f6388
JA
157file is simple. All that is required is the name of the
158command or the text of a macro and a key sequence to which
159it should be bound. The name may be specified in one of two ways:
160as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP
161prefixes, or as a key sequence.
cce855bc 162When using the form \fBkeyname\fP:\^\fIfunction-name\fP or \fImacro\fP,
726f6388
JA
163.I keyname
164is the name of a key spelled out in English. For example:
165.sp
166.RS
167Control\-u: universal\-argument
168.br
169Meta\-Rubout: backward\-kill\-word
170.br
171Control\-o: ">&output"
172.RE
173.LP
174In the above example,
175.I C\-u
176is bound to the function
177.BR universal\-argument ,
178.I M-DEL
179is bound to the function
180.BR backward\-kill\-word ,
181and
182.I C\-o
183is bound to run the macro
184expressed on the right hand side (that is, to insert the text
185.I >&output
186into the line).
187.PP
cce855bc 188In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP,
726f6388
JA
189.B keyseq
190differs from
191.B keyname
192above in that strings denoting
193an entire key sequence may be specified by placing the sequence
194within double quotes. Some GNU Emacs style key escapes can be
195used, as in the following example.
196.sp
197.RS
198"\eC\-u": universal\-argument
199.br
200"\eC\-x\eC\-r": re\-read\-init\-file
201.br
202"\ee[11~": "Function Key 1"
203.RE
204.PP
205In this example,
206.I C-u
207is again bound to the function
208.BR universal\-argument .
209.I "C-x C-r"
210is bound to the function
211.BR re\-read\-init\-file ,
212and
213.I "ESC [ 1 1 ~"
214is bound to insert the text
215.BR "Function Key 1" .
cce855bc 216The full set of GNU Emacs style escape sequences is
726f6388 217.RS
cce855bc 218.PD 0
726f6388 219.TP
ccc6cda3 220.B \eC\-
726f6388
JA
221control prefix
222.TP
ccc6cda3 223.B \eM\-
726f6388
JA
224meta prefix
225.TP
226.B \ee
227an escape character
228.TP
229.B \e\e
230backslash
231.TP
232.B \e"
233literal "
234.TP
235.B \e'
236literal '
237.RE
cce855bc
JA
238.PD
239.PP
240In addition to the GNU Emacs style escape sequences, a second
241set of backslash escapes is available:
242.RS
243.PD 0
244.TP
245.B \ea
246alert (bell)
247.TP
248.B \eb
249backspace
250.TP
251.B \ed
252delete
253.TP
254.B \ef
255form feed
256.TP
257.B \en
258newline
259.TP
260.B \er
261carriage return
262.TP
263.B \et
264horizontal tab
265.TP
266.B \ev
267vertical tab
268.TP
269.B \e\fInnn\fP
270the character whose ASCII code is the octal value \fInnn\fP
271(one to three digits)
272.TP
273.B \ex\fInnn\fP
274the character whose ASCII code is the hexadecimal value \fInnn\fP
275(one to three digits)
276.RE
277.PD
726f6388
JA
278.PP
279When entering the text of a macro, single or double quotes should
280be used to indicate a macro definition. Unquoted text
cce855bc
JA
281is assumed to be a function name.
282In the macro body, the backslash escapes described above are expanded.
283Backslash will quote any other character in the macro text,
284including " and '.
726f6388
JA
285.PP
286.B Bash
287allows the current readline key bindings to be displayed or modified
288with the
289.B bind
290builtin command. The editing mode may be switched during interactive
291use by using the
292.B \-o
293option to the
294.B set
295builtin command. Other programs using this library provide
296similar mechanisms. The
297.I inputrc
ccc6cda3 298file may be edited and re-read if a program does not provide
726f6388
JA
299any other means to incorporate new bindings.
300.SS Variables
301.PP
302Readline has variables that can be used to further customize its
303behavior. A variable may be set in the
304.I inputrc
305file with a statement of the form
306.RS
307.PP
308\fBset\fP \fIvariable\-name\fP \fIvalue\fP
309.RE
310.PP
311Except where noted, readline variables can take the values
312.B On
313or
314.BR Off .
315The variables and their default values are:
316.PP
317.PD 0
318.TP
726f6388
JA
319.B bell\-style (audible)
320Controls what happens when readline wants to ring the terminal bell.
321If set to \fBnone\fP, readline never rings the bell. If set to
322\fBvisible\fP, readline uses a visible bell if one is available.
323If set to \fBaudible\fP, readline attempts to ring the terminal's bell.
324.TP
325.B comment\-begin (``#'')
326The string that is inserted in \fBvi\fP mode when the
ccc6cda3 327.B insert\-comment
726f6388 328command is executed.
ccc6cda3
JA
329This command is bound to
330.B M\-#
331in emacs mode and to
332.B #
333in vi command mode.
cce855bc
JA
334.TP
335.B completion\-ignore\-case (Off)
336If set to \fBOn\fP, readline performs filename matching and completion
337in a case\-insensitive fashion.
726f6388
JA
338.TP
339.B completion\-query\-items (100)
340This determines when the user is queried about viewing
341the number of possible completions
342generated by the \fBpossible\-completions\fP command.
343It may be set to any integer value greater than or equal to
344zero. If the number of possible completions is greater than
345or equal to the value of this variable, the user is asked whether
346or not he wishes to view them; otherwise they are simply listed
347on the terminal.
348.TP
ccc6cda3
JA
349.B convert\-meta (On)
350If set to \fBOn\fP, readline will convert characters with the
351eighth bit set to an ASCII key sequence
352by stripping the eighth bit and prepending an
353escape character (in effect, using escape as the \fImeta prefix\fP).
354.TP
355.B disable\-completion (Off)
356If set to \fBOn\fP, readline will inhibit word completion. Completion
357characters will be inserted into the line as if they had been
358mapped to \fBself-insert\fP.
359.TP
360.B editing\-mode (emacs)
361Controls whether readline begins with a set of key bindings similar
362to \fIemacs\fP or \fIvi\fP.
363.B editing\-mode
364can be set to either
365.B emacs
366or
367.BR vi .
368.TP
369.B enable\-keypad (Off)
370When set to \fBOn\fP, readline will try to enable the application
371keypad when it is called. Some systems need this to enable the
372arrow keys.
373.TP
374.B expand\-tilde (Off)
375If set to \fBon\fP, tilde expansion is performed when readline
376attempts word completion.
377.TP
378.B horizontal\-scroll\-mode (Off)
379When set to \fBOn\fP, makes readline use a single line for display,
380scrolling the input horizontally on a single screen line when it
381becomes longer than the screen width rather than wrapping to a new line.
382.TP
726f6388
JA
383.B keymap (emacs)
384Set the current readline keymap. The set of legal keymap names is
385\fIemacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move,
386vi-command\fP, and
387.IR vi-insert .
388\fIvi\fP is equivalent to \fIvi-command\fP; \fIemacs\fP is
389equivalent to \fIemacs-standard\fP. The default value is
390.IR emacs ;
391the value of
392.B editing\-mode
393also affects the default keymap.
394.TP
ccc6cda3 395.B mark\-directories (On)
cce855bc 396If set to \fBOn\fP, complete<d directory names have a slash
ccc6cda3
JA
397appended.
398.TP
399.B mark\-modified\-lines (Off)
400If set to \fBOn\fP, history lines that have been modified are displayed
401with a preceding asterisk (\fB*\fP).
402.TP
403.B meta\-flag (Off)
404If set to \fBOn\fP, readline will enable eight-bit input (that is,
405it will not strip the high bit from the characters it reads),
406regardless of what the terminal claims it can support.
407.TP
408.B output\-meta (Off)
409If set to \fBOn\fP, readline will display characters with the
410eighth bit set directly rather than as a meta-prefixed escape
411sequence.
412.TP
cce855bc
JA
413.B print\-completions\-horizontally (Off)
414If set to \fBOn\fP, readline will display completions with matches
415sorted horizontally in alphabetical order, rather than down the screen.
416.TP
726f6388
JA
417.B show\-all\-if\-ambiguous (Off)
418This alters the default behavior of the completion functions. If
419set to
420.BR on ,
421words which have more than one possible completion cause the
422matches to be listed immediately instead of ringing the bell.
423.TP
ccc6cda3
JA
424.B visible\-stats (Off)
425If set to \fBOn\fP, a character denoting a file's type as reported
426by \fBstat\fP(2) is appended to the filename when listing possible
427completions.
726f6388
JA
428.PD
429.SS Conditional Constructs
430.PP
431Readline implements a facility similar in spirit to the conditional
432compilation features of the C preprocessor which allows key
433bindings and variable settings to be performed as the result
cce855bc 434of tests. There are four parser directives used.
726f6388
JA
435.IP \fB$if\fP
436The
437.B $if
438construct allows bindings to be made based on the
439editing mode, the terminal being used, or the application using
440readline. The text of the test extends to the end of the line;
441no characters are required to isolate it.
442.RS
443.IP \fBmode\fP
444The \fBmode=\fP form of the \fB$if\fP directive is used to test
445whether readline is in emacs or vi mode.
446This may be used in conjunction
447with the \fBset keymap\fP command, for instance, to set bindings in
448the \fIemacs-standard\fP and \fIemacs-ctlx\fP keymaps only if
449readline is starting out in emacs mode.
450.IP \fBterm\fP
451The \fBterm=\fP form may be used to include terminal-specific
452key bindings, perhaps to bind the key sequences output by the
453terminal's function keys. The word on the right side of the
454.B =
455is tested against the full name of the terminal and the portion
456of the terminal name before the first \fB\-\fP. This allows
457.I sun
458to match both
459.I sun
460and
461.IR sun\-cmd ,
462for instance.
463.IP \fBapplication\fP
464The \fBapplication\fP construct is used to include
ccc6cda3 465application-specific settings. Each program using the readline
726f6388
JA
466library sets the \fIapplication name\fP, and an initialization
467file can test for a particular value.
468This could be used to bind key sequences to functions useful for
469a specific program. For instance, the following command adds a
470key sequence that quotes the current or previous word in Bash:
cce855bc 471.sp 1
726f6388
JA
472.RS
473.nf
474\fB$if\fP bash
475# Quote the current or previous word
476"\eC-xq": "\eeb\e"\eef\e""
477\fB$endif\fP
478.fi
479.RE
480.RE
481.IP \fB$endif\fP
cce855bc 482This command, as seen in the previous example, terminates an
726f6388
JA
483\fB$if\fP command.
484.IP \fB$else\fP
485Commands in this branch of the \fB$if\fP directive are executed if
486the test fails.
cce855bc
JA
487.IP \fB$include\fP
488This directive takes a single filename as an argument and reads commands
489and bindings from that file. For example, the following directive
490would read \fI/etc/inputrc\fP:
491.sp 1
492.RS
493.nf
494\fB$include\fP \^ \fI/etc/inputrc\fP
495.fi
496.RE
ccc6cda3
JA
497.SH SEARCHING
498.PP
499Readline provides commands for searching through the command history
500for lines containing a specified string.
501There are two search modes:
502.I incremental
503and
504.IR non-incremental .
505.PP
506Incremental searches begin before the user has finished typing the
507search string.
508As each character of the search string is typed, readline displays
509the next entry from the history matching the string typed so far.
510An incremental search requires only as many characters as needed to
511find the desired history entry.
512The Escape character is used to terminate an incremental search.
513Control-J will also terminate the search.
514Control-G will abort an incremental search and restore the original
515line.
516When the search is terminated, the history entry containing the
517search string becomes the current line.
518To find other matching entries in the history list, type Control-S or
519Control-R as appropriate.
520This will search backward or forward in the history for the next
521line matching the search string typed so far.
522Any other key sequence bound to a readline command will terminate
523the search and execute that command.
524For instance, a \fInewline\fP will terminate the search and accept
525the line, thereby executing the command from the history list.
526.PP
527Non-incremental searches read the entire search string before starting
528to search for matching history lines. The search string may be
cce855bc 529typed by the user or be part of the contents of the current line.
726f6388
JA
530.SH EDITING COMMANDS
531.PP
532The following is a list of the names of the commands and the default
533key sequences to which they are bound.
ccc6cda3 534Command names without an accompanying key sequence are unbound by default.
726f6388
JA
535.SS Commands for Moving
536.PP
537.PD 0
538.TP
539.B beginning\-of\-line (C\-a)
540Move to the start of the current line.
541.TP
542.B end\-of\-line (C\-e)
543Move to the end of the line.
544.TP
545.B forward\-char (C\-f)
546Move forward a character.
547.TP
548.B backward\-char (C\-b)
549Move back a character.
550.TP
551.B forward\-word (M\-f)
552Move forward to the end of the next word. Words are composed of
553alphanumeric characters (letters and digits).
554.TP
555.B backward\-word (M\-b)
556Move back to the start of this, or the previous, word. Words are
557composed of alphanumeric characters (letters and digits).
558.TP
559.B clear\-screen (C\-l)
560Clear the screen leaving the current line at the top of the screen.
561With an argument, refresh the current line without clearing the
562screen.
563.TP
564.B redraw\-current\-line
ccc6cda3 565Refresh the current line.
726f6388
JA
566.PD
567.SS Commands for Manipulating the History
568.PP
569.PD 0
570.TP
571.B accept\-line (Newline, Return)
572Accept the line regardless of where the cursor is. If this line is
ccc6cda3 573non-empty, add it to the history list. If the line is a modified
726f6388
JA
574history line, then restore the history line to its original state.
575.TP
576.B previous\-history (C\-p)
577Fetch the previous command from the history list, moving back in
578the list.
579.TP
580.B next\-history (C\-n)
581Fetch the next command from the history list, moving forward in the
582list.
583.TP
584.B beginning\-of\-history (M\-<)
585Move to the first line in the history.
586.TP
587.B end\-of\-history (M\->)
588Move to the end of the input history, i.e., the line currently being
589entered.
590.TP
591.B reverse\-search\-history (C\-r)
592Search backward starting at the current line and moving `up' through
593the history as necessary. This is an incremental search.
594.TP
595.B forward\-search\-history (C\-s)
596Search forward starting at the current line and moving `down' through
597the history as necessary. This is an incremental search.
598.TP
599.B non\-incremental\-reverse\-search\-history (M\-p)
600Search backward through the history starting at the current line
ccc6cda3 601using a non-incremental search for a string supplied by the user.
726f6388
JA
602.TP
603.B non\-incremental\-forward\-search\-history (M\-n)
ccc6cda3 604Search forward through the history using a non-incremental search
726f6388
JA
605for a string supplied by the user.
606.TP
607.B history\-search\-forward
608Search forward through the history for the string of characters
ccc6cda3
JA
609between the start of the current line and the current cursor
610position (the \fIpoint\fP).
611This is a non-incremental search.
726f6388
JA
612.TP
613.B history\-search\-backward
614Search backward through the history for the string of characters
ccc6cda3
JA
615between the start of the current line and the point.
616This is a non-incremental search.
726f6388
JA
617.TP
618.B yank\-nth\-arg (M\-C\-y)
619Insert the first argument to the previous command (usually
620the second word on the previous line) at point (the current
621cursor position). With an argument
622.IR n ,
623insert the \fIn\fPth word from the previous command (the words
624in the previous command begin with word 0). A negative argument
625inserts the \fIn\fPth word from the end of the previous command.
626.TP
627.B
628yank\-last\-arg (M\-.\^, M\-_\^)
ccc6cda3
JA
629Insert the last argument to the previous command (the last word of
630the previous history entry). With an argument,
631behave exactly like \fByank\-nth\-arg\fP.
cce855bc
JA
632Successive calls to \fByank\-last\-arg\fP move back through the history
633list, inserting the last argument of each line in turn.
726f6388
JA
634.PD
635.SS Commands for Changing Text
636.PP
637.PD 0
638.TP
639.B delete\-char (C\-d)
640Delete the character under the cursor. If point is at the
641beginning of the line, there are no characters in the line, and
cce855bc 642the last character typed was not bound to \fBBdelete\-char\fP, then return
726f6388
JA
643.SM
644.BR EOF .
645.TP
646.B backward\-delete\-char (Rubout)
647Delete the character behind the cursor. When given a numeric argument,
ccc6cda3 648save the deleted text on the kill ring.
726f6388
JA
649.TP
650.B quoted\-insert (C\-q, C\-v)
651Add the next character that you type to the line verbatim. This is
652how to insert characters like \fBC\-q\fP, for example.
653.TP
654.B tab\-insert (M-TAB)
655Insert a tab character.
656.TP
657.B self\-insert (a,\ b,\ A,\ 1,\ !,\ ...)
658Insert the character typed.
659.TP
660.B transpose\-chars (C\-t)
661Drag the character before point forward over the character at point.
662Point moves forward as well. If point is at the end of the line, then
663transpose the two characters before point. Negative arguments don't work.
664.TP
665.B transpose\-words (M\-t)
666Drag the word behind the cursor past the word in front of the cursor
667moving the cursor over that word as well.
668.TP
669.B upcase\-word (M\-u)
670Uppercase the current (or following) word. With a negative argument,
cce855bc 671uppercase the previous word, but do not move point.
726f6388
JA
672.TP
673.B downcase\-word (M\-l)
674Lowercase the current (or following) word. With a negative argument,
cce855bc 675lowercase the previous word, but do not move point.
726f6388
JA
676.TP
677.B capitalize\-word (M\-c)
678Capitalize the current (or following) word. With a negative argument,
cce855bc 679capitalize the previous word, but do not move point.
726f6388
JA
680.PD
681.SS Killing and Yanking
682.PP
683.PD 0
684.TP
685.B kill\-line (C\-k)
686Kill the text from the current cursor position to the end of the line.
687.TP
688.B backward\-kill\-line (C\-x Rubout)
689Kill backward to the beginning of the line.
690.TP
691.B unix\-line\-discard (C\-u)
692Kill backward from point to the beginning of the line.
cce855bc 693The killed text is saved on the kill-ring.
726f6388
JA
694.\" There is no real difference between this and backward-kill-line
695.TP
696.B kill\-whole\-line
697Kill all characters on the current line, no matter where the
ccc6cda3 698cursor is.
726f6388
JA
699.TP
700.B kill\-word (M\-d)
701Kill from the cursor to the end of the current word, or if between
702words, to the end of the next word. Word boundaries are the same as
703those used by \fBforward\-word\fP.
704.TP
705.B backward\-kill\-word (M\-Rubout)
706Kill the word behind the cursor. Word boundaries are the same as
707those used by \fBbackward\-word\fP.
708.TP
709.B unix\-word\-rubout (C\-w)
710Kill the word behind the cursor, using white space as a word boundary.
711The word boundaries are different from
712.BR backward\-kill\-word .
713.TP
ccc6cda3
JA
714.B delete\-horizontal\-space (M\-\e)
715Delete all spaces and tabs around point.
716.TP
717.B kill\-region
718Kill the text between the point and \fImark\fP (saved cursor position).
719This text is referred to as the \fIregion\fP.
720.TP
721.B copy\-region\-as\-kill
722Copy the text in the region to the kill buffer.
723.TP
724.B copy\-backward\-word
725Copy the word before point to the kill buffer.
cce855bc 726The word boundaries are the same as \fBbackward\-word\fP.
ccc6cda3
JA
727.TP
728.B copy\-forward\-word
729Copy the word following point to the kill buffer.
cce855bc 730The word boundaries are the same as \fBforward\-word\fP.
726f6388
JA
731.TP
732.B yank (C\-y)
733Yank the top of the kill ring into the buffer at the cursor.
734.TP
735.B yank\-pop (M\-y)
ccc6cda3 736Rotate the kill ring, and yank the new top. Only works following
726f6388
JA
737.B yank
738or
739.BR yank\-pop .
740.PD
741.SS Numeric Arguments
742.PP
743.PD 0
744.TP
745.B digit\-argument (M\-0, M\-1, ..., M\-\-)
746Add this digit to the argument already accumulating, or start a new
747argument. M\-\- starts a negative argument.
748.TP
749.B universal\-argument
d166f048
JA
750This is another way to specify an argument.
751If this command is followed by one or more digits, optionally with a
752leading minus sign, those digits define the argument.
753If the command is followed by digits, executing
754.B universal\-argument
755again ends the numeric argument, but is otherwise ignored.
756As a special case, if this command is immediately followed by a
757character that is neither a digit or minus sign, the argument count
758for the next command is multiplied by four.
726f6388 759The argument count is initially one, so executing this function the
d166f048
JA
760first time makes the argument count four, a second time makes the
761argument count sixteen, and so on.
726f6388
JA
762.PD
763.SS Completing
764.PP
765.PD 0
766.TP
767.B complete (TAB)
768Attempt to perform completion on the text before point.
769The actual completion performed is application-specific.
770.BR Bash ,
771for instance, attempts completion treating the text as a variable
772(if the text begins with \fB$\fP), username (if the text begins with
773\fB~\fP), hostname (if the text begins with \fB@\fP), or
774command (including aliases and functions) in turn. If none
775of these produces a match, filename completion is attempted.
776.BR Gdb ,
777on the other hand,
778allows completion of program functions and variables, and
779only attempts filename completion under certain circumstances.
780.TP
ccc6cda3 781.B possible\-completions (M\-?)
726f6388
JA
782List the possible completions of the text before point.
783.TP
ccc6cda3 784.B insert\-completions (M\-*)
726f6388
JA
785Insert all completions of the text before point
786that would have been generated by
ccc6cda3 787\fBpossible\-completions\fP.
cce855bc
JA
788.TP
789.B menu\-complete
790Similar to \fBcomplete\fP, but replaces the word to be completed
791with a single match from the list of possible completions.
792Repeated execution of \fBmenu\-complete\fP steps through the list
793of possible completions, inserting each match in turn.
794At the end of the list of completions, the bell is rung and the
795original text is restored.
796An argument of \fIn\fP moves \fIn\fP positions forward in the list
797of matches; a negative argument may be used to move backward
798through the list.
799This command is intended to be bound to \fBTAB\fP, but is unbound
800by default.
726f6388
JA
801.PD
802.SS Keyboard Macros
803.PP
804.PD 0
805.TP
ccc6cda3 806.B start\-kbd\-macro (C\-x (\^)
726f6388
JA
807Begin saving the characters typed into the current keyboard macro.
808.TP
ccc6cda3 809.B end\-kbd\-macro (C\-x )\^)
726f6388 810Stop saving the characters typed into the current keyboard macro
ccc6cda3 811and store the definition.
726f6388 812.TP
ccc6cda3 813.B call\-last\-kbd\-macro (C\-x e)
726f6388
JA
814Re-execute the last keyboard macro defined, by making the characters
815in the macro appear as if typed at the keyboard.
816.PD
817.SS Miscellaneous
818.PP
819.PD 0
820.TP
ccc6cda3
JA
821.B re\-read\-init\-file (C\-x C\-r)
822Read in the contents of the \fIinputrc\fP file, and incorporate
726f6388
JA
823any bindings or variable assignments found there.
824.TP
825.B abort (C\-g)
826Abort the current editing command and
827ring the terminal's bell (subject to the setting of
828.BR bell\-style ).
829.TP
ccc6cda3
JA
830.B do\-uppercase\-version (M\-a, M\-b, M\-\fIx\fP, ...)
831If the metafied character \fIx\fP is lowercase, run the command
832that is bound to the corresponding uppercase character.
726f6388
JA
833.TP
834.B prefix\-meta (ESC)
835Metafy the next character typed.
836.SM
837.B ESC
838.B f
839is equivalent to
840.BR Meta\-f .
841.TP
842.B undo (C\-_, C\-x C\-u)
843Incremental undo, separately remembered for each line.
844.TP
845.B revert\-line (M\-r)
cce855bc 846Undo all changes made to this line. This is like executing the
726f6388
JA
847.B undo
848command enough times to return the line to its initial state.
849.TP
850.B tilde\-expand (M\-~)
851Perform tilde expansion on the current word.
852.TP
ccc6cda3
JA
853.B set\-mark (C\-@, M-<space>)
854Set the mark to the current point. If a
855numeric argument is supplied, the mark is set to that position.
856.TP
857.B exchange\-point\-and\-mark (C\-x C\-x)
858Swap the point with the mark. The current cursor position is set to
859the saved position, and the old cursor position is saved as the mark.
860.TP
861.B character\-search (C\-])
862A character is read and point is moved to the next occurrence of that
863character. A negative count searches for previous occurrences.
864.TP
865.B character\-search\-backward (M\-C\-])
866A character is read and point is moved to the previous occurrence of that
867character. A negative count searches for subsequent occurrences.
868.TP
869.B insert\-comment (M\-#)
870The value of the readline
871.B comment\-begin
872variable is inserted at the beginning of the current line, and the line
873is accepted as if a newline had been typed. This makes the current line
874a shell comment.
875.TP
726f6388
JA
876.B dump\-functions
877Print all of the functions and their key bindings to the
878readline output stream. If a numeric argument is supplied,
879the output is formatted in such a way that it can be made part
880of an \fIinputrc\fP file.
881.TP
ccc6cda3
JA
882.B dump\-variables
883Print all of the settable variables and their values to the
884readline output stream. If a numeric argument is supplied,
885the output is formatted in such a way that it can be made part
886of an \fIinputrc\fP file.
887.TP
888.B dump\-macros
889Print all of the readline key sequences bound to macros and the
890strings they ouput. If a numeric argument is supplied,
891the output is formatted in such a way that it can be made part
892of an \fIinputrc\fP file.
893.TP
726f6388
JA
894.B emacs\-editing\-mode (C\-e)
895When in
896.B vi
897editing mode, this causes a switch to
898.B emacs
899editing mode.
900.TP
901.B vi\-editing\-mode (M\-C\-j)
902When in
903.B emacs
904editing mode, this causes a switch to
905.B vi
906editing mode.
907.PD
908.SH DEFAULT KEY BINDINGS
909.LP
910The following is a list of the default emacs and vi bindings.
ccc6cda3 911Characters with the 8th bit set are written as M\-<character>, and
726f6388
JA
912are referred to as
913.I metafied
914characters.
915The printable ASCII characters not mentioned in the list of emacs
916standard bindings are bound to the
917.I self\-insert
918function, which just inserts the given character into the input line.
919In vi insertion mode, all characters not specifically mentioned are
920bound to
921.IR self\-insert .
922Characters assigned to signal generation by
923.IR stty (1)
924or the terminal driver, such as C-Z or C-C,
925retain that function.
926Upper and lower case
927.I metafied
928characters are bound to the same function in the emacs mode
929meta keymap.
930The remaining characters are unbound, which causes readline
931to ring the bell (subject to the setting of the
932.B bell\-style
933variable).
934.SS Emacs Mode
935.RS +.6i
936.nf
937.ta 2.5i
938.sp
939Emacs Standard bindings
940.sp
ccc6cda3
JA
941"C-@" set-mark
942"C-A" beginning-of-line
943"C-B" backward-char
944"C-D" delete-char
945"C-E" end-of-line
946"C-F" forward-char
947"C-G" abort
948"C-H" backward-delete-char
949"C-I" complete
950"C-J" accept-line
951"C-K" kill-line
952"C-L" clear-screen
953"C-M" accept-line
954"C-N" next-history
955"C-P" previous-history
956"C-Q" quoted-insert
957"C-R" reverse-search-history
958"C-S" forward-search-history
959"C-T" transpose-chars
960"C-U" unix-line-discard
961"C-V" quoted-insert
962"C-W" unix-word-rubout
963"C-Y" yank
964"C-]" character-search
965"C-_" undo
966"\^ " to "/" self-insert
967"0" to "9" self-insert
968":" to "~" self-insert
969"C-?" backward-delete-char
726f6388
JA
970.PP
971Emacs Meta bindings
972.sp
ccc6cda3
JA
973"M-C-G" abort
974"M-C-H" backward-kill-word
975"M-C-I" tab-insert
976"M-C-J" vi-editing-mode
977"M-C-M" vi-editing-mode
978"M-C-R" revert-line
979"M-C-Y" yank-nth-arg
980"M-C-[" complete
981"M-C-]" character-search-backward
982"M-space" set-mark
983"M-#" insert-comment
984"M-&" tilde-expand
985"M-*" insert-completions
986"M--" digit-argument
987"M-." yank-last-arg
988"M-0" digit-argument
989"M-1" digit-argument
990"M-2" digit-argument
991"M-3" digit-argument
992"M-4" digit-argument
993"M-5" digit-argument
994"M-6" digit-argument
995"M-7" digit-argument
996"M-8" digit-argument
997"M-9" digit-argument
998"M-<" beginning-of-history
999"M-=" possible-completions
1000"M->" end-of-history
1001"M-?" possible-completions
1002"M-B" backward-word
1003"M-C" capitalize-word
1004"M-D" kill-word
1005"M-F" forward-word
1006"M-L" downcase-word
1007"M-N" non-incremental-forward-search-history
1008"M-P" non-incremental-reverse-search-history
1009"M-R" revert-line
1010"M-T" transpose-words
1011"M-U" upcase-word
1012"M-Y" yank-pop
1013"M-\e" delete-horizontal-space
1014"M-~" tilde-expand
1015"M-C-?" backward-delete-word
1016"M-_" yank-last-arg
726f6388
JA
1017.PP
1018Emacs Control-X bindings
1019.sp
ccc6cda3
JA
1020"C-XC-G" abort
1021"C-XC-R" re-read-init-file
1022"C-XC-U" undo
1023"C-XC-X" exchange-point-and-mark
1024"C-X(" start-kbd-macro
1025"C-X)" end-kbd-macro
1026"C-XE" call-last-kbd-macro
1027"C-XC-?" backward-kill-line
726f6388
JA
1028.sp
1029.RE
1030.SS VI Mode bindings
1031.RS +.6i
1032.nf
1033.ta 2.5i
1034.sp
1035.PP
1036VI Insert Mode functions
1037.sp
ccc6cda3
JA
1038"C-D" vi-eof-maybe
1039"C-H" backward-delete-char
1040"C-I" complete
1041"C-J" accept-line
1042"C-M" accept-line
1043"C-R" reverse-search-history
1044"C-S" forward-search-history
1045"C-T" transpose-chars
1046"C-U" unix-line-discard
1047"C-V" quoted-insert
1048"C-W" unix-word-rubout
1049"C-Y" yank
1050"C-[" vi-movement-mode
1051"C-_" undo
1052"\^ " to "~" self-insert
1053"C-?" backward-delete-char
726f6388
JA
1054.PP
1055VI Command Mode functions
1056.sp
ccc6cda3
JA
1057"C-D" vi-eof-maybe
1058"C-E" emacs-editing-mode
1059"C-G" abort
1060"C-H" backward-char
1061"C-J" accept-line
1062"C-K" kill-line
1063"C-L" clear-screen
1064"C-M" accept-line
1065"C-N" next-history
1066"C-P" previous-history
1067"C-Q" quoted-insert
1068"C-R" reverse-search-history
1069"C-S" forward-search-history
1070"C-T" transpose-chars
1071"C-U" unix-line-discard
1072"C-V" quoted-insert
1073"C-W" unix-word-rubout
1074"C-Y" yank
1075"\^ " forward-char
1076"#" insert-comment
1077"$" end-of-line
1078"%" vi-match
1079"&" vi-tilde-expand
1080"*" vi-complete
1081"+" next-history
1082"," vi-char-search
1083"-" previous-history
1084"." vi-redo
1085"/" vi-search
1086"0" beginning-of-line
1087"1" to "9" vi-arg-digit
1088";" vi-char-search
1089"=" vi-complete
1090"?" vi-search
1091"A" vi-append-eol
1092"B" vi-prev-word
1093"C" vi-change-to
1094"D" vi-delete-to
1095"E" vi-end-word
1096"F" vi-char-search
1097"G" vi-fetch-history
1098"I" vi-insert-beg
1099"N" vi-search-again
1100"P" vi-put
1101"R" vi-replace
1102"S" vi-subst
1103"T" vi-char-search
1104"U" revert-line
1105"W" vi-next-word
1106"X" backward-delete-char
1107"Y" vi-yank-to
1108"\e" vi-complete
1109"^" vi-first-print
1110"_" vi-yank-arg
1111"`" vi-goto-mark
1112"a" vi-append-mode
1113"b" vi-prev-word
1114"c" vi-change-to
1115"d" vi-delete-to
1116"e" vi-end-word
1117"f" vi-char-search
1118"h" backward-char
1119"i" vi-insertion-mode
1120"j" next-history
1121"k" prev-history
1122"l" forward-char
1123"m" vi-set-mark
1124"n" vi-search-again
1125"p" vi-put
1126"r" vi-change-char
1127"s" vi-subst
1128"t" vi-char-search
1129"u" undo
1130"w" vi-next-word
1131"x" vi-delete
1132"y" vi-yank-to
1133"|" vi-column
1134"~" vi-change-case
726f6388
JA
1135.RE
1136.SH "SEE ALSO"
1137.PD 0
1138.TP
1139\fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey
1140.TP
1141\fIThe Gnu History Library\fP, Brian Fox and Chet Ramey
1142.TP
1143\fIbash\fP(1)
1144.PD
1145.SH FILES
1146.PD 0
1147.TP
1148.FN ~/.inputrc
1149Individual \fBreadline\fP initialization file
1150.PD
1151.SH AUTHORS
726f6388
JA
1152Brian Fox, Free Software Foundation (primary author)
1153.br
1154bfox@ai.MIT.Edu
1155.PP
1156Chet Ramey, Case Western Reserve University
1157.br
1158chet@ins.CWRU.Edu
1159.SH BUG REPORTS
1160If you find a bug in
1161.B readline,
1162you should report it. But first, you should
1163make sure that it really is a bug, and that it appears in the latest
1164version of the
1165.B readline
1166library that you have.
1167.PP
1168Once you have determined that a bug actually exists, mail a
cce855bc 1169bug report to \fIbug\-readline\fP@\fIgnu.org\fP.
726f6388
JA
1170If you have a fix, you are welcome to mail that
1171as well! Suggestions and `philosophical' bug reports may be mailed
cce855bc 1172to \fPbug-readline\fP@\fIgnu.org\fP or posted to the Usenet
726f6388
JA
1173newsgroup
1174.BR gnu.bash.bug .
1175.PP
1176Comments and bug reports concerning
1177this manual page should be directed to
1178.IR chet@ins.CWRU.Edu .
1179.SH BUGS
1180.PP
1181It's too big and too slow.