2 .\" MAN PAGE COMMENTS to
5 .\" Information Network Services
6 .\" Case Western Reserve University
7 .\" chet.ramey@case.edu
9 .\" Last Change: Tue Mar 24 09:27:30 EDT 2020
11 .TH READLINE 3 "2020 October 29" "GNU Readline 8.1"
13 .\" File Name macro. This used to be `.PN', for Path Name,
14 .\" but Sun doesn't seem to like that very much.
20 readline \- get a line from a user with editing
26 #include <readline/readline.h>
27 #include <readline/history.h>
34 \fBreadline\fP (\fIconst char *prompt\fP);
37 .if n Readline is Copyright (C) 1989\-2020 Free Software Foundation, Inc.
38 .if t Readline is Copyright \(co 1989\-2020 Free Software Foundation, Inc.
42 will read a line from the terminal
47 is \fBNULL\fP or the empty string, no prompt is issued.
48 The line returned is allocated with
50 the caller must free it when finished. The line returned
51 has the final newline removed, so only the text of the line
55 offers editing capabilities while the user is entering the
57 By default, the line editing commands
58 are similar to those of emacs.
59 A vi\-style line editing interface is also available.
61 This manual page describes only the most basic use of \fBreadline\fP.
62 Much more functionality is available; see
63 \fIThe GNU Readline Library\fP and \fIThe GNU History Library\fP
64 for additional information.
68 returns the text of the line read. A blank line
69 returns the empty string. If
71 is encountered while reading a line, and the line is empty,
75 is read with a non\-empty line, it is
79 An Emacs-style notation is used to denote
80 keystrokes. Control keys are denoted by C\-\fIkey\fR, e.g., C\-n
81 means Control\-N. Similarly,
83 keys are denoted by M\-\fIkey\fR, so M\-x means Meta\-X. (On keyboards
86 key, M\-\fIx\fP means ESC \fIx\fP, i.e., press the Escape key
89 key. This makes ESC the \fImeta prefix\fP.
90 The combination M\-C\-\fIx\fP means ESC\-Control\-\fIx\fP,
91 or press the Escape key
92 then hold the Control key while pressing the
96 Readline commands may be given numeric
98 which normally act as a repeat count. Sometimes, however, it is the
99 sign of the argument that is significant. Passing a negative argument
100 to a command that acts in the forward direction (e.g., \fBkill\-line\fP)
101 causes that command to act in a backward direction.
102 Commands whose behavior with arguments deviates from this are noted
105 When a command is described as \fIkilling\fP text, the text
106 deleted is saved for possible future retrieval
107 (\fIyanking\fP). The killed text is saved in a
108 \fIkill ring\fP. Consecutive kills cause the text to be
109 accumulated into one unit, which can be yanked all at once.
110 Commands which do not kill text separate the chunks of text
112 .SH INITIALIZATION FILE
114 Readline is customized by putting commands in an initialization
115 file (the \fIinputrc\fP file).
116 The name of this file is taken from the value of the
118 environment variable. If that variable is unset, the default is
120 If that file does not exist or cannot be read, the ultimate default is
122 When a program which uses the readline library starts up, the
123 init file is read, and the key bindings and variables are set.
124 There are only a few basic constructs allowed in the
125 readline init file. Blank lines are ignored.
126 Lines beginning with a \fB#\fP are comments.
127 Lines beginning with a \fB$\fP indicate conditional constructs.
128 Other lines denote key bindings and variable settings.
129 Each program using this library may add its own commands
135 M\-Control\-u: universal\-argument
139 C\-Meta\-u: universal\-argument
144 would make M\-C\-u execute the readline command
145 .IR universal\-argument .
147 The following symbolic character names are recognized while
148 processing key bindings:
162 In addition to command names, readline allows keys to be bound
163 to a string that is inserted when the key is pressed (a \fImacro\fP).
166 The syntax for controlling key bindings in the
168 file is simple. All that is required is the name of the
169 command or the text of a macro and a key sequence to which
170 it should be bound. The name may be specified in one of two ways:
171 as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP
172 prefixes, or as a key sequence.
173 The name and key sequence are separated by a colon. There can be no
174 whitespace between the name and the colon.
176 When using the form \fBkeyname\fP:\^\fIfunction-name\fP or \fImacro\fP,
178 is the name of a key spelled out in English. For example:
181 Control\-u: universal\-argument
183 Meta\-Rubout: backward\-kill\-word
185 Control\-o: "> output"
188 In the above example,
190 is bound to the function
191 .BR universal\-argument ,
193 is bound to the function
194 .BR backward\-kill\-word ,
197 is bound to run the macro
198 expressed on the right hand side (that is, to insert the text
199 .if t \f(CW> output\fP
203 In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP,
207 above in that strings denoting
208 an entire key sequence may be specified by placing the sequence
209 within double quotes. Some GNU Emacs style key escapes can be
210 used, as in the following example, but the symbolic character names
214 "\eC\-u": universal\-argument
216 "\eC\-x\eC\-r": re\-read\-init\-file
218 "\ee[11~": "Function Key 1"
223 is again bound to the function
224 .BR universal\-argument .
226 is bound to the function
227 .BR re\-read\-init\-file ,
230 is bound to insert the text
231 .if t \f(CWFunction Key 1\fP.
232 .if n ``Function Key 1''.
234 The full set of GNU Emacs style escape sequences available when specifying
252 literal ", a double quote
255 literal ', a single quote
259 In addition to the GNU Emacs style escape sequences, a second
260 set of backslash escapes is available:
289 the eight-bit character whose value is the octal value \fInnn\fP
290 (one to three digits)
293 the eight-bit character whose value is the hexadecimal value \fIHH\fP
294 (one or two hex digits)
298 When entering the text of a macro, single or double quotes should
299 be used to indicate a macro definition. Unquoted text
300 is assumed to be a function name.
301 In the macro body, the backslash escapes described above are expanded.
302 Backslash will quote any other character in the macro text,
306 allows the current readline key bindings to be displayed or modified
309 builtin command. The editing mode may be switched during interactive
314 builtin command. Other programs using this library provide
315 similar mechanisms. The
317 file may be edited and re-read if a program does not provide
318 any other means to incorporate new bindings.
320 Readline has variables that can be used to further customize its
321 behavior. A variable may be set in the
323 file with a statement of the form
326 \fBset\fP \fIvariable\-name\fP \fIvalue\fP
329 Except where noted, readline variables can take the values
333 (without regard to case).
334 Unrecognized variable names are ignored.
335 When a variable value is read, empty or null values, "on" (case-insensitive),
336 and "1" are equivalent to \fBOn\fP. All other values are equivalent to
338 The variables and their default values are:
342 .B bell\-style (audible)
343 Controls what happens when readline wants to ring the terminal bell.
344 If set to \fBnone\fP, readline never rings the bell. If set to
345 \fBvisible\fP, readline uses a visible bell if one is available.
346 If set to \fBaudible\fP, readline attempts to ring the terminal's bell.
348 .B bind\-tty\-special\-chars (On)
349 If set to \fBOn\fP (the default), readline attempts to bind the control
350 characters treated specially by the kernel's terminal driver to their
351 readline equivalents.
353 .B blink\-matching\-paren (Off)
354 If set to \fBOn\fP, readline attempts to briefly move the cursor to an
355 opening parenthesis when a closing parenthesis is inserted.
357 .B colored\-completion\-prefix (Off)
358 If set to \fBOn\fP, when listing completions, readline displays the
359 common prefix of the set of possible completions using a different color.
360 The color definitions are taken from the value of the \fBLS_COLORS\fP
361 environment variable.
363 .B colored\-stats (Off)
364 If set to \fBOn\fP, readline displays possible completions using different
365 colors to indicate their file type.
366 The color definitions are taken from the value of the \fBLS_COLORS\fP
367 environment variable.
369 .B comment\-begin (``#'')
370 The string that is inserted in \fBvi\fP mode when the
373 This command is bound to
379 .B completion\-display\-width (\-1)
380 The number of screen columns used to display possible matches
381 when performing completion.
382 The value is ignored if it is less than 0 or greater than the terminal
384 A value of 0 will cause matches to be displayed one per line.
385 The default value is \-1.
387 .B completion\-ignore\-case (Off)
388 If set to \fBOn\fP, readline performs filename matching and completion
389 in a case\-insensitive fashion.
391 .B completion\-map\-case (Off)
392 If set to \fBOn\fP, and \fBcompletion\-ignore\-case\fP is enabled, readline
393 treats hyphens (\fI\-\fP) and underscores (\fI_\fP) as equivalent when
394 performing case\-insensitive filename matching and completion.
396 .B completion\-prefix\-display\-length (0)
397 The length in characters of the common prefix of a list of possible
398 completions that is displayed without modification. When set to a
399 value greater than zero, common prefixes longer than this value are
400 replaced with an ellipsis when displaying possible completions.
402 .B completion\-query\-items (100)
403 This determines when the user is queried about viewing
404 the number of possible completions
405 generated by the \fBpossible\-completions\fP command.
406 It may be set to any integer value greater than or equal to zero.
407 If the number of possible completions is greater than
408 or equal to the value of this variable,
409 readline will ask whether or not the user wishes to view them;
410 otherwise they are simply listed
411 on the terminal. A negative value causes readline to never ask.
413 .B convert\-meta (On)
414 If set to \fBOn\fP, readline will convert characters with the
415 eighth bit set to an ASCII key sequence
416 by stripping the eighth bit and prefixing it with an
417 escape character (in effect, using escape as the \fImeta prefix\fP).
418 The default is \fIOn\fP, but readline will set it to \fIOff\fP if the
419 locale contains eight-bit characters.
421 .B disable\-completion (Off)
422 If set to \fBOn\fP, readline will inhibit word completion. Completion
423 characters will be inserted into the line as if they had been
424 mapped to \fBself-insert\fP.
426 .B echo\-control\-characters (On)
427 When set to \fBOn\fP, on operating systems that indicate they support it,
428 readline echoes a character corresponding to a signal generated from the
431 .B editing\-mode (emacs)
432 Controls whether readline begins with a set of key bindings similar
433 to \fIEmacs\fP or \fIvi\fP.
440 .B emacs\-mode\-string (@)
441 If the \fIshow\-mode\-in\-prompt\fP variable is enabled,
442 this string is displayed immediately before the last line of the primary
443 prompt when emacs editing mode is active. The value is expanded like a
444 key binding, so the standard set of meta- and control prefixes and
445 backslash escape sequences is available.
446 Use the \e1 and \e2 escapes to begin and end sequences of
447 non-printing characters, which can be used to embed a terminal control
448 sequence into the mode string.
450 .B enable\-bracketed\-paste (On)
451 When set to \fBOn\fP, readline will configure the terminal in a way
452 that will enable it to insert each paste into the editing buffer as a
453 single string of characters, instead of treating each character as if
454 it had been read from the keyboard. This can prevent pasted characters
455 from being interpreted as editing commands.
457 .B enable\-keypad (Off)
458 When set to \fBOn\fP, readline will try to enable the application
459 keypad when it is called. Some systems need this to enable the
462 .B enable\-meta\-key (On)
463 When set to \fBOn\fP, readline will try to enable any meta modifier
464 key the terminal claims to support when it is called. On many terminals,
465 the meta key is used to send eight-bit characters.
467 .B expand\-tilde (Off)
468 If set to \fBOn\fP, tilde expansion is performed when readline
469 attempts word completion.
471 .B history\-preserve\-point (Off)
472 If set to \fBOn\fP, the history code attempts to place point at the
473 same location on each history line retrieved with \fBprevious-history\fP
474 or \fBnext-history\fP.
476 .B history\-size (unset)
477 Set the maximum number of history entries saved in the history list.
478 If set to zero, any existing history entries are deleted and no new entries
480 If set to a value less than zero, the number of history entries is not
482 By default, the number of history entries is not limited.
483 If an attempt is made to set \fIhistory\-size\fP to a non-numeric value,
484 the maximum number of history entries will be set to 500.
486 .B horizontal\-scroll\-mode (Off)
487 When set to \fBOn\fP, makes readline use a single line for display,
488 scrolling the input horizontally on a single screen line when it
489 becomes longer than the screen width rather than wrapping to a new line.
490 This setting is automatically enabled for terminals of height 1.
493 If set to \fBOn\fP, readline will enable eight-bit input (that is,
494 it will not clear the eighth bit in the characters it reads),
495 regardless of what the terminal claims it can support. The name
497 is a synonym for this variable.
498 The default is \fIOff\fP, but readline will set it to \fIOn\fP if the
499 locale contains eight-bit characters.
501 .B isearch\-terminators (``C\-[ C\-J'')
502 The string of characters that should terminate an incremental
503 search without subsequently executing the character as a command.
504 If this variable has not been given a value, the characters
505 \fIESC\fP and \fIC\-J\fP will terminate an incremental search.
508 Set the current readline keymap. The set of legal keymap names is
509 \fIemacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move,
512 \fIvi\fP is equivalent to \fIvi-command\fP; \fIemacs\fP is
513 equivalent to \fIemacs-standard\fP. The default value is
517 also affects the default keymap.
519 .B keyseq\-timeout (500)
520 Specifies the duration \fIreadline\fP will wait for a character when reading an
521 ambiguous key sequence (one that can form a complete key sequence using
522 the input read so far, or can take additional input to complete a longer
524 If no input is received within the timeout, \fIreadline\fP will use the shorter
525 but complete key sequence.
526 The value is specified in milliseconds, so a value of 1000 means that
527 \fIreadline\fP will wait one second for additional input.
528 If this variable is set to a value less than or equal to zero, or to a
529 non-numeric value, \fIreadline\fP will wait until another key is pressed to
530 decide which key sequence to complete.
532 .B mark\-directories (On)
533 If set to \fBOn\fP, completed directory names have a slash
536 .B mark\-modified\-lines (Off)
537 If set to \fBOn\fP, history lines that have been modified are displayed
538 with a preceding asterisk (\fB*\fP).
540 .B mark\-symlinked\-directories (Off)
541 If set to \fBOn\fP, completed names which are symbolic links to directories
542 have a slash appended (subject to the value of
543 \fBmark\-directories\fP).
545 .B match\-hidden\-files (On)
546 This variable, when set to \fBOn\fP, causes readline to match files whose
547 names begin with a `.' (hidden files) when performing filename
549 If set to \fBOff\fP, the leading `.' must be
550 supplied by the user in the filename to be completed.
552 .B menu\-complete\-display\-prefix (Off)
553 If set to \fBOn\fP, menu completion displays the common prefix of the
554 list of possible completions (which may be empty) before cycling through
557 .B output\-meta (Off)
558 If set to \fBOn\fP, readline will display characters with the
559 eighth bit set directly rather than as a meta-prefixed escape
561 The default is \fIOff\fP, but readline will set it to \fIOn\fP if the
562 locale contains eight-bit characters.
564 .B page\-completions (On)
565 If set to \fBOn\fP, readline uses an internal \fImore\fP-like pager
566 to display a screenful of possible completions at a time.
568 .B print\-completions\-horizontally (Off)
569 If set to \fBOn\fP, readline will display completions with matches
570 sorted horizontally in alphabetical order, rather than down the screen.
572 .B revert\-all\-at\-newline (Off)
573 If set to \fBOn\fP, readline will undo all changes to history lines
574 before returning when \fBaccept\-line\fP is executed. By default,
575 history lines may be modified and retain individual undo lists across
576 calls to \fBreadline\fP.
578 .B show\-all\-if\-ambiguous (Off)
579 This alters the default behavior of the completion functions. If
582 words which have more than one possible completion cause the
583 matches to be listed immediately instead of ringing the bell.
585 .B show\-all\-if\-unmodified (Off)
586 This alters the default behavior of the completion functions in
587 a fashion similar to \fBshow\-all\-if\-ambiguous\fP.
590 words which have more than one possible completion without any
591 possible partial completion (the possible completions don't share
592 a common prefix) cause the matches to be listed immediately instead
595 .B show\-mode\-in\-prompt (Off)
596 If set to \fBOn\fP, add a string to the beginning of the prompt
597 indicating the editing mode: emacs, vi command, or vi insertion.
598 The mode strings are user-settable (e.g., \fIemacs\-mode\-string\fP).
600 .B skip\-completed\-text (Off)
601 If set to \fBOn\fP, this alters the default completion behavior when
602 inserting a single match into the line. It's only active when
603 performing completion in the middle of a word. If enabled, readline
604 does not insert characters from the completion that match characters
605 after point in the word being completed, so portions of the word
606 following the cursor are not duplicated.
608 .B vi\-cmd\-mode\-string ((cmd))
609 If the \fIshow\-mode\-in\-prompt\fP variable is enabled,
610 this string is displayed immediately before the last line of the primary
611 prompt when vi editing mode is active and in command mode.
612 The value is expanded like a
613 key binding, so the standard set of meta- and control prefixes and
614 backslash escape sequences is available.
615 Use the \e1 and \e2 escapes to begin and end sequences of
616 non-printing characters, which can be used to embed a terminal control
617 sequence into the mode string.
619 .B vi\-ins\-mode\-string ((ins))
620 If the \fIshow\-mode\-in\-prompt\fP variable is enabled,
621 this string is displayed immediately before the last line of the primary
622 prompt when vi editing mode is active and in insertion mode.
623 The value is expanded like a
624 key binding, so the standard set of meta- and control prefixes and
625 backslash escape sequences is available.
626 Use the \e1 and \e2 escapes to begin and end sequences of
627 non-printing characters, which can be used to embed a terminal control
628 sequence into the mode string.
630 .B visible\-stats (Off)
631 If set to \fBOn\fP, a character denoting a file's type as reported
632 by \fIstat\fP(2) is appended to the filename when listing possible
635 .SS Conditional Constructs
636 Readline implements a facility similar in spirit to the conditional
637 compilation features of the C preprocessor which allows key
638 bindings and variable settings to be performed as the result
639 of tests. There are four parser directives used.
643 construct allows bindings to be made based on the
644 editing mode, the terminal being used, or the application using
645 readline. The text of the test, after any comparison operator,
646 extends to the end of the line;
647 unless otherwise noted, no characters are required to isolate it.
650 The \fBmode=\fP form of the \fB$if\fP directive is used to test
651 whether readline is in emacs or vi mode.
652 This may be used in conjunction
653 with the \fBset keymap\fP command, for instance, to set bindings in
654 the \fIemacs-standard\fP and \fIemacs-ctlx\fP keymaps only if
655 readline is starting out in emacs mode.
657 The \fBterm=\fP form may be used to include terminal-specific
658 key bindings, perhaps to bind the key sequences output by the
659 terminal's function keys. The word on the right side of the
661 is tested against the full name of the terminal and the portion
662 of the terminal name before the first \fB\-\fP. This allows
670 The \fBversion\fP test may be used to perform comparisons against
671 specific readline versions.
672 The \fBversion\fP expands to the current readline version.
673 The set of comparison operators includes
683 The version number supplied on the right side of the operator consists
684 of a major version number, an optional decimal point, and an optional
685 minor version (e.g., \fB7.1\fP). If the minor version is omitted, it
686 is assumed to be \fB0\fP.
687 The operator may be separated from the string \fBversion\fP
688 and from the version number argument by whitespace.
689 .IP \fBapplication\fP
690 The \fBapplication\fP construct is used to include
691 application-specific settings. Each program using the readline
692 library sets the \fIapplication name\fP, and an initialization
693 file can test for a particular value.
694 This could be used to bind key sequences to functions useful for
695 a specific program. For instance, the following command adds a
696 key sequence that quotes the current or previous word in \fBbash\fP:
701 # Quote the current or previous word
702 "\eC-xq": "\eeb\e"\eef\e""
707 The \fIvariable\fP construct provides simple equality tests for readline
708 variables and values.
709 The permitted comparison operators are \fI=\fP, \fI==\fP, and \fI!=\fP.
710 The variable name must be separated from the comparison operator by
711 whitespace; the operator may be separated from the value on the right hand
713 Both string and boolean variables may be tested. Boolean variables must be
714 tested against the values \fIon\fP and \fIoff\fP.
717 This command, as seen in the previous example, terminates an
720 Commands in this branch of the \fB$if\fP directive are executed if
723 This directive takes a single filename as an argument and reads commands
724 and bindings from that file. For example, the following directive
725 would read \fI/etc/inputrc\fP:
729 \fB$include\fP \^ \fI/etc/inputrc\fP
733 Readline provides commands for searching through the command history
734 for lines containing a specified string.
735 There are two search modes:
738 .IR non-incremental .
740 Incremental searches begin before the user has finished typing the
742 As each character of the search string is typed, readline displays
743 the next entry from the history matching the string typed so far.
744 An incremental search requires only as many characters as needed to
745 find the desired history entry.
746 To search backward in the history for a particular string, type
747 \fBC\-r\fP. Typing \fBC\-s\fP searches forward through the history.
748 The characters present in the value of the \fBisearch-terminators\fP
749 variable are used to terminate an incremental search.
750 If that variable has not been assigned a value the \fIEscape\fP and
751 \fBC\-J\fP characters will terminate an incremental search.
752 \fBC\-G\fP will abort an incremental search and restore the original
754 When the search is terminated, the history entry containing the
755 search string becomes the current line.
757 To find other matching entries in the history list, type \fBC\-s\fP or
758 \fBC\-r\fP as appropriate.
759 This will search backward or forward in the history for the next
760 line matching the search string typed so far.
761 Any other key sequence bound to a readline command will terminate
762 the search and execute that command.
763 For instance, a newline will terminate the search and accept
764 the line, thereby executing the command from the history list.
765 A movement command will terminate the search, make the last line found
766 the current line, and begin editing.
768 Non-incremental searches read the entire search string before starting
769 to search for matching history lines. The search string may be
770 typed by the user or be part of the contents of the current line.
772 The following is a list of the names of the commands and the default
773 key sequences to which they are bound.
774 Command names without an accompanying key sequence are unbound by default.
776 In the following descriptions, \fIpoint\fP refers to the current cursor
777 position, and \fImark\fP refers to a cursor position saved by the
778 \fBset\-mark\fP command.
779 The text between the point and mark is referred to as the \fIregion\fP.
780 .SS Commands for Moving
783 .B beginning\-of\-line (C\-a)
784 Move to the start of the current line.
786 .B end\-of\-line (C\-e)
787 Move to the end of the line.
789 .B forward\-char (C\-f)
790 Move forward a character.
792 .B backward\-char (C\-b)
793 Move back a character.
795 .B forward\-word (M\-f)
796 Move forward to the end of the next word. Words are composed of
797 alphanumeric characters (letters and digits).
799 .B backward\-word (M\-b)
800 Move back to the start of the current or previous word. Words are
801 composed of alphanumeric characters (letters and digits).
803 .B previous\-screen\-line
804 Attempt to move point to the same physical screen column on the previous
805 physical screen line. This will not have the desired effect if the current
806 Readline line does not take up more than one physical line or if point is not
807 greater than the length of the prompt plus the screen width.
809 .B next\-screen\-line
810 Attempt to move point to the same physical screen column on the next
811 physical screen line. This will not have the desired effect if the current
812 Readline line does not take up more than one physical line or if the length
813 of the current Readline line is not greater than the length of the prompt
814 plus the screen width.
816 .B clear\-display (M\-C\-l)
817 Clear the screen and, if possible, the terminal's scrollback buffer,
818 then redraw the current line,
819 leaving the current line at the top of the screen.
821 .B clear\-screen (C\-l)
823 then redraw the current line,
824 leaving the current line at the top of the screen.
825 With an argument, refresh the current line without clearing the
828 .B redraw\-current\-line
829 Refresh the current line.
831 .SS Commands for Manipulating the History
834 .B accept\-line (Newline, Return)
835 Accept the line regardless of where the cursor is.
837 non-empty, it may be added to the history list for future recall with
839 If the line is a modified history line, the history line is restored to its original state.
841 .B previous\-history (C\-p)
842 Fetch the previous command from the history list, moving back in
845 .B next\-history (C\-n)
846 Fetch the next command from the history list, moving forward in the
849 .B beginning\-of\-history (M\-<)
850 Move to the first line in the history.
852 .B end\-of\-history (M\->)
853 Move to the end of the input history, i.e., the line currently being
856 .B reverse\-search\-history (C\-r)
857 Search backward starting at the current line and moving `up' through
858 the history as necessary. This is an incremental search.
860 .B forward\-search\-history (C\-s)
861 Search forward starting at the current line and moving `down' through
862 the history as necessary. This is an incremental search.
864 .B non\-incremental\-reverse\-search\-history (M\-p)
865 Search backward through the history starting at the current line
866 using a non-incremental search for a string supplied by the user.
868 .B non\-incremental\-forward\-search\-history (M\-n)
869 Search forward through the history using a non-incremental search
870 for a string supplied by the user.
872 .B history\-search\-backward
873 Search backward through the history for the string of characters
874 between the start of the current line and the current cursor
875 position (the \fIpoint\fP).
876 The search string must match at the beginning of a history line.
877 This is a non-incremental search.
879 .B history\-search\-forward
880 Search forward through the history for the string of characters
881 between the start of the current line and the point.
882 The search string must match at the beginning of a history line.
883 This is a non-incremental search.
885 .B history\-substring\-search\-backward
886 Search backward through the history for the string of characters
887 between the start of the current line and the current cursor
888 position (the \fIpoint\fP).
889 The search string may match anywhere in a history line.
890 This is a non-incremental search.
892 .B history\-substring\-search\-forward
893 Search forward through the history for the string of characters
894 between the start of the current line and the point.
895 The search string may match anywhere in a history line.
896 This is a non-incremental search.
898 .B yank\-nth\-arg (M\-C\-y)
899 Insert the first argument to the previous command (usually
900 the second word on the previous line) at point.
903 insert the \fIn\fPth word from the previous command (the words
904 in the previous command begin with word 0). A negative argument
905 inserts the \fIn\fPth word from the end of the previous command.
906 Once the argument \fIn\fP is computed, the argument is extracted
907 as if the "!\fIn\fP" history expansion had been specified.
910 yank\-last\-arg (M\-.\^, M\-_\^)
911 Insert the last argument to the previous command (the last word of
912 the previous history entry).
913 With a numeric argument, behave exactly like \fByank\-nth\-arg\fP.
914 Successive calls to \fByank\-last\-arg\fP move back through the history
915 list, inserting the last word (or the word specified by the argument to
916 the first call) of each line in turn.
917 Any numeric argument supplied to these successive calls determines
918 the direction to move through the history. A negative argument switches
919 the direction through the history (back or forward).
920 The history expansion facilities are used to extract the last argument,
921 as if the "!$" history expansion had been specified.
924 operate\-and\-get\-next (C\-o)
925 Accept the current line for return to the calling application as if a
926 newline had been entered,
927 and fetch the next line relative to the current line from the history
929 A numeric argument, if supplied, specifies the history entry to use instead
932 .SS Commands for Changing Text
935 .B \fIend\-of\-file\fP (usually C\-d)
936 The character indicating end-of-file as set, for example, by
939 If this character is read when there are no characters
940 on the line, and point is at the beginning of the line, Readline
941 interprets it as the end of input and returns
945 .B delete\-char (C\-d)
946 Delete the character at point.
947 If this function is bound to the
948 same character as the tty \fBEOF\fP character, as \fBC\-d\fP
949 commonly is, see above for the effects.
951 .B backward\-delete\-char (Rubout)
952 Delete the character behind the cursor. When given a numeric argument,
953 save the deleted text on the kill ring.
955 .B forward\-backward\-delete\-char
956 Delete the character under the cursor, unless the cursor is at the
957 end of the line, in which case the character behind the cursor is
960 .B quoted\-insert (C\-q, C\-v)
961 Add the next character that you type to the line verbatim. This is
962 how to insert characters like \fBC\-q\fP, for example.
964 .B tab\-insert (M-TAB)
965 Insert a tab character.
967 .B self\-insert (a,\ b,\ A,\ 1,\ !,\ ...)
968 Insert the character typed.
970 .B transpose\-chars (C\-t)
971 Drag the character before point forward over the character at point,
972 moving point forward as well.
973 If point is at the end of the line, then this transposes
974 the two characters before point.
975 Negative arguments have no effect.
977 .B transpose\-words (M\-t)
978 Drag the word before point past the word after point,
979 moving point over that word as well.
980 If point is at the end of the line, this transposes
981 the last two words on the line.
983 .B upcase\-word (M\-u)
984 Uppercase the current (or following) word. With a negative argument,
985 uppercase the previous word, but do not move point.
987 .B downcase\-word (M\-l)
988 Lowercase the current (or following) word. With a negative argument,
989 lowercase the previous word, but do not move point.
991 .B capitalize\-word (M\-c)
992 Capitalize the current (or following) word. With a negative argument,
993 capitalize the previous word, but do not move point.
996 Toggle overwrite mode. With an explicit positive numeric argument,
997 switches to overwrite mode. With an explicit non-positive numeric
998 argument, switches to insert mode. This command affects only
999 \fBemacs\fP mode; \fBvi\fP mode does overwrite differently.
1000 Each call to \fIreadline()\fP starts in insert mode.
1001 In overwrite mode, characters bound to \fBself\-insert\fP replace
1002 the text at point rather than pushing the text to the right.
1003 Characters bound to \fBbackward\-delete\-char\fP replace the character
1004 before point with a space. By default, this command is unbound.
1006 .SS Killing and Yanking
1009 .B kill\-line (C\-k)
1010 Kill the text from point to the end of the line.
1012 .B backward\-kill\-line (C\-x Rubout)
1013 Kill backward to the beginning of the line.
1015 .B unix\-line\-discard (C\-u)
1016 Kill backward from point to the beginning of the line.
1017 The killed text is saved on the kill-ring.
1018 .\" There is no real difference between this and backward-kill-line
1020 .B kill\-whole\-line
1021 Kill all characters on the current line, no matter where point is.
1023 .B kill\-word (M\-d)
1024 Kill from point the end of the current word, or if between
1025 words, to the end of the next word. Word boundaries are the same as
1026 those used by \fBforward\-word\fP.
1028 .B backward\-kill\-word (M\-Rubout)
1029 Kill the word behind point.
1030 Word boundaries are the same as those used by \fBbackward\-word\fP.
1032 .B unix\-word\-rubout (C\-w)
1033 Kill the word behind point, using white space as a word boundary.
1034 The killed text is saved on the kill-ring.
1036 .B unix\-filename\-rubout
1037 Kill the word behind point, using white space and the slash character
1038 as the word boundaries.
1039 The killed text is saved on the kill-ring.
1041 .B delete\-horizontal\-space (M\-\e)
1042 Delete all spaces and tabs around point.
1045 Kill the text between the point and \fImark\fP (saved cursor position).
1046 This text is referred to as the \fIregion\fP.
1048 .B copy\-region\-as\-kill
1049 Copy the text in the region to the kill buffer.
1051 .B copy\-backward\-word
1052 Copy the word before point to the kill buffer.
1053 The word boundaries are the same as \fBbackward\-word\fP.
1055 .B copy\-forward\-word
1056 Copy the word following point to the kill buffer.
1057 The word boundaries are the same as \fBforward\-word\fP.
1060 Yank the top of the kill ring into the buffer at point.
1063 Rotate the kill ring, and yank the new top. Only works following
1068 .SS Numeric Arguments
1071 .B digit\-argument (M\-0, M\-1, ..., M\-\-)
1072 Add this digit to the argument already accumulating, or start a new
1073 argument. M\-\- starts a negative argument.
1075 .B universal\-argument
1076 This is another way to specify an argument.
1077 If this command is followed by one or more digits, optionally with a
1078 leading minus sign, those digits define the argument.
1079 If the command is followed by digits, executing
1080 .B universal\-argument
1081 again ends the numeric argument, but is otherwise ignored.
1082 As a special case, if this command is immediately followed by a
1083 character that is neither a digit or minus sign, the argument count
1084 for the next command is multiplied by four.
1085 The argument count is initially one, so executing this function the
1086 first time makes the argument count four, a second time makes the
1087 argument count sixteen, and so on.
1093 Attempt to perform completion on the text before point.
1094 The actual completion performed is application-specific.
1096 for instance, attempts completion treating the text as a variable
1097 (if the text begins with \fB$\fP), username (if the text begins with
1098 \fB~\fP), hostname (if the text begins with \fB@\fP), or
1099 command (including aliases and functions) in turn. If none
1100 of these produces a match, filename completion is attempted.
1103 allows completion of program functions and variables, and
1104 only attempts filename completion under certain circumstances.
1106 .B possible\-completions (M\-?)
1107 List the possible completions of the text before point.
1108 When displaying completions, readline sets the number of columns used
1109 for display to the value of \fBcompletion-display-width\fP, the value of
1110 the environment variable
1113 or the screen width, in that order.
1115 .B insert\-completions (M\-*)
1116 Insert all completions of the text before point
1117 that would have been generated by
1118 \fBpossible\-completions\fP.
1121 Similar to \fBcomplete\fP, but replaces the word to be completed
1122 with a single match from the list of possible completions.
1123 Repeated execution of \fBmenu\-complete\fP steps through the list
1124 of possible completions, inserting each match in turn.
1125 At the end of the list of completions, the bell is rung
1126 (subject to the setting of \fBbell\-style\fP)
1127 and the original text is restored.
1128 An argument of \fIn\fP moves \fIn\fP positions forward in the list
1129 of matches; a negative argument may be used to move backward
1131 This command is intended to be bound to \fBTAB\fP, but is unbound
1134 .B menu\-complete\-backward
1135 Identical to \fBmenu\-complete\fP, but moves backward through the list
1136 of possible completions, as if \fBmenu\-complete\fP had been given a
1137 negative argument. This command is unbound by default.
1139 .B delete\-char\-or\-list
1140 Deletes the character under the cursor if not at the beginning or
1141 end of the line (like \fBdelete-char\fP).
1142 If at the end of the line, behaves identically to
1143 \fBpossible-completions\fP.
1148 .B start\-kbd\-macro (C\-x (\^)
1149 Begin saving the characters typed into the current keyboard macro.
1151 .B end\-kbd\-macro (C\-x )\^)
1152 Stop saving the characters typed into the current keyboard macro
1153 and store the definition.
1155 .B call\-last\-kbd\-macro (C\-x e)
1156 Re-execute the last keyboard macro defined, by making the characters
1157 in the macro appear as if typed at the keyboard.
1159 .B print\-last\-kbd\-macro ()
1160 Print the last keyboard macro defined in a format suitable for the
1166 .B re\-read\-init\-file (C\-x C\-r)
1167 Read in the contents of the \fIinputrc\fP file, and incorporate
1168 any bindings or variable assignments found there.
1171 Abort the current editing command and
1172 ring the terminal's bell (subject to the setting of
1175 .B do\-lowercase\-version (M\-A, M\-B, M\-\fIx\fP, ...)
1176 If the metafied character \fIx\fP is uppercase, run the command
1177 that is bound to the corresponding metafied lowercase character.
1178 The behavior is undefined if \fIx\fP is already lowercase.
1180 .B prefix\-meta (ESC)
1181 Metafy the next character typed.
1188 .B undo (C\-_, C\-x C\-u)
1189 Incremental undo, separately remembered for each line.
1191 .B revert\-line (M\-r)
1192 Undo all changes made to this line. This is like executing the
1194 command enough times to return the line to its initial state.
1196 .B tilde\-expand (M\-&)
1197 Perform tilde expansion on the current word.
1199 .B set\-mark (C\-@, M\-<space>)
1200 Set the mark to the point. If a
1201 numeric argument is supplied, the mark is set to that position.
1203 .B exchange\-point\-and\-mark (C\-x C\-x)
1204 Swap the point with the mark. The current cursor position is set to
1205 the saved position, and the old cursor position is saved as the mark.
1207 .B character\-search (C\-])
1208 A character is read and point is moved to the next occurrence of that
1209 character. A negative count searches for previous occurrences.
1211 .B character\-search\-backward (M\-C\-])
1212 A character is read and point is moved to the previous occurrence of that
1213 character. A negative count searches for subsequent occurrences.
1215 .B skip\-csi\-sequence
1216 Read enough characters to consume a multi-key sequence such as those
1217 defined for keys like Home and End. Such sequences begin with a
1218 Control Sequence Indicator (CSI), usually ESC\-[. If this sequence is
1219 bound to "\e[", keys producing such sequences will have no effect
1220 unless explicitly bound to a readline command, instead of inserting
1221 stray characters into the editing buffer. This is unbound by default,
1222 but usually bound to ESC\-[.
1224 .B insert\-comment (M\-#)
1225 Without a numeric argument, the value of the readline
1227 variable is inserted at the beginning of the current line.
1228 If a numeric argument is supplied, this command acts as a toggle: if
1229 the characters at the beginning of the line do not match the value
1230 of \fBcomment\-begin\fP, the value is inserted, otherwise
1231 the characters in \fBcomment-begin\fP are deleted from the beginning of
1233 In either case, the line is accepted as if a newline had been typed.
1234 The default value of
1236 makes the current line a shell comment.
1237 If a numeric argument causes the comment character to be removed, the line
1238 will be executed by the shell.
1241 Print all of the functions and their key bindings to the
1242 readline output stream. If a numeric argument is supplied,
1243 the output is formatted in such a way that it can be made part
1244 of an \fIinputrc\fP file.
1247 Print all of the settable variables and their values to the
1248 readline output stream. If a numeric argument is supplied,
1249 the output is formatted in such a way that it can be made part
1250 of an \fIinputrc\fP file.
1253 Print all of the readline key sequences bound to macros and the
1254 strings they output. If a numeric argument is supplied,
1255 the output is formatted in such a way that it can be made part
1256 of an \fIinputrc\fP file.
1258 .B emacs\-editing\-mode (C\-e)
1261 command mode, this causes a switch to
1265 .B vi\-editing\-mode (M\-C\-j)
1268 editing mode, this causes a switch to
1272 .SH DEFAULT KEY BINDINGS
1274 The following is a list of the default emacs and vi bindings.
1275 Characters with the eighth bit set are written as M\-<character>, and
1279 The printable ASCII characters not mentioned in the list of emacs
1280 standard bindings are bound to the
1282 function, which just inserts the given character into the input line.
1283 In vi insertion mode, all characters not specifically mentioned are
1286 Characters assigned to signal generation by
1288 or the terminal driver, such as C-Z or C-C,
1289 retain that function.
1290 Upper and lower case metafied characters are bound to the same function in
1291 the emacs mode meta keymap.
1292 The remaining characters are unbound, which causes readline
1293 to ring the bell (subject to the setting of the
1301 Emacs Standard bindings
1304 "C-A" beginning-of-line
1310 "C-H" backward-delete-char
1317 "C-P" previous-history
1319 "C-R" reverse-search-history
1320 "C-S" forward-search-history
1321 "C-T" transpose-chars
1322 "C-U" unix-line-discard
1324 "C-W" unix-word-rubout
1326 "C-]" character-search
1328 "\^ " to "/" self-insert
1329 "0" to "9" self-insert
1330 ":" to "~" self-insert
1331 "C-?" backward-delete-char
1336 "M-C-H" backward-kill-word
1338 "M-C-J" vi-editing-mode
1339 "M-C-L" clear-display
1340 "M-C-M" vi-editing-mode
1342 "M-C-Y" yank-nth-arg
1344 "M-C-]" character-search-backward
1346 "M-#" insert-comment
1348 "M-*" insert-completions
1349 "M--" digit-argument
1351 "M-0" digit-argument
1352 "M-1" digit-argument
1353 "M-2" digit-argument
1354 "M-3" digit-argument
1355 "M-4" digit-argument
1356 "M-5" digit-argument
1357 "M-6" digit-argument
1358 "M-7" digit-argument
1359 "M-8" digit-argument
1360 "M-9" digit-argument
1361 "M-<" beginning-of-history
1362 "M-=" possible-completions
1363 "M->" end-of-history
1364 "M-?" possible-completions
1366 "M-C" capitalize-word
1370 "M-N" non-incremental-forward-search-history
1371 "M-P" non-incremental-reverse-search-history
1373 "M-T" transpose-words
1376 "M-\e" delete-horizontal-space
1378 "M-C-?" backward-kill-word
1381 Emacs Control-X bindings
1384 "C-XC-R" re-read-init-file
1386 "C-XC-X" exchange-point-and-mark
1387 "C-X(" start-kbd-macro
1388 "C-X)" end-kbd-macro
1389 "C-XE" call-last-kbd-macro
1390 "C-XC-?" backward-kill-line
1393 .SS VI Mode bindings
1399 VI Insert Mode functions
1402 "C-H" backward-delete-char
1406 "C-R" reverse-search-history
1407 "C-S" forward-search-history
1408 "C-T" transpose-chars
1409 "C-U" unix-line-discard
1411 "C-W" unix-word-rubout
1413 "C-[" vi-movement-mode
1415 "\^ " to "~" self-insert
1416 "C-?" backward-delete-char
1418 VI Command Mode functions
1421 "C-E" emacs-editing-mode
1429 "C-P" previous-history
1431 "C-R" reverse-search-history
1432 "C-S" forward-search-history
1433 "C-T" transpose-chars
1434 "C-U" unix-line-discard
1436 "C-W" unix-word-rubout
1447 "-" previous-history
1450 "0" beginning-of-line
1451 "1" to "9" vi-arg-digit
1461 "G" vi-fetch-history
1470 "X" backward-delete-char
1483 "i" vi-insertion-mode
1503 \fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey
1505 \fIThe Gnu History Library\fP, Brian Fox and Chet Ramey
1513 Individual \fBreadline\fP initialization file
1516 Brian Fox, Free Software Foundation
1520 Chet Ramey, Case Western Reserve University
1524 If you find a bug in
1526 you should report it. But first, you should
1527 make sure that it really is a bug, and that it appears in the latest
1530 library that you have.
1532 Once you have determined that a bug actually exists, mail a
1533 bug report to \fIbug\-readline\fP@\fIgnu.org\fP.
1534 If you have a fix, you are welcome to mail that
1535 as well! Suggestions and `philosophical' bug reports may be mailed
1536 to \fPbug-readline\fP@\fIgnu.org\fP or posted to the Usenet
1540 Comments and bug reports concerning
1541 this manual page should be directed to
1542 .IR chet.ramey@case.edu .
1544 It's too big and too slow.