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