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