1 @comment %**start of header (This is for running Texinfo on a region.)
2 @setfilename rluser.info
3 @comment %**end of header (This is for running Texinfo on a region.)
7 This file documents the end user interface to the GNU command line
8 editing features. It is to be an appendix to manuals for programs which
9 use these features. There is a document entitled "readline.texinfo"
10 which contains both end-user and programmer documentation for the GNU
13 Copyright (C) 1988, 1991, 1993, 1996 Free Software Foundation, Inc.
15 Authored by Brian Fox and Chet Ramey.
17 Permission is granted to process this file through Tex and print the
18 results, provided the printed document carries copying permission notice
19 identical to this one except for the removal of this paragraph (this
20 paragraph not being relevant to the printed manual).
22 Permission is granted to make and distribute verbatim copies of this manual
23 provided the copyright notice and this permission notice are preserved on
26 Permission is granted to copy and distribute modified versions of this
27 manual under the conditions for verbatim copying, provided also that the
28 GNU Copyright statement is available to the distributee, and provided that
29 the entire resulting derived work is distributed under the terms of a
30 permission notice identical to this one.
32 Permission is granted to copy and distribute translations of this manual
33 into another language, under the above conditions for modified versions.
36 @comment If you are including this manual as an appendix, then set the
37 @comment variable readline-appendix.
40 @node Command Line Editing
41 @chapter Command Line Editing
44 This chapter describes the basic features of the @sc{GNU}
45 command line editing interface.
48 * Introduction and Notation:: Notation used in this text.
49 * Readline Interaction:: The minimum set of commands for editing a line.
50 * Readline Init File:: Customizing Readline from a user's view.
51 * Bindable Readline Commands:: A description of most of the Readline commands
53 * Readline vi Mode:: A short description of how to make Readline
54 behave like the vi editor.
57 @node Introduction and Notation
58 @section Introduction to Line Editing
60 The following paragraphs describe the notation used to represent
63 The text @key{C-k} is read as `Control-K' and describes the character
64 produced when the @key{k} key is pressed while the Control key
67 The text @key{M-k} is read as `Meta-K' and describes the character
68 produced when the meta key (if you have one) is depressed, and the @key{k}
69 key is pressed. If you do not have a meta key, the identical keystroke
70 can be generated by typing @key{ESC} @i{first}, and then typing @key{k}.
71 Either process is known as @dfn{metafying} the @key{k} key.
73 The text @key{M-C-k} is read as `Meta-Control-k' and describes the
74 character produced by @dfn{metafying} @key{C-k}.
76 In addition, several keys have their own names. Specifically,
77 @key{DEL}, @key{ESC}, @key{LFD}, @key{SPC}, @key{RET}, and @key{TAB} all
78 stand for themselves when seen in this text, or in an init file
79 (@pxref{Readline Init File}).
81 @node Readline Interaction
82 @section Readline Interaction
83 @cindex interaction, readline
85 Often during an interactive session you type in a long line of text,
86 only to notice that the first word on the line is misspelled. The
87 Readline library gives you a set of commands for manipulating the text
88 as you type it in, allowing you to just fix your typo, and not forcing
89 you to retype the majority of the line. Using these editing commands,
90 you move the cursor to the place that needs correction, and delete or
91 insert the text of the corrections. Then, when you are satisfied with
92 the line, you simply press @key{RETURN}. You do not have to be at the
93 end of the line to press @key{RETURN}; the entire line is accepted
94 regardless of the location of the cursor within the line.
97 * Readline Bare Essentials:: The least you need to know about Readline.
98 * Readline Movement Commands:: Moving about the input line.
99 * Readline Killing Commands:: How to delete text, and how to get it back!
100 * Readline Arguments:: Giving numeric arguments to commands.
101 * Searching:: Searching through previous lines.
104 @node Readline Bare Essentials
105 @subsection Readline Bare Essentials
106 @cindex notation, readline
107 @cindex command editing
108 @cindex editing command lines
110 In order to enter characters into the line, simply type them. The typed
111 character appears where the cursor was, and then the cursor moves one
112 space to the right. If you mistype a character, you can use your
113 erase character to back up and delete the mistyped character.
115 Sometimes you may miss typing a character that you wanted to type, and
116 not notice your error until you have typed several other characters. In
117 that case, you can type @key{C-b} to move the cursor to the left, and then
118 correct your mistake. Afterwards, you can move the cursor to the right
121 When you add text in the middle of a line, you will notice that characters
122 to the right of the cursor are `pushed over' to make room for the text
123 that you have inserted. Likewise, when you delete text behind the cursor,
124 characters to the right of the cursor are `pulled back' to fill in the
125 blank space created by the removal of the text. A list of the basic bare
126 essentials for editing the text of an input line follows.
130 Move back one character.
132 Move forward one character.
134 Delete the character to the left of the cursor.
136 Delete the character underneath the cursor.
137 @item @w{Printing characters}
138 Insert the character into the line at the cursor.
140 Undo the last editing command. You can undo all the way back to an
144 @node Readline Movement Commands
145 @subsection Readline Movement Commands
148 The above table describes the most basic possible keystrokes that you need
149 in order to do editing of the input line. For your convenience, many
150 other commands have been added in addition to @key{C-b}, @key{C-f},
151 @key{C-d}, and @key{DEL}. Here are some commands for moving more rapidly
156 Move to the start of the line.
158 Move to the end of the line.
160 Move forward a word, where a word is composed of letters and digits.
162 Move backward a word.
164 Clear the screen, reprinting the current line at the top.
167 Notice how @key{C-f} moves forward a character, while @key{M-f} moves
168 forward a word. It is a loose convention that control keystrokes
169 operate on characters while meta keystrokes operate on words.
171 @node Readline Killing Commands
172 @subsection Readline Killing Commands
177 @dfn{Killing} text means to delete the text from the line, but to save
178 it away for later use, usually by @dfn{yanking} (re-inserting)
179 it back into the line.
180 If the description for a command says that it `kills' text, then you can
181 be sure that you can get the text back in a different (or the same)
184 When you use a kill command, the text is saved in a @dfn{kill-ring}.
185 Any number of consecutive kills save all of the killed text together, so
186 that when you yank it back, you get it all. The kill
187 ring is not line specific; the text that you killed on a previously
188 typed line is available to be yanked back later, when you are typing
192 Here is the list of commands for killing text.
196 Kill the text from the current cursor position to the end of the line.
199 Kill from the cursor to the end of the current word, or if between
200 words, to the end of the next word.
203 Kill from the cursor the start of the previous word, or if between
204 words, to the start of the previous word.
207 Kill from the cursor to the previous whitespace. This is different than
208 @key{M-DEL} because the word boundaries differ.
212 Here is how to @dfn{yank} the text back into the line. Yanking
213 means to copy the most-recently-killed text from the kill buffer.
217 Yank the most recently killed text back into the buffer at the cursor.
220 Rotate the kill-ring, and yank the new top. You can only do this if
221 the prior command is @key{C-y} or @key{M-y}.
224 @node Readline Arguments
225 @subsection Readline Arguments
227 You can pass numeric arguments to Readline commands. Sometimes the
228 argument acts as a repeat count, other times it is the @i{sign} of the
229 argument that is significant. If you pass a negative argument to a
230 command which normally acts in a forward direction, that command will
231 act in a backward direction. For example, to kill text back to the
232 start of the line, you might type @samp{M-- C-k}.
234 The general way to pass numeric arguments to a command is to type meta
235 digits before the command. If the first `digit' typed is a minus
236 sign (@key{-}), then the sign of the argument will be negative. Once
237 you have typed one meta digit to get the argument started, you can type
238 the remainder of the digits, and then the command. For example, to give
239 the @key{C-d} command an argument of 10, you could type @samp{M-1 0 C-d}.
242 @subsection Searching for Commands in the History
244 Readline provides commands for searching through the command history
246 (@pxref{Bash History Facilities})
248 for lines containing a specified string.
249 There are two search modes: @var{incremental} and @var{non-incremental}.
251 Incremental searches begin before the user has finished typing the
253 As each character of the search string is typed, Readline displays
254 the next entry from the history matching the string typed so far.
255 An incremental search requires only as many characters as needed to
256 find the desired history entry.
257 The characters present in the value of the @var{isearch-terminators} variable
258 are used to terminate an incremental search.
259 If that variable has not been assigned a value, the @key{ESC} and
260 @key{C-J} characters will terminate an incremental search.
261 @key{C-g} will abort an incremental search and restore the original line.
262 When the search is terminated, the history entry containing the
263 search string becomes the current line.
264 To find other matching entries in the history list, type @key{C-s} or
265 @key{C-r} as appropriate.
266 This will search backward or forward in the history for the next
267 entry matching the search string typed so far.
268 Any other key sequence bound to a Readline command will terminate
269 the search and execute that command.
270 For instance, a @key{RET} will terminate the search and accept
271 the line, thereby executing the command from the history list.
273 Non-incremental searches read the entire search string before starting
274 to search for matching history lines. The search string may be
275 typed by the user or be part of the contents of the current line.
277 @node Readline Init File
278 @section Readline Init File
279 @cindex initialization file, readline
281 Although the Readline library comes with a set of @code{emacs}-like
282 keybindings installed by default, it is possible to use a different set
284 Any user can customize programs that use Readline by putting
285 commands in an @dfn{inputrc} file in his home directory.
288 file is taken from the value of the shell variable @code{INPUTRC}. If
290 @ifclear BashFeatures
291 file is taken from the value of the environment variable @code{INPUTRC}. If
293 that variable is unset, the default is @file{~/.inputrc}.
295 When a program which uses the Readline library starts up, the
296 init file is read, and the key bindings are set.
298 In addition, the @code{C-x C-r} command re-reads this init file, thus
299 incorporating any changes that you might have made to it.
302 * Readline Init File Syntax:: Syntax for the commands in the inputrc file.
304 * Conditional Init Constructs:: Conditional key bindings in the inputrc file.
306 * Sample Init File:: An example inputrc file.
309 @node Readline Init File Syntax
310 @subsection Readline Init File Syntax
312 There are only a few basic constructs allowed in the
313 Readline init file. Blank lines are ignored.
314 Lines beginning with a @samp{#} are comments.
315 Lines beginning with a @samp{$} indicate conditional
316 constructs (@pxref{Conditional Init Constructs}). Other lines
317 denote variable settings and key bindings.
320 @item Variable Settings
321 You can modify the run-time behavior of Readline by
322 altering the values of variables in Readline
323 using the @code{set} command within the init file. Here is how to
324 change from the default Emacs-like key binding to use
325 @code{vi} line editing commands:
331 A great deal of run-time behavior is changeable with the following
338 Controls what happens when Readline wants to ring the terminal bell.
339 If set to @samp{none}, Readline never rings the bell. If set to
340 @samp{visible}, Readline uses a visible bell if one is available.
341 If set to @samp{audible} (the default), Readline attempts to ring
345 @vindex comment-begin
346 The string to insert at the beginning of the line when the
347 @code{insert-comment} command is executed. The default value
350 @item completion-ignore-case
351 If set to @samp{on}, Readline performs filename matching and completion
352 in a case-insensitive fashion.
353 The default value is @samp{off}.
355 @item completion-query-items
356 @vindex completion-query-items
357 The number of possible completions that determines when the user is
358 asked whether he wants to see the list of possibilities. If the
359 number of possible completions is greater than this value,
360 Readline will ask the user whether or not he wishes to view
361 them; otherwise, they are simply listed. The default limit is
366 If set to @samp{on}, Readline will convert characters with the
367 eighth bit set to an ASCII key sequence by stripping the eighth
368 bit and prepending an @key{ESC} character, converting them to a
369 meta-prefixed key sequence. The default value is @samp{on}.
371 @item disable-completion
372 @vindex disable-completion
373 If set to @samp{On}, Readline will inhibit word completion.
374 Completion characters will be inserted into the line as if they had
375 been mapped to @code{self-insert}. The default is @samp{off}.
379 The @code{editing-mode} variable controls which default set of
380 key bindings is used. By default, Readline starts up in Emacs editing
381 mode, where the keystrokes are most similar to Emacs. This variable can be
382 set to either @samp{emacs} or @samp{vi}.
385 @vindex enable-keypad
386 When set to @samp{on}, Readline will try to enable the application
387 keypad when it is called. Some systems need this to enable the
388 arrow keys. The default is @samp{off}.
392 If set to @samp{on}, tilde expansion is performed when Readline
393 attempts word completion. The default is @samp{off}.
395 @item horizontal-scroll-mode
396 @vindex horizontal-scroll-mode
397 This variable can be set to either @samp{on} or @samp{off}. Setting it
398 to @samp{on} means that the text of the lines being edited will scroll
399 horizontally on a single screen line when they are longer than the width
400 of the screen, instead of wrapping onto a new screen line. By default,
401 this variable is set to @samp{off}.
406 If set to @samp{on}, Readline will enable eight-bit input (it
407 will not strip the eighth bit from the characters it reads),
408 regardless of what the terminal claims it can support. The
409 default value is @samp{off}. The name @code{meta-flag} is a
410 synonym for this variable.
412 @item isearch-terminators
413 @vindex isearch-terminators
414 The string of characters that should terminate an incremental search without
415 subsequently executing the character as a command (@pxref{Searching}).
416 If this variable has not been given a value, the characters @key{ESC} and
417 @key{C-J} will terminate an incremental search.
421 Sets Readline's idea of the current keymap for key binding commands.
422 Acceptable @code{keymap} names are
424 @code{emacs-standard},
428 @code{vi-command}, and
430 @code{vi} is equivalent to @code{vi-command}; @code{emacs} is
431 equivalent to @code{emacs-standard}. The default value is @code{emacs}.
432 The value of the @code{editing-mode} variable also affects the
435 @item mark-directories
436 If set to @samp{on}, completed directory names have a slash
437 appended. The default is @samp{on}.
439 @item mark-modified-lines
440 @vindex mark-modified-lines
441 This variable, when set to @samp{on}, causes Readline to display an
442 asterisk (@samp{*}) at the start of history lines which have been modified.
443 This variable is @samp{off} by default.
447 If set to @samp{on}, Readline will display characters with the
448 eighth bit set directly rather than as a meta-prefixed escape
449 sequence. The default is @samp{off}.
451 @item print-completions-horizontally
452 If set to @samp{on}, Readline will display completions with matches
453 sorted horizontally in alphabetical order, rather than down the screen.
454 The default is @samp{off}.
456 @item show-all-if-ambiguous
457 @vindex show-all-if-ambiguous
458 This alters the default behavior of the completion functions. If
460 words which have more than one possible completion cause the
461 matches to be listed immediately instead of ringing the bell.
462 The default value is @samp{off}.
465 @vindex visible-stats
466 If set to @samp{on}, a character denoting a file's type
467 is appended to the filename when listing possible
468 completions. The default is @samp{off}.
473 The syntax for controlling key bindings in the init file is
474 simple. First you have to know the name of the command that you
475 want to change. The following sections contain tables of the command
476 name, the default keybinding, if any, and a short description of what
479 Once you know the name of the command, simply place the name of the key
480 you wish to bind the command to, a colon, and then the name of the
481 command on a line in the init file. The name of the key
482 can be expressed in different ways, depending on which is most
486 @item @w{@var{keyname}: @var{function-name} or @var{macro}}
487 @var{keyname} is the name of a key spelled out in English. For example:
489 Control-u: universal-argument
490 Meta-Rubout: backward-kill-word
491 Control-o: "> output"
494 In the above example, @key{C-u} is bound to the function
495 @code{universal-argument}, and @key{C-o} is bound to run the macro
496 expressed on the right hand side (that is, to insert the text
497 @samp{> output} into the line).
499 @item @w{"@var{keyseq}": @var{function-name} or @var{macro}}
500 @var{keyseq} differs from @var{keyname} above in that strings
501 denoting an entire key sequence can be specified, by placing
502 the key sequence in double quotes. Some GNU Emacs style key
503 escapes can be used, as in the following example, but the
504 special character names are not recognized.
507 "\C-u": universal-argument
508 "\C-x\C-r": re-read-init-file
509 "\e[11~": "Function Key 1"
512 In the above example, @key{C-u} is bound to the function
513 @code{universal-argument} (just as it was in the first example),
514 @samp{@key{C-x} @key{C-r}} is bound to the function @code{re-read-init-file},
515 and @samp{@key{ESC} @key{[} @key{1} @key{1} @key{~}} is bound to insert
516 the text @samp{Function Key 1}.
520 The following GNU Emacs style escape sequences are available when
521 specifying key sequences:
538 In addition to the GNU Emacs style escape sequences, a second
539 set of backslash escapes is available:
559 the character whose ASCII code is the octal value @var{nnn}
560 (one to three digits)
562 the character whose ASCII code is the hexadecimal value @var{nnn}
563 (one to three digits)
566 When entering the text of a macro, single or double quotes must
567 be used to indicate a macro definition.
568 Unquoted text is assumed to be a function name.
569 In the macro body, the backslash escapes described above are expanded.
570 Backslash will quote any other character in the macro text,
571 including @samp{"} and @samp{'}.
572 For example, the following binding will make @samp{C-x \}
573 insert a single @samp{\} into the line:
580 @node Conditional Init Constructs
581 @subsection Conditional Init Constructs
583 Readline implements a facility similar in spirit to the conditional
584 compilation features of the C preprocessor which allows key
585 bindings and variable settings to be performed as the result
586 of tests. There are four parser directives used.
590 The @code{$if} construct allows bindings to be made based on the
591 editing mode, the terminal being used, or the application using
592 Readline. The text of the test extends to the end of the line;
593 no characters are required to isolate it.
597 The @code{mode=} form of the @code{$if} directive is used to test
598 whether Readline is in @code{emacs} or @code{vi} mode.
599 This may be used in conjunction
600 with the @samp{set keymap} command, for instance, to set bindings in
601 the @code{emacs-standard} and @code{emacs-ctlx} keymaps only if
602 Readline is starting out in @code{emacs} mode.
605 The @code{term=} form may be used to include terminal-specific
606 key bindings, perhaps to bind the key sequences output by the
607 terminal's function keys. The word on the right side of the
608 @samp{=} is tested against both the full name of the terminal and
609 the portion of the terminal name before the first @samp{-}. This
610 allows @code{sun} to match both @code{sun} and @code{sun-cmd},
614 The @var{application} construct is used to include
615 application-specific settings. Each program using the Readline
616 library sets the @var{application name}, and you can test for it.
617 This could be used to bind key sequences to functions useful for
618 a specific program. For instance, the following command adds a
619 key sequence that quotes the current or previous word in Bash:
622 # Quote the current or previous word
623 "\C-xq": "\eb\"\ef\""
629 This command, as seen in the previous example, terminates an
633 Commands in this branch of the @code{$if} directive are executed if
637 This directive takes a single filename as an argument and reads commands
638 and bindings from that file.
640 $include /etc/inputrc
644 @node Sample Init File
645 @subsection Sample Init File
647 Here is an example of an inputrc file. This illustrates key
648 binding, variable assignment, and conditional syntax.
652 # This file controls the behaviour of line input editing for
653 # programs that use the Gnu Readline library. Existing programs
654 # include FTP, Bash, and Gdb.
656 # You can re-read the inputrc file with C-x C-r.
657 # Lines beginning with '#' are comments.
659 # First, include any systemwide bindings and variable assignments from
661 $include /etc/Inputrc
664 # Set various bindings for emacs mode.
666 set editing-mode emacs
670 Meta-Control-h: backward-kill-word Text after the function name is ignored
673 # Arrow keys in keypad mode
675 #"\M-OD": backward-char
676 #"\M-OC": forward-char
677 #"\M-OA": previous-history
678 #"\M-OB": next-history
680 # Arrow keys in ANSI mode
682 "\M-[D": backward-char
683 "\M-[C": forward-char
684 "\M-[A": previous-history
685 "\M-[B": next-history
687 # Arrow keys in 8 bit keypad mode
689 #"\M-\C-OD": backward-char
690 #"\M-\C-OC": forward-char
691 #"\M-\C-OA": previous-history
692 #"\M-\C-OB": next-history
694 # Arrow keys in 8 bit ANSI mode
696 #"\M-\C-[D": backward-char
697 #"\M-\C-[C": forward-char
698 #"\M-\C-[A": previous-history
699 #"\M-\C-[B": next-history
705 # An old-style binding. This happens to be the default.
708 # Macros that are convenient for shell interaction
711 "\C-xp": "PATH=$@{PATH@}\e\C-e\C-a\ef\C-f"
712 # prepare to type a quoted word -- insert open and close double quotes
713 # and move to just after the open quote
715 # insert a backslash (testing backslash escapes in sequences and macros)
717 # Quote the current or previous word
718 "\C-xq": "\eb\"\ef\""
719 # Add a binding to refresh the line, which is unbound
720 "\C-xr": redraw-current-line
721 # Edit variable on current line.
722 "\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y="
725 # use a visible bell if one is available
726 set bell-style visible
728 # don't strip characters to 7 bits when reading
731 # allow iso-latin1 characters to be inserted rather than converted to
732 # prefix-meta sequences
735 # display characters with the eighth bit set directly rather than
736 # as meta-prefixed characters
739 # if there are more than 150 possible completions for a word, ask the
740 # user if he wants to see all of them
741 set completion-query-items 150
747 "\M-.": yank-last-arg
751 @node Bindable Readline Commands
752 @section Bindable Readline Commands
755 * Commands For Moving:: Moving about the line.
756 * Commands For History:: Getting at previous lines.
757 * Commands For Text:: Commands for changing text.
758 * Commands For Killing:: Commands for killing and yanking.
759 * Numeric Arguments:: Specifying numeric arguments, repeat counts.
760 * Commands For Completion:: Getting Readline to do the typing for you.
761 * Keyboard Macros:: Saving and re-executing typed characters
762 * Miscellaneous Commands:: Other miscellaneous commands.
765 This section describes Readline commands that may be bound to key
768 @node Commands For Moving
769 @subsection Commands For Moving
771 @item beginning-of-line (C-a)
772 Move to the start of the current line.
774 @item end-of-line (C-e)
775 Move to the end of the line.
777 @item forward-char (C-f)
778 Move forward a character.
780 @item backward-char (C-b)
781 Move back a character.
783 @item forward-word (M-f)
784 Move forward to the end of the next word. Words are composed of
787 @item backward-word (M-b)
788 Move back to the start of this, or the previous, word. Words are
789 composed of letters and digits.
791 @item clear-screen (C-l)
792 Clear the screen and redraw the current line,
793 leaving the current line at the top of the screen.
795 @item redraw-current-line ()
796 Refresh the current line. By default, this is unbound.
800 @node Commands For History
801 @subsection Commands For Manipulating The History
804 @item accept-line (Newline, Return)
806 Accept the line regardless of where the cursor is. If this line is
807 non-empty, add it to the history list according to the setting of
808 the @code{HISTCONTROL} and @code{HISTIGNORE} variables.
809 If this line was a history line, then restore the history line to its
812 @ifclear BashFeatures
813 Accept the line regardless of where the cursor is. If this line is
814 non-empty, add it to the history list. If this line was a history
815 line, then restore the history line to its original state.
818 @item previous-history (C-p)
819 Move `up' through the history list.
821 @item next-history (C-n)
822 Move `down' through the history list.
824 @item beginning-of-history (M-<)
825 Move to the first line in the history.
827 @item end-of-history (M->)
828 Move to the end of the input history, i.e., the line currently
831 @item reverse-search-history (C-r)
832 Search backward starting at the current line and moving `up' through
833 the history as necessary. This is an incremental search.
835 @item forward-search-history (C-s)
836 Search forward starting at the current line and moving `down' through
837 the the history as necessary. This is an incremental search.
839 @item non-incremental-reverse-search-history (M-p)
840 Search backward starting at the current line and moving `up'
841 through the history as necessary using a non-incremental search
842 for a string supplied by the user.
844 @item non-incremental-forward-search-history (M-n)
845 Search forward starting at the current line and moving `down'
846 through the the history as necessary using a non-incremental search
847 for a string supplied by the user.
849 @item history-search-forward ()
850 Search forward through the history for the string of characters
851 between the start of the current line and the current cursor
852 position (the @var{point}). This is a non-incremental search. By
853 default, this command is unbound.
855 @item history-search-backward ()
856 Search backward through the history for the string of characters
857 between the start of the current line and the point. This
858 is a non-incremental search. By default, this command is unbound.
860 @item yank-nth-arg (M-C-y)
861 Insert the first argument to the previous command (usually
862 the second word on the previous line). With an argument @var{n},
863 insert the @var{n}th word from the previous command (the words
864 in the previous command begin with word 0). A negative argument
865 inserts the @var{n}th word from the end of the previous command.
867 @item yank-last-arg (M-., M-_)
868 Insert last argument to the previous command (the last word of the
869 previous history entry). With an
870 argument, behave exactly like @code{yank-nth-arg}.
871 Successive calls to @code{yank-last-arg} move back through the history
872 list, inserting the last argument of each line in turn.
876 @node Commands For Text
877 @subsection Commands For Changing Text
880 @item delete-char (C-d)
881 Delete the character under the cursor. If the cursor is at the
882 beginning of the line, there are no characters in the line, and
883 the last character typed was not bound to @code{delete-char}, then
886 @item backward-delete-char (Rubout)
887 Delete the character behind the cursor. A numeric argument means
888 to kill the characters instead of deleting them.
890 @item forward-backward-delete-char ()
891 Delete the character under the cursor, unless the cursor is at the
892 end of the line, in which case the character behind the cursor is
893 deleted. By default, this is not bound to a key.
895 @item quoted-insert (C-q, C-v)
896 Add the next character typed to the line verbatim. This is
897 how to insert key sequences like @key{C-q}, for example.
899 @ifclear BashFeatures
900 @item tab-insert (M-TAB)
901 Insert a tab character.
904 @item self-insert (a, b, A, 1, !, ...)
907 @item transpose-chars (C-t)
908 Drag the character before the cursor forward over
909 the character at the cursor, moving the
910 cursor forward as well. If the insertion point
911 is at the end of the line, then this
912 transposes the last two characters of the line.
913 Negative arguments don't work.
915 @item transpose-words (M-t)
916 Drag the word behind the cursor past the word in front of the cursor
917 moving the cursor over that word as well.
919 @item upcase-word (M-u)
920 Uppercase the current (or following) word. With a negative argument,
921 uppercase the previous word, but do not move the cursor.
923 @item downcase-word (M-l)
924 Lowercase the current (or following) word. With a negative argument,
925 lowercase the previous word, but do not move the cursor.
927 @item capitalize-word (M-c)
928 Capitalize the current (or following) word. With a negative argument,
929 capitalize the previous word, but do not move the cursor.
933 @node Commands For Killing
934 @subsection Killing And Yanking
938 @item kill-line (C-k)
939 Kill the text from the current cursor position to the end of the line.
941 @item backward-kill-line (C-x Rubout)
942 Kill backward to the beginning of the line.
944 @item unix-line-discard (C-u)
945 Kill backward from the cursor to the beginning of the current line.
946 The killed text is saved on the kill-ring.
948 @item kill-whole-line ()
949 Kill all characters on the current line, no matter where the
950 cursor is. By default, this is unbound.
952 @item kill-word (M-d)
953 Kill from the cursor to the end of the current word, or if between
954 words, to the end of the next word. Word boundaries are the same
955 as @code{forward-word}.
957 @item backward-kill-word (M-DEL)
958 Kill the word behind the cursor. Word boundaries are the same
959 as @code{backward-word}.
961 @item unix-word-rubout (C-w)
962 Kill the word behind the cursor, using white space as a word
963 boundary. The killed text is saved on the kill-ring.
965 @item delete-horizontal-space ()
966 Delete all spaces and tabs around point. By default, this is unbound.
969 Kill the text between the point and the @emph{mark} (saved
970 cursor position). This text is referred to as the @var{region}.
971 By default, this command is unbound.
973 @item copy-region-as-kill ()
974 Copy the text in the region to the kill buffer, so it can be yanked
975 right away. By default, this command is unbound.
977 @item copy-backward-word ()
978 Copy the word before point to the kill buffer.
979 The word boundaries are the same as @code{backward-word}.
980 By default, this command is unbound.
982 @item copy-forward-word ()
983 Copy the word following point to the kill buffer.
984 The word boundaries are the same as @code{forward-word}.
985 By default, this command is unbound.
988 Yank the top of the kill ring into the buffer at the current
992 Rotate the kill-ring, and yank the new top. You can only do this if
993 the prior command is yank or yank-pop.
996 @node Numeric Arguments
997 @subsection Specifying Numeric Arguments
1000 @item digit-argument (M-0, M-1, ... M--)
1001 Add this digit to the argument already accumulating, or start a new
1002 argument. @key{M--} starts a negative argument.
1004 @item universal-argument ()
1005 This is another way to specify an argument.
1006 If this command is followed by one or more digits, optionally with a
1007 leading minus sign, those digits define the argument.
1008 If the command is followed by digits, executing @code{universal-argument}
1009 again ends the numeric argument, but is otherwise ignored.
1010 As a special case, if this command is immediately followed by a
1011 character that is neither a digit or minus sign, the argument count
1012 for the next command is multiplied by four.
1013 The argument count is initially one, so executing this function the
1014 first time makes the argument count four, a second time makes the
1015 argument count sixteen, and so on.
1016 By default, this is not bound to a key.
1019 @node Commands For Completion
1020 @subsection Letting Readline Type For You
1023 @item complete (TAB)
1024 Attempt to do completion on the text before the cursor. This is
1025 application-specific. Generally, if you are typing a filename
1026 argument, you can do filename completion; if you are typing a command,
1027 you can do command completion; if you are typing in a symbol to GDB, you
1028 can do symbol name completion; if you are typing in a variable to Bash,
1029 you can do variable name completion, and so on.
1031 Bash attempts completion treating the text as a variable (if the
1032 text begins with @samp{$}), username (if the text begins with
1033 @samp{~}), hostname (if the text begins with @samp{@@}), or
1034 command (including aliases and functions) in turn. If none
1035 of these produces a match, filename completion is attempted.
1038 @item possible-completions (M-?)
1039 List the possible completions of the text before the cursor.
1041 @item insert-completions (M-*)
1042 Insert all completions of the text before point that would have
1043 been generated by @code{possible-completions}.
1045 @item menu-complete ()
1046 Similar to @code{complete}, but replaces the word to be completed
1047 with a single match from the list of possible completions.
1048 Repeated execution of @code{menu-complete} steps through the list
1049 of possible completions, inserting each match in turn.
1050 At the end of the list of completions, the bell is rung and the
1051 original text is restored.
1052 An argument of @var{n} moves @var{n} positions forward in the list
1053 of matches; a negative argument may be used to move backward
1055 This command is intended to be bound to @code{TAB}, but is unbound
1058 @item delete-char-or-list ()
1059 Deletes the character under the cursor if not at the beginning or
1060 end of the line (like @code{delete-char}).
1061 If at the end of the line, behaves identically to
1062 @code{possible-completions}.
1063 This command is unbound by default.
1066 @item complete-filename (M-/)
1067 Attempt filename completion on the text before point.
1069 @item possible-filename-completions (C-x /)
1070 List the possible completions of the text before point,
1071 treating it as a filename.
1073 @item complete-username (M-~)
1074 Attempt completion on the text before point, treating
1077 @item possible-username-completions (C-x ~)
1078 List the possible completions of the text before point,
1079 treating it as a username.
1081 @item complete-variable (M-$)
1082 Attempt completion on the text before point, treating
1083 it as a shell variable.
1085 @item possible-variable-completions (C-x $)
1086 List the possible completions of the text before point,
1087 treating it as a shell variable.
1089 @item complete-hostname (M-@@)
1090 Attempt completion on the text before point, treating
1093 @item possible-hostname-completions (C-x @@)
1094 List the possible completions of the text before point,
1095 treating it as a hostname.
1097 @item complete-command (M-!)
1098 Attempt completion on the text before point, treating
1099 it as a command name. Command completion attempts to
1100 match the text against aliases, reserved words, shell
1101 functions, shell builtins, and finally executable filenames,
1104 @item possible-command-completions (C-x !)
1105 List the possible completions of the text before point,
1106 treating it as a command name.
1108 @item dynamic-complete-history (M-TAB)
1109 Attempt completion on the text before point, comparing
1110 the text against lines from the history list for possible
1113 @item complete-into-braces (M-@{)
1114 Perform filename completion and return the list of possible completions
1115 enclosed within braces so the list is available to the shell
1116 (@pxref{Brace Expansion}).
1121 @node Keyboard Macros
1122 @subsection Keyboard Macros
1125 @item start-kbd-macro (C-x ()
1126 Begin saving the characters typed into the current keyboard macro.
1128 @item end-kbd-macro (C-x ))
1129 Stop saving the characters typed into the current keyboard macro
1130 and save the definition.
1132 @item call-last-kbd-macro (C-x e)
1133 Re-execute the last keyboard macro defined, by making the characters
1134 in the macro appear as if typed at the keyboard.
1138 @node Miscellaneous Commands
1139 @subsection Some Miscellaneous Commands
1142 @item re-read-init-file (C-x C-r)
1143 Read in the contents of the inputrc file, and incorporate
1144 any bindings or variable assignments found there.
1147 Abort the current editing command and
1148 ring the terminal's bell (subject to the setting of
1151 @item do-uppercase-version (M-a, M-b, M-@var{x}, @dots{})
1152 If the metafied character @var{x} is lowercase, run the command
1153 that is bound to the corresponding uppercase character.
1155 @item prefix-meta (ESC)
1156 Make the next character typed be metafied. This is for keyboards
1157 without a meta key. Typing @samp{ESC f} is equivalent to typing
1160 @item undo (C-_, C-x C-u)
1161 Incremental undo, separately remembered for each line.
1163 @item revert-line (M-r)
1164 Undo all changes made to this line. This is like executing the @code{undo}
1165 command enough times to get back to the beginning.
1168 @item tilde-expand (M-&)
1170 @ifclear BashFeatures
1171 @item tilde-expand (M-~)
1173 Perform tilde expansion on the current word.
1175 @item set-mark (C-@@)
1176 Set the mark to the current point. If a
1177 numeric argument is supplied, the mark is set to that position.
1179 @item exchange-point-and-mark (C-x C-x)
1180 Swap the point with the mark. The current cursor position is set to
1181 the saved position, and the old cursor position is saved as the mark.
1183 @item character-search (C-])
1184 A character is read and point is moved to the next occurrence of that
1185 character. A negative count searches for previous occurrences.
1187 @item character-search-backward (M-C-])
1188 A character is read and point is moved to the previous occurrence
1189 of that character. A negative count searches for subsequent
1192 @item insert-comment (M-#)
1193 The value of the @code{comment-begin}
1194 variable is inserted at the beginning of the current line,
1195 and the line is accepted as if a newline had been typed.
1197 This makes the current line a shell comment.
1200 @item dump-functions ()
1201 Print all of the functions and their key bindings to the
1202 Readline output stream. If a numeric argument is supplied,
1203 the output is formatted in such a way that it can be made part
1204 of an @var{inputrc} file. This command is unbound by default.
1206 @item dump-variables ()
1207 Print all of the settable variables and their values to the
1208 Readline output stream. If a numeric argument is supplied,
1209 the output is formatted in such a way that it can be made part
1210 of an @var{inputrc} file. This command is unbound by default.
1212 @item dump-macros ()
1213 Print all of the Readline key sequences bound to macros and the
1214 strings they ouput. If a numeric argument is supplied,
1215 the output is formatted in such a way that it can be made part
1216 of an @var{inputrc} file. This command is unbound by default.
1219 @item glob-expand-word (C-x *)
1220 The word before point is treated as a pattern for pathname expansion,
1221 and the list of matching file names is inserted, replacing the word.
1223 @item glob-list-expansions (C-x g)
1224 The list of expansions that would have been generated by
1225 @code{glob-expand-word} is displayed, and the line is redrawn.
1227 @item display-shell-version (C-x C-v)
1228 Display version information about the current instance of Bash.
1230 @item shell-expand-line (M-C-e)
1231 Expand the line as the shell does.
1232 This performs alias and history expansion as well as all of the shell
1233 word expansions (@pxref{Shell Expansions}).
1235 @item history-expand-line (M-^)
1236 Perform history expansion on the current line.
1238 @item magic-space ()
1239 Perform history expansion on the current line and insert a space
1240 (@pxref{History Interaction}).
1242 @item alias-expand-line ()
1243 Perform alias expansion on the current line (@pxref{Aliases}).
1245 @item history-and-alias-expand-line ()
1246 Perform history and alias expansion on the current line.
1248 @item insert-last-argument (M-., M-_)
1249 A synonym for @code{yank-last-arg}.
1251 @item operate-and-get-next (C-o)
1252 Accept the current line for execution and fetch the next line
1253 relative to the current line from the history for editing. Any
1254 argument is ignored.
1256 @item emacs-editing-mode (C-e)
1257 When in @code{vi} editing mode, this causes a switch back to
1258 @code{emacs} editing mode, as if the command @samp{set -o emacs} had
1265 @node Readline vi Mode
1266 @section Readline vi Mode
1268 While the Readline library does not have a full set of @code{vi}
1269 editing functions, it does contain enough to allow simple editing
1270 of the line. The Readline @code{vi} mode behaves as specified in
1271 the @sc{POSIX} 1003.2 standard.
1274 In order to switch interactively between @code{emacs} and @code{vi}
1275 editing modes, use the @samp{set -o emacs} and @samp{set -o vi}
1276 commands (@pxref{The Set Builtin}).
1278 @ifclear BashFeatures
1279 In order to switch interactively between @code{emacs} and @code{vi}
1280 editing modes, use the command M-C-j (toggle-editing-mode).
1282 The Readline default is @code{emacs} mode.
1284 When you enter a line in @code{vi} mode, you are already placed in
1285 `insertion' mode, as if you had typed an @samp{i}. Pressing @key{ESC}
1286 switches you into `command' mode, where you can edit the text of the
1287 line with the standard @code{vi} movement keys, move to previous
1288 history lines with @samp{k} and subsequent lines with @samp{j}, and