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