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