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