1READLINE(3) Library Functions Manual READLINE(3)
2
3
4
6 readline - get a line from a user with editing
7
9 #include <stdio.h>
10 #include <readline/readline.h>
11 #include <readline/history.h>
12
13 char *
14 readline (const char *prompt);
15
17 Readline is Copyright (C) 1989-2009 Free Software Foundation, Inc.
18
20 readline will read a line from the terminal and return it, using prompt
21 as a prompt. If prompt is NULL or the empty string, no prompt is
22 issued. The line returned is allocated with malloc(3); the caller must
23 free it when finished. The line returned has the final newline
24 removed, so only the text of the line remains.
25
26 readline offers editing capabilities while the user is entering the
27 line. By default, the line editing commands are similar to those of
28 emacs. A vi-style line editing interface is also available.
29
30 This manual page describes only the most basic use of readline. Much
31 more functionality is available; see The GNU Readline Library and The
32 GNU History Library for additional information.
33
35 readline returns the text of the line read. A blank line returns the
36 empty string. If EOF is encountered while reading a line, and the line
37 is empty, NULL is returned. If an EOF is read with a non-empty line,
38 it is treated as a newline.
39
41 An emacs-style notation is used to denote keystrokes. Control keys are
42 denoted by C-key, e.g., C-n means Control-N. Similarly, meta keys are
43 denoted by M-key, so M-x means Meta-X. (On keyboards without a meta
44 key, M-x means ESC x, i.e., press the Escape key then the x key. This
45 makes ESC the meta prefix. The combination M-C-x means ESC-Control-x,
46 or press the Escape key then hold the Control key while pressing the x
47 key.)
48
49 Readline commands may be given numeric arguments, which normally act as
50 a repeat count. Sometimes, however, it is the sign of the argument
51 that is significant. Passing a negative argument to a command that
52 acts in the forward direction (e.g., kill-line) causes that command to
53 act in a backward direction. Commands whose behavior with arguments
54 deviates from this are noted.
55
56 When a command is described as killing text, the text deleted is saved
57 for possible future retrieval (yanking). The killed text is saved in a
58 kill ring. Consecutive kills cause the text to be accumulated into one
59 unit, which can be yanked all at once. Commands which do not kill text
60 separate the chunks of text on the kill ring.
61
63 Readline is customized by putting commands in an initialization file
64 (the inputrc file). The name of this file is taken from the value of
65 the INPUTRC environment variable. If that variable is unset, the
66 default is ~/.inputrc. If that file does not exist or cannot be read,
67 the ultimate default is /etc/inputrc. When a program which uses the
68 readline library starts up, the init file is read, and the key bindings
69 and variables are set. There are only a few basic constructs allowed
70 in the readline init file. Blank lines are ignored. Lines beginning
71 with a # are comments. Lines beginning with a $ indicate conditional
72 constructs. Other lines denote key bindings and variable settings.
73 Each program using this library may add its own commands and bindings.
74
75 For example, placing
76
77 M-Control-u: universal-argument
78 or
79 C-Meta-u: universal-argument
80
81 into the inputrc would make M-C-u execute the readline command univer‐
82 sal-argument.
83
84 The following symbolic character names are recognized while processing
85 key bindings: DEL, ESC, ESCAPE, LFD, NEWLINE, RET, RETURN, RUBOUT,
86 SPACE, SPC, and TAB.
87
88 In addition to command names, readline allows keys to be bound to a
89 string that is inserted when the key is pressed (a macro).
90
91 Key Bindings
92 The syntax for controlling key bindings in the inputrc file is simple.
93 All that is required is the name of the command or the text of a macro
94 and a key sequence to which it should be bound. The name may be speci‐
95 fied in one of two ways: as a symbolic key name, possibly with Meta- or
96 Control- prefixes, or as a key sequence. The name and key sequence are
97 separated by a colon. There can be no whitespace between the name and
98 the colon.
99
100 When using the form keyname:function-name or macro, keyname is the name
101 of a key spelled out in English. For example:
102
103 Control-u: universal-argument
104 Meta-Rubout: backward-kill-word
105 Control-o: "> output"
106
107 In the above example, C-u is bound to the function universal-argument,
108 M-DEL is bound to the function backward-kill-word, and C-o is bound to
109 run the macro expressed on the right hand side (that is, to insert the
110 text ``> output'' into the line).
111
112 In the second form, "keyseq":function-name or macro, keyseq differs
113 from keyname above in that strings denoting an entire key sequence may
114 be specified by placing the sequence within double quotes. Some GNU
115 Emacs style key escapes can be used, as in the following example, but
116 the symbolic character names are not recognized.
117
118 "\C-u": universal-argument
119 "\C-x\C-r": re-read-init-file
120 "\e[11~": "Function Key 1"
121
122 In this example, C-u is again bound to the function universal-argument.
123 C-x C-r is bound to the function re-read-init-file, and ESC [ 1 1 ~ is
124 bound to insert the text ``Function Key 1''.
125
126 The full set of GNU Emacs style escape sequences available when speci‐
127 fying key sequences is
128 \C- control prefix
129 \M- meta prefix
130 \e an escape character
131 \\ backslash
132 \" literal ", a double quote
133 \' literal ', a single quote
134
135 In addition to the GNU Emacs style escape sequences, a second set of
136 backslash escapes is available:
137 \a alert (bell)
138 \b backspace
139 \d delete
140 \f form feed
141 \n newline
142 \r carriage return
143 \t horizontal tab
144 \v vertical tab
145 \nnn the eight-bit character whose value is the octal value
146 nnn (one to three digits)
147 \xHH the eight-bit character whose value is the hexadecimal
148 value HH (one or two hex digits)
149
150 When entering the text of a macro, single or double quotes should be
151 used to indicate a macro definition. Unquoted text is assumed to be a
152 function name. In the macro body, the backslash escapes described
153 above are expanded. Backslash will quote any other character in the
154 macro text, including " and '.
155
156 Bash allows the current readline key bindings to be displayed or modi‐
157 fied with the bind builtin command. The editing mode may be switched
158 during interactive use by using the -o option to the set builtin com‐
159 mand. Other programs using this library provide similar mechanisms.
160 The inputrc file may be edited and re-read if a program does not pro‐
161 vide any other means to incorporate new bindings.
162
163 Variables
164 Readline has variables that can be used to further customize its behav‐
165 ior. A variable may be set in the inputrc file with a statement of the
166 form
167
168 set variable-name value
169
170 Except where noted, readline variables can take the values On or Off
171 (without regard to case). Unrecognized variable names are ignored.
172 When a variable value is read, empty or null values, "on" (case-insen‐
173 sitive), and "1" are equivalent to On. All other values are equivalent
174 to Off. The variables and their default values are:
175
176 bell-style (audible)
177 Controls what happens when readline wants to ring the terminal
178 bell. If set to none, readline never rings the bell. If set to
179 visible, readline uses a visible bell if one is available. If
180 set to audible, readline attempts to ring the terminal's bell.
181 bind-tty-special-chars (On)
182 If set to On, readline attempts to bind the control characters
183 treated specially by the kernel's terminal driver to their read‐
184 line equivalents.
185 comment-begin (``#'')
186 The string that is inserted in vi mode when the insert-comment
187 command is executed. This command is bound to M-# in emacs mode
188 and to # in vi command mode.
189 completion-ignore-case (Off)
190 If set to On, readline performs filename matching and completion
191 in a case-insensitive fashion.
192 completion-prefix-display-length (0)
193 The length in characters of the common prefix of a list of pos‐
194 sible completions that is displayed without modification. When
195 set to a value greater than zero, common prefixes longer than
196 this value are replaced with an ellipsis when displaying possi‐
197 ble completions.
198 completion-query-items (100)
199 This determines when the user is queried about viewing the num‐
200 ber of possible completions generated by the possible-comple‐
201 tions command. It may be set to any integer value greater than
202 or equal to zero. If the number of possible completions is
203 greater than or equal to the value of this variable, the user is
204 asked whether or not he wishes to view them; otherwise they are
205 simply listed on the terminal. A negative value causes readline
206 to never ask.
207 convert-meta (On)
208 If set to On, readline will convert characters with the eighth
209 bit set to an ASCII key sequence by stripping the eighth bit and
210 prefixing it with an escape character (in effect, using escape
211 as the meta prefix).
212 disable-completion (Off)
213 If set to On, readline will inhibit word completion. Completion
214 characters will be inserted into the line as if they had been
215 mapped to self-insert.
216 editing-mode (emacs)
217 Controls whether readline begins with a set of key bindings sim‐
218 ilar to emacs or vi. editing-mode can be set to either emacs or
219 vi.
220 enable-keypad (Off)
221 When set to On, readline will try to enable the application key‐
222 pad when it is called. Some systems need this to enable the
223 arrow keys.
224 expand-tilde (Off)
225 If set to on, tilde expansion is performed when readline
226 attempts word completion.
227 history-preserve-point (Off)
228 If set to on, the history code attempts to place point at the
229 same location on each history line retrieved with previous-his‐
230 tory or next-history.
231 history-size (0)
232 Set the maximum number of history entries saved in the history
233 list. If set to zero, the number of entries in the history list
234 is not limited.
235 horizontal-scroll-mode (Off)
236 When set to On, makes readline use a single line for display,
237 scrolling the input horizontally on a single screen line when it
238 becomes longer than the screen width rather than wrapping to a
239 new line.
240 input-meta (Off)
241 If set to On, readline will enable eight-bit input (that is, it
242 will not clear the eighth bit in the characters it reads),
243 regardless of what the terminal claims it can support. The name
244 meta-flag is a synonym for this variable.
245 isearch-terminators (``C-[ C-J'')
246 The string of characters that should terminate an incremental
247 search without subsequently executing the character as a com‐
248 mand. If this variable has not been given a value, the charac‐
249 ters ESC and C-J will terminate an incremental search.
250 keymap (emacs)
251 Set the current readline keymap. The set of legal keymap names
252 is emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move,
253 vi-command, and vi-insert. vi is equivalent to vi-command;
254 emacs is equivalent to emacs-standard. The default value is
255 emacs. The value of editing-mode also affects the default
256 keymap.
257 mark-directories (On)
258 If set to On, completed directory names have a slash appended.
259 mark-modified-lines (Off)
260 If set to On, history lines that have been modified are dis‐
261 played with a preceding asterisk (*).
262 mark-symlinked-directories (Off)
263 If set to On, completed names which are symbolic links to direc‐
264 tories have a slash appended (subject to the value of
265 mark-directories).
266 match-hidden-files (On)
267 This variable, when set to On, causes readline to match files
268 whose names begin with a `.' (hidden files) when performing
269 filename completion, unless the leading `.' is supplied by the
270 user in the filename to be completed.
271 output-meta (Off)
272 If set to On, readline will display characters with the eighth
273 bit set directly rather than as a meta-prefixed escape sequence.
274 page-completions (On)
275 If set to On, readline uses an internal more-like pager to dis‐
276 play a screenful of possible completions at a time.
277 print-completions-horizontally (Off)
278 If set to On, readline will display completions with matches
279 sorted horizontally in alphabetical order, rather than down the
280 screen.
281 revert-all-at-newline (Off)
282 If set to on, readline will undo all changes to history lines
283 before returning when accept-line is executed. By default, his‐
284 tory lines may be modified and retain individual undo lists
285 across calls to readline.
286 show-all-if-ambiguous (Off)
287 This alters the default behavior of the completion functions.
288 If set to on, words which have more than one possible completion
289 cause the matches to be listed immediately instead of ringing
290 the bell.
291 show-all-if-unmodified (Off)
292 This alters the default behavior of the completion functions in
293 a fashion similar to show-all-if-ambiguous. If set to on, words
294 which have more than one possible completion without any possi‐
295 ble partial completion (the possible completions don't share a
296 common prefix) cause the matches to be listed immediately
297 instead of ringing the bell.
298 visible-stats (Off)
299 If set to On, a character denoting a file's type as reported by
300 stat(2) is appended to the filename when listing possible com‐
301 pletions.
302
303 Conditional Constructs
304 Readline implements a facility similar in spirit to the conditional
305 compilation features of the C preprocessor which allows key bindings
306 and variable settings to be performed as the result of tests. There
307 are four parser directives used.
308
309 $if The $if construct allows bindings to be made based on the edit‐
310 ing mode, the terminal being used, or the application using
311 readline. The text of the test extends to the end of the line;
312 no characters are required to isolate it.
313
314 mode The mode= form of the $if directive is used to test
315 whether readline is in emacs or vi mode. This may be
316 used in conjunction with the set keymap command, for
317 instance, to set bindings in the emacs-standard and
318 emacs-ctlx keymaps only if readline is starting out in
319 emacs mode.
320
321 term The term= form may be used to include terminal-specific
322 key bindings, perhaps to bind the key sequences output by
323 the terminal's function keys. The word on the right side
324 of the = is tested against the full name of the terminal
325 and the portion of the terminal name before the first -.
326 This allows sun to match both sun and sun-cmd, for
327 instance.
328
329 application
330 The application construct is used to include application-
331 specific settings. Each program using the readline
332 library sets the application name, and an initialization
333 file can test for a particular value. This could be used
334 to bind key sequences to functions useful for a specific
335 program. For instance, the following command adds a key
336 sequence that quotes the current or previous word in
337 Bash:
338
339 $if Bash
340 # Quote the current or previous word
341 "\C-xq": "\eb\"\ef\""
342 $endif
343
344 $endif This command, as seen in the previous example, terminates an $if
345 command.
346
347 $else Commands in this branch of the $if directive are executed if the
348 test fails.
349
350 $include
351 This directive takes a single filename as an argument and reads
352 commands and bindings from that file. For example, the follow‐
353 ing directive would read /etc/inputrc:
354
355 $include /etc/inputrc
356
358 Readline provides commands for searching through the command history
359 for lines containing a specified string. There are two search modes:
360 incremental and non-incremental.
361
362 Incremental searches begin before the user has finished typing the
363 search string. As each character of the search string is typed, read‐
364 line displays the next entry from the history matching the string typed
365 so far. An incremental search requires only as many characters as
366 needed to find the desired history entry. To search backward in the
367 history for a particular string, type C-r. Typing C-s searches forward
368 through the history. The characters present in the value of the
369 isearch-terminators variable are used to terminate an incremental
370 search. If that variable has not been assigned a value the Escape and
371 C-J characters will terminate an incremental search. C-G will abort an
372 incremental search and restore the original line. When the search is
373 terminated, the history entry containing the search string becomes the
374 current line.
375
376 To find other matching entries in the history list, type C-s or C-r as
377 appropriate. This will search backward or forward in the history for
378 the next line matching the search string typed so far. Any other key
379 sequence bound to a readline command will terminate the search and exe‐
380 cute that command. For instance, a newline will terminate the search
381 and accept the line, thereby executing the command from the history
382 list. A movement command will terminate the search, make the last line
383 found the current line, and begin editing.
384
385 Non-incremental searches read the entire search string before starting
386 to search for matching history lines. The search string may be typed
387 by the user or be part of the contents of the current line.
388
390 The following is a list of the names of the commands and the default
391 key sequences to which they are bound. Command names without an accom‐
392 panying key sequence are unbound by default.
393
394 In the following descriptions, point refers to the current cursor posi‐
395 tion, and mark refers to a cursor position saved by the set-mark com‐
396 mand. The text between the point and mark is referred to as the
397 region.
398
399 Commands for Moving
400 beginning-of-line (C-a)
401 Move to the start of the current line.
402 end-of-line (C-e)
403 Move to the end of the line.
404 forward-char (C-f)
405 Move forward a character.
406 backward-char (C-b)
407 Move back a character.
408 forward-word (M-f)
409 Move forward to the end of the next word. Words are composed of
410 alphanumeric characters (letters and digits).
411 backward-word (M-b)
412 Move back to the start of the current or previous word. Words
413 are composed of alphanumeric characters (letters and digits).
414 clear-screen (C-l)
415 Clear the screen leaving the current line at the top of the
416 screen. With an argument, refresh the current line without
417 clearing the screen.
418 redraw-current-line
419 Refresh the current line.
420
421 Commands for Manipulating the History
422 accept-line (Newline, Return)
423 Accept the line regardless of where the cursor is. If this line
424 is non-empty, it may be added to the history list for future
425 recall with add_history(). If the line is a modified history
426 line, the history line is restored to its original state.
427 previous-history (C-p)
428 Fetch the previous command from the history list, moving back in
429 the list.
430 next-history (C-n)
431 Fetch the next command from the history list, moving forward in
432 the list.
433 beginning-of-history (M-<)
434 Move to the first line in the history.
435 end-of-history (M->)
436 Move to the end of the input history, i.e., the line currently
437 being entered.
438 reverse-search-history (C-r)
439 Search backward starting at the current line and moving `up'
440 through the history as necessary. This is an incremental
441 search.
442 forward-search-history (C-s)
443 Search forward starting at the current line and moving `down'
444 through the history as necessary. This is an incremental
445 search.
446 non-incremental-reverse-search-history (M-p)
447 Search backward through the history starting at the current line
448 using a non-incremental search for a string supplied by the
449 user.
450 non-incremental-forward-search-history (M-n)
451 Search forward through the history using a non-incremental
452 search for a string supplied by the user.
453 history-search-forward
454 Search forward through the history for the string of characters
455 between the start of the current line and the current cursor
456 position (the point). This is a non-incremental search.
457 history-search-backward
458 Search backward through the history for the string of characters
459 between the start of the current line and the point. This is a
460 non-incremental search.
461 yank-nth-arg (M-C-y)
462 Insert the first argument to the previous command (usually the
463 second word on the previous line) at point. With an argument n,
464 insert the nth word from the previous command (the words in the
465 previous command begin with word 0). A negative argument
466 inserts the nth word from the end of the previous command. Once
467 the argument n is computed, the argument is extracted as if the
468 "!n" history expansion had been specified.
469 yank-last-arg (M-., M-_)
470 Insert the last argument to the previous command (the last word
471 of the previous history entry). With an argument, behave
472 exactly like yank-nth-arg. Successive calls to yank-last-arg
473 move back through the history list, inserting the last argument
474 of each line in turn. The history expansion facilities are used
475 to extract the last argument, as if the "!$" history expansion
476 had been specified.
477
478 Commands for Changing Text
479 delete-char (C-d)
480 Delete the character at point. If point is at the beginning of
481 the line, there are no characters in the line, and the last
482 character typed was not bound to delete-char, then return EOF.
483 backward-delete-char (Rubout)
484 Delete the character behind the cursor. When given a numeric
485 argument, save the deleted text on the kill ring.
486 forward-backward-delete-char
487 Delete the character under the cursor, unless the cursor is at
488 the end of the line, in which case the character behind the cur‐
489 sor is deleted.
490 quoted-insert (C-q, C-v)
491 Add the next character that you type to the line verbatim. This
492 is how to insert characters like C-q, for example.
493 tab-insert (M-TAB)
494 Insert a tab character.
495 self-insert (a, b, A, 1, !, ...)
496 Insert the character typed.
497 transpose-chars (C-t)
498 Drag the character before point forward over the character at
499 point, moving point forward as well. If point is at the end of
500 the line, then this transposes the two characters before point.
501 Negative arguments have no effect.
502 transpose-words (M-t)
503 Drag the word before point past the word after point, moving
504 point over that word as well. If point is at the end of the
505 line, this transposes the last two words on the line.
506 upcase-word (M-u)
507 Uppercase the current (or following) word. With a negative
508 argument, uppercase the previous word, but do not move point.
509 downcase-word (M-l)
510 Lowercase the current (or following) word. With a negative
511 argument, lowercase the previous word, but do not move point.
512 capitalize-word (M-c)
513 Capitalize the current (or following) word. With a negative
514 argument, capitalize the previous word, but do not move point.
515 overwrite-mode
516 Toggle overwrite mode. With an explicit positive numeric argu‐
517 ment, switches to overwrite mode. With an explicit non-positive
518 numeric argument, switches to insert mode. This command affects
519 only emacs mode; vi mode does overwrite differently. Each call
520 to readline() starts in insert mode. In overwrite mode, charac‐
521 ters bound to self-insert replace the text at point rather than
522 pushing the text to the right. Characters bound to back‐
523 ward-delete-char replace the character before point with a
524 space. By default, this command is unbound.
525
526 Killing and Yanking
527 kill-line (C-k)
528 Kill the text from point to the end of the line.
529 backward-kill-line (C-x Rubout)
530 Kill backward to the beginning of the line.
531 unix-line-discard (C-u)
532 Kill backward from point to the beginning of the line. The
533 killed text is saved on the kill-ring.
534 kill-whole-line
535 Kill all characters on the current line, no matter where point
536 is.
537 kill-word (M-d)
538 Kill from point the end of the current word, or if between
539 words, to the end of the next word. Word boundaries are the
540 same as those used by forward-word.
541 backward-kill-word (M-Rubout)
542 Kill the word behind point. Word boundaries are the same as
543 those used by backward-word.
544 unix-word-rubout (C-w)
545 Kill the word behind point, using white space as a word bound‐
546 ary. The killed text is saved on the kill-ring.
547 unix-filename-rubout
548 Kill the word behind point, using white space and the slash
549 character as the word boundaries. The killed text is saved on
550 the kill-ring.
551 delete-horizontal-space (M-\)
552 Delete all spaces and tabs around point.
553 kill-region
554 Kill the text between the point and mark (saved cursor posi‐
555 tion). This text is referred to as the region.
556 copy-region-as-kill
557 Copy the text in the region to the kill buffer.
558 copy-backward-word
559 Copy the word before point to the kill buffer. The word bound‐
560 aries are the same as backward-word.
561 copy-forward-word
562 Copy the word following point to the kill buffer. The word
563 boundaries are the same as forward-word.
564 yank (C-y)
565 Yank the top of the kill ring into the buffer at point.
566 yank-pop (M-y)
567 Rotate the kill ring, and yank the new top. Only works follow‐
568 ing yank or yank-pop.
569
570 Numeric Arguments
571 digit-argument (M-0, M-1, ..., M--)
572 Add this digit to the argument already accumulating, or start a
573 new argument. M-- starts a negative argument.
574 universal-argument
575 This is another way to specify an argument. If this command is
576 followed by one or more digits, optionally with a leading minus
577 sign, those digits define the argument. If the command is fol‐
578 lowed by digits, executing universal-argument again ends the
579 numeric argument, but is otherwise ignored. As a special case,
580 if this command is immediately followed by a character that is
581 neither a digit or minus sign, the argument count for the next
582 command is multiplied by four. The argument count is initially
583 one, so executing this function the first time makes the argu‐
584 ment count four, a second time makes the argument count sixteen,
585 and so on.
586
587 Completing
588 complete (TAB)
589 Attempt to perform completion on the text before point. The
590 actual completion performed is application-specific. Bash, for
591 instance, attempts completion treating the text as a variable
592 (if the text begins with $), username (if the text begins with
593 ~), hostname (if the text begins with @), or command (including
594 aliases and functions) in turn. If none of these produces a
595 match, filename completion is attempted. Gdb, on the other
596 hand, allows completion of program functions and variables, and
597 only attempts filename completion under certain circumstances.
598 possible-completions (M-?)
599 List the possible completions of the text before point.
600 insert-completions (M-*)
601 Insert all completions of the text before point that would have
602 been generated by possible-completions.
603 menu-complete
604 Similar to complete, but replaces the word to be completed with
605 a single match from the list of possible completions. Repeated
606 execution of menu-complete steps through the list of possible
607 completions, inserting each match in turn. At the end of the
608 list of completions, the bell is rung (subject to the setting of
609 bell-style) and the original text is restored. An argument of n
610 moves n positions forward in the list of matches; a negative
611 argument may be used to move backward through the list. This
612 command is intended to be bound to TAB, but is unbound by
613 default.
614 delete-char-or-list
615 Deletes the character under the cursor if not at the beginning
616 or end of the line (like delete-char). If at the end of the
617 line, behaves identically to possible-completions.
618
619 Keyboard Macros
620 start-kbd-macro (C-x ()
621 Begin saving the characters typed into the current keyboard
622 macro.
623 end-kbd-macro (C-x ))
624 Stop saving the characters typed into the current keyboard macro
625 and store the definition.
626 call-last-kbd-macro (C-x e)
627 Re-execute the last keyboard macro defined, by making the char‐
628 acters in the macro appear as if typed at the keyboard.
629
630 Miscellaneous
631 re-read-init-file (C-x C-r)
632 Read in the contents of the inputrc file, and incorporate any
633 bindings or variable assignments found there.
634 abort (C-g)
635 Abort the current editing command and ring the terminal's bell
636 (subject to the setting of bell-style).
637 do-uppercase-version (M-a, M-b, M-x, ...)
638 If the metafied character x is lowercase, run the command that
639 is bound to the corresponding uppercase character.
640 prefix-meta (ESC)
641 Metafy the next character typed. ESC f is equivalent to Meta-f.
642 undo (C-_, C-x C-u)
643 Incremental undo, separately remembered for each line.
644 revert-line (M-r)
645 Undo all changes made to this line. This is like executing the
646 undo command enough times to return the line to its initial
647 state.
648 tilde-expand (M-&)
649 Perform tilde expansion on the current word.
650 set-mark (C-@, M-<space>)
651 Set the mark to the point. If a numeric argument is supplied,
652 the mark is set to that position.
653 exchange-point-and-mark (C-x C-x)
654 Swap the point with the mark. The current cursor position is
655 set to the saved position, and the old cursor position is saved
656 as the mark.
657 character-search (C-])
658 A character is read and point is moved to the next occurrence of
659 that character. A negative count searches for previous occur‐
660 rences.
661 character-search-backward (M-C-])
662 A character is read and point is moved to the previous occur‐
663 rence of that character. A negative count searches for subse‐
664 quent occurrences.
665 insert-comment (M-#)
666 Without a numeric argument, the value of the readline com‐
667 ment-begin variable is inserted at the beginning of the current
668 line. If a numeric argument is supplied, this command acts as a
669 toggle: if the characters at the beginning of the line do not
670 match the value of comment-begin, the value is inserted, other‐
671 wise the characters in comment-begin are deleted from the begin‐
672 ning of the line. In either case, the line is accepted as if a
673 newline had been typed. The default value of comment-begin
674 makes the current line a shell comment. If a numeric argument
675 causes the comment character to be removed, the line will be
676 executed by the shell.
677 dump-functions
678 Print all of the functions and their key bindings to the read‐
679 line output stream. If a numeric argument is supplied, the out‐
680 put is formatted in such a way that it can be made part of an
681 inputrc file.
682 dump-variables
683 Print all of the settable variables and their values to the
684 readline output stream. If a numeric argument is supplied, the
685 output is formatted in such a way that it can be made part of an
686 inputrc file.
687 dump-macros
688 Print all of the readline key sequences bound to macros and the
689 strings they output. If a numeric argument is supplied, the
690 output is formatted in such a way that it can be made part of an
691 inputrc file.
692 emacs-editing-mode (C-e)
693 When in vi command mode, this causes a switch to emacs editing
694 mode.
695 vi-editing-mode (M-C-j)
696 When in emacs editing mode, this causes a switch to vi editing
697 mode.
698
700 The following is a list of the default emacs and vi bindings. Charac‐
701 ters with the eighth bit set are written as M-<character>, and are
702 referred to as metafied characters. The printable ASCII characters not
703 mentioned in the list of emacs standard bindings are bound to the
704 self-insert function, which just inserts the given character into the
705 input line. In vi insertion mode, all characters not specifically men‐
706 tioned are bound to self-insert. Characters assigned to signal genera‐
707 tion by stty(1) or the terminal driver, such as C-Z or C-C, retain that
708 function. Upper and lower case metafied characters are bound to the
709 same function in the emacs mode meta keymap. The remaining characters
710 are unbound, which causes readline to ring the bell (subject to the
711 setting of the bell-style variable).
712
713 Emacs Mode
714 Emacs Standard bindings
715
716 "C-@" set-mark
717 "C-A" beginning-of-line
718 "C-B" backward-char
719 "C-D" delete-char
720 "C-E" end-of-line
721 "C-F" forward-char
722 "C-G" abort
723 "C-H" backward-delete-char
724 "C-I" complete
725 "C-J" accept-line
726 "C-K" kill-line
727 "C-L" clear-screen
728 "C-M" accept-line
729 "C-N" next-history
730 "C-P" previous-history
731 "C-Q" quoted-insert
732 "C-R" reverse-search-history
733 "C-S" forward-search-history
734 "C-T" transpose-chars
735 "C-U" unix-line-discard
736 "C-V" quoted-insert
737 "C-W" unix-word-rubout
738 "C-Y" yank
739 "C-]" character-search
740 "C-_" undo
741 " " to "/" self-insert
742 "0" to "9" self-insert
743 ":" to "~" self-insert
744 "C-?" backward-delete-char
745
746 Emacs Meta bindings
747
748 "M-C-G" abort
749 "M-C-H" backward-kill-word
750 "M-C-I" tab-insert
751 "M-C-J" vi-editing-mode
752 "M-C-M" vi-editing-mode
753 "M-C-R" revert-line
754 "M-C-Y" yank-nth-arg
755 "M-C-[" complete
756 "M-C-]" character-search-backward
757 "M-space" set-mark
758 "M-#" insert-comment
759 "M-&" tilde-expand
760 "M-*" insert-completions
761 "M--" digit-argument
762 "M-." yank-last-arg
763 "M-0" digit-argument
764 "M-1" digit-argument
765 "M-2" digit-argument
766 "M-3" digit-argument
767 "M-4" digit-argument
768 "M-5" digit-argument
769 "M-6" digit-argument
770 "M-7" digit-argument
771 "M-8" digit-argument
772 "M-9" digit-argument
773 "M-<" beginning-of-history
774 "M-=" possible-completions
775 "M->" end-of-history
776 "M-?" possible-completions
777 "M-B" backward-word
778 "M-C" capitalize-word
779 "M-D" kill-word
780 "M-F" forward-word
781 "M-L" downcase-word
782 "M-N" non-incremental-forward-search-history
783 "M-P" non-incremental-reverse-search-history
784 "M-R" revert-line
785 "M-T" transpose-words
786 "M-U" upcase-word
787 "M-Y" yank-pop
788 "M-\" delete-horizontal-space
789 "M-~" tilde-expand
790 "M-C-?" backward-kill-word
791 "M-_" yank-last-arg
792
793 Emacs Control-X bindings
794
795 "C-XC-G" abort
796 "C-XC-R" re-read-init-file
797 "C-XC-U" undo
798 "C-XC-X" exchange-point-and-mark
799 "C-X(" start-kbd-macro
800 "C-X)" end-kbd-macro
801 "C-XE" call-last-kbd-macro
802 "C-XC-?" backward-kill-line
803
804
805 VI Mode bindings
806 VI Insert Mode functions
807
808 "C-D" vi-eof-maybe
809 "C-H" backward-delete-char
810 "C-I" complete
811 "C-J" accept-line
812 "C-M" accept-line
813 "C-R" reverse-search-history
814 "C-S" forward-search-history
815 "C-T" transpose-chars
816 "C-U" unix-line-discard
817 "C-V" quoted-insert
818 "C-W" unix-word-rubout
819 "C-Y" yank
820 "C-[" vi-movement-mode
821 "C-_" undo
822 " " to "~" self-insert
823 "C-?" backward-delete-char
824
825 VI Command Mode functions
826
827 "C-D" vi-eof-maybe
828 "C-E" emacs-editing-mode
829 "C-G" abort
830 "C-H" backward-char
831 "C-J" accept-line
832 "C-K" kill-line
833 "C-L" clear-screen
834 "C-M" accept-line
835 "C-N" next-history
836 "C-P" previous-history
837 "C-Q" quoted-insert
838 "C-R" reverse-search-history
839 "C-S" forward-search-history
840 "C-T" transpose-chars
841 "C-U" unix-line-discard
842 "C-V" quoted-insert
843 "C-W" unix-word-rubout
844 "C-Y" yank
845 "C-_" vi-undo
846 " " forward-char
847 "#" insert-comment
848 "$" end-of-line
849 "%" vi-match
850 "&" vi-tilde-expand
851 "*" vi-complete
852 "+" next-history
853 "," vi-char-search
854 "-" previous-history
855 "." vi-redo
856 "/" vi-search
857 "0" beginning-of-line
858 "1" to "9" vi-arg-digit
859 ";" vi-char-search
860 "=" vi-complete
861 "?" vi-search
862 "A" vi-append-eol
863 "B" vi-prev-word
864 "C" vi-change-to
865 "D" vi-delete-to
866 "E" vi-end-word
867 "F" vi-char-search
868 "G" vi-fetch-history
869 "I" vi-insert-beg
870 "N" vi-search-again
871 "P" vi-put
872 "R" vi-replace
873 "S" vi-subst
874 "T" vi-char-search
875 "U" revert-line
876 "W" vi-next-word
877 "X" backward-delete-char
878 "Y" vi-yank-to
879 "\" vi-complete
880 "^" vi-first-print
881 "_" vi-yank-arg
882 "`" vi-goto-mark
883 "a" vi-append-mode
884 "b" vi-prev-word
885 "c" vi-change-to
886 "d" vi-delete-to
887 "e" vi-end-word
888 "f" vi-char-search
889 "h" backward-char
890 "i" vi-insertion-mode
891 "j" next-history
892 "k" prev-history
893 "l" forward-char
894 "m" vi-set-mark
895 "n" vi-search-again
896 "p" vi-put
897 "r" vi-change-char
898 "s" vi-subst
899 "t" vi-char-search
900 "u" vi-undo
901 "w" vi-next-word
902 "x" vi-delete
903 "y" vi-yank-to
904 "|" vi-column
905 "~" vi-change-case
906
908 The Gnu Readline Library, Brian Fox and Chet Ramey
909 The Gnu History Library, Brian Fox and Chet Ramey
910 bash(1)
911
913 ~/.inputrc
914 Individual readline initialization file
915
917 Brian Fox, Free Software Foundation
918 bfox@gnu.org
919
920 Chet Ramey, Case Western Reserve University
921 chet@ins.CWRU.Edu
922
924 If you find a bug in readline, you should report it. But first, you
925 should make sure that it really is a bug, and that it appears in the
926 latest version of the readline library that you have.
927
928 Once you have determined that a bug actually exists, mail a bug report
929 to bug-readline@gnu.org. If you have a fix, you are welcome to mail
930 that as well! Suggestions and `philosophical' bug reports may be
931 mailed to bug-readline@gnu.org or posted to the Usenet newsgroup
932 gnu.bash.bug.
933
934 Comments and bug reports concerning this manual page should be directed
935 to chet@ins.CWRU.Edu.
936
938 It's too big and too slow.
939
940
941
942GNU Readline 6.0 2008 May 8 READLINE(3)