* v850-dis.c (disassemble): Handle insertion of ',', '[' and
[deliverable/binutils-gdb.git] / readline / doc / rluser.texinfo
CommitLineData
be9485d5
SG
1@ignore
2This file documents the end user interface to the GNU command line
3editing feautres. It is to be an appendix to manuals for programs which
4use these features. There is a document entitled "readline.texinfo"
5which contains both end-user and programmer documentation for the GNU
6Readline Library.
7
8Copyright (C) 1988 Free Software Foundation, Inc.
9
10Authored by Brian Fox.
11
12Permission is granted to process this file through Tex and print the
13results, provided the printed document carries copying permission notice
14identical to this one except for the removal of this paragraph (this
15paragraph not being relevant to the printed manual).
16
17Permission is granted to make and distribute verbatim copies of this manual
18provided the copyright notice and this permission notice are preserved on
19all copies.
20
21Permission is granted to copy and distribute modified versions of this
22manual under the conditions for verbatim copying, provided also that the
23GNU Copyright statement is available to the distributee, and provided that
24the entire resulting derived work is distributed under the terms of a
25permission notice identical to this one.
26
27Permission is granted to copy and distribute translations of this manual
28into another language, under the above conditions for modified versions.
29@end ignore
30
31@node Command Line Editing
b621d050 32@appendix Command Line Editing
be9485d5
SG
33
34This text describes GNU's command line editing interface.
35
36@menu
37* Introduction and Notation:: Notation used in this text.
38* Readline Interaction:: The minimum set of commands for editing a line.
39* Readline Init File:: Customizing Readline from a user's view.
40@end menu
41
42@node Introduction and Notation
43@section Introduction to Line Editing
44
45The following paragraphs describe the notation we use to represent
46keystrokes.
47
48The text @key{C-k} is read as `Control-K' and describes the character
49produced when the Control key is depressed and the @key{k} key is struck.
50
51The text @key{M-k} is read as `Meta-K' and describes the character
52produced when the meta key (if you have one) is depressed, and the @key{k}
53key is struck. If you do not have a meta key, the identical keystroke
54can be generated by typing @key{ESC} @i{first}, and then typing @key{k}.
55Either process is known as @dfn{metafying} the @key{k} key.
56
57The text @key{M-C-k} is read as `Meta-Control-k' and describes the
58character produced by @dfn{metafying} @key{C-k}.
59
60In addition, several keys have their own names. Specifically,
61@key{DEL}, @key{ESC}, @key{LFD}, @key{SPC}, @key{RET}, and @key{TAB} all
62stand for themselves when seen in this text, or in an init file
63(@pxref{Readline Init File}, for more info).
64
65@node Readline Interaction
66@section Readline Interaction
67@cindex interaction, readline
68
69Often during an interactive session you type in a long line of text,
70only to notice that the first word on the line is misspelled. The
71Readline library gives you a set of commands for manipulating the text
72as you type it in, allowing you to just fix your typo, and not forcing
73you to retype the majority of the line. Using these editing commands,
74you move the cursor to the place that needs correction, and delete or
75insert the text of the corrections. Then, when you are satisfied with
f9e903ee
VM
76the line, you simply press @key{RET}. You do not have to be at the
77end of the line to press @key{RET}; the entire line is accepted
be9485d5
SG
78regardless of the location of the cursor within the line.
79
80@menu
81* Readline Bare Essentials:: The least you need to know about Readline.
82* Readline Movement Commands:: Moving about the input line.
83* Readline Killing Commands:: How to delete text, and how to get it back!
84* Readline Arguments:: Giving numeric arguments to commands.
85@end menu
86
87@node Readline Bare Essentials
88@subsection Readline Bare Essentials
89
90In order to enter characters into the line, simply type them. The typed
91character appears where the cursor was, and then the cursor moves one
92space to the right. If you mistype a character, you can use @key{DEL} to
93back up, and delete the mistyped character.
94
95Sometimes you may miss typing a character that you wanted to type, and
96not notice your error until you have typed several other characters. In
97that case, you can type @key{C-b} to move the cursor to the left, and then
98correct your mistake. Aftwerwards, you can move the cursor to the right
99with @key{C-f}.
100
101When you add text in the middle of a line, you will notice that characters
102to the right of the cursor get `pushed over' to make room for the text
103that you have inserted. Likewise, when you delete text behind the cursor,
104characters to the right of the cursor get `pulled back' to fill in the
105blank space created by the removal of the text. A list of the basic bare
106essentials for editing the text of an input line follows.
107
108@table @asis
109@item @key{C-b}
110Move back one character.
111@item @key{C-f}
112Move forward one character.
113@item @key{DEL}
114Delete the character to the left of the cursor.
115@item @key{C-d}
116Delete the character underneath the cursor.
117@item @w{Printing characters}
118Insert itself into the line at the cursor.
119@item @key{C-_}
120Undo the last thing that you did. You can undo all the way back to an
121empty line.
122@end table
123
124@node Readline Movement Commands
125@subsection Readline Movement Commands
126
be9485d5
SG
127The above table describes the most basic possible keystrokes that you need
128in order to do editing of the input line. For your convenience, many
129other commands have been added in addition to @key{C-b}, @key{C-f},
130@key{C-d}, and @key{DEL}. Here are some commands for moving more rapidly
131about the line.
132
133@table @key
134@item C-a
135Move to the start of the line.
136@item C-e
137Move to the end of the line.
138@item M-f
139Move forward a word.
140@item M-b
141Move backward a word.
142@item C-l
143Clear the screen, reprinting the current line at the top.
144@end table
145
146Notice how @key{C-f} moves forward a character, while @key{M-f} moves
147forward a word. It is a loose convention that control keystrokes
148operate on characters while meta keystrokes operate on words.
149
150@node Readline Killing Commands
151@subsection Readline Killing Commands
152
be9485d5
SG
153@dfn{Killing} text means to delete the text from the line, but to save
154it away for later use, usually by @dfn{yanking} it back into the line.
155If the description for a command says that it `kills' text, then you can
156be sure that you can get the text back in a different (or the same)
157place later.
158
159Here is the list of commands for killing text.
160
161@table @key
162@item C-k
163Kill the text from the current cursor position to the end of the line.
164
165@item M-d
166Kill from the cursor to the end of the current word, or if between
167words, to the end of the next word.
168
169@item M-DEL
e62b9411
RP
170Kill from the cursor to the start of the previous word, or if between
171words, to the start of the previous word.
be9485d5
SG
172
173@item C-w
174Kill from the cursor to the previous whitespace. This is different than
175@key{M-DEL} because the word boundaries differ.
176
177@end table
178
f9e903ee 179And, here is how to @dfn{yank} the text back into the line.
be9485d5
SG
180
181@table @key
182@item C-y
183Yank the most recently killed text back into the buffer at the cursor.
184
185@item M-y
186Rotate the kill-ring, and yank the new top. You can only do this if
187the prior command is @key{C-y} or @key{M-y}.
188@end table
189
190When you use a kill command, the text is saved in a @dfn{kill-ring}.
191Any number of consecutive kills save all of the killed text together, so
192that when you yank it back, you get it in one clean sweep. The kill
193ring is not line specific; the text that you killed on a previously
194typed line is available to be yanked back later, when you are typing
195another line.
196
197@node Readline Arguments
198@subsection Readline Arguments
199
200You can pass numeric arguments to Readline commands. Sometimes the
201argument acts as a repeat count, other times it is the @i{sign} of the
202argument that is significant. If you pass a negative argument to a
203command which normally acts in a forward direction, that command will
204act in a backward direction. For example, to kill text back to the
205start of the line, you might type @key{M--} @key{C-k}.
206
207The general way to pass numeric arguments to a command is to type meta
208digits before the command. If the first `digit' you type is a minus
209sign (@key{-}), then the sign of the argument will be negative. Once
210you have typed one meta digit to get the argument started, you can type
211the remainder of the digits, and then the command. For example, to give
212the @key{C-d} command an argument of 10, you could type @key{M-1 0 C-d}.
213
214
215@node Readline Init File
216@section Readline Init File
217
f9e903ee 218Although the Readline library comes with a set of @sc{gnu} Emacs-like
be9485d5
SG
219keybindings, it is possible that you would like to use a different set
220of keybindings. You can customize programs that use Readline by putting
221commands in an @dfn{init} file in your home directory. The name of this
222file is @file{~/.inputrc}.
223
224When a program which uses the Readline library starts up, the
225@file{~/.inputrc} file is read, and the keybindings are set.
226
0eb75940 227In addition, the @key{C-x C-r} command re-reads this init file, thus
be9485d5
SG
228incorporating any changes that you might have made to it.
229
230@menu
231* Readline Init Syntax:: Syntax for the commands in @file{~/.inputrc}.
f9e903ee 232* Readline vi Mode:: Switching to @code{vi} mode in Readline.
be9485d5
SG
233@end menu
234
235@node Readline Init Syntax
236@subsection Readline Init Syntax
237
238There are only four constructs allowed in the @file{~/.inputrc}
239file:
240
241@table @asis
242@item Variable Settings
243You can change the state of a few variables in Readline. You do this by
244using the @code{set} command within the init file. Here is how you
f9e903ee 245would specify that you wish to use @code{vi} line editing commands:
be9485d5
SG
246
247@example
248set editing-mode vi
249@end example
250
251Right now, there are only a few variables which can be set; so few in
252fact, that we just iterate them here:
253
254@table @code
255
256@item editing-mode
257@vindex editing-mode
258The @code{editing-mode} variable controls which editing mode you are
f9e903ee 259using. By default, @sc{gnu} Readline starts up in Emacs editing mode, where
be9485d5
SG
260the keystrokes are most similar to Emacs. This variable can either be
261set to @code{emacs} or @code{vi}.
262
263@item horizontal-scroll-mode
264@vindex horizontal-scroll-mode
265This variable can either be set to @code{On} or @code{Off}. Setting it
266to @code{On} means that the text of the lines that you edit will scroll
267horizontally on a single screen line when they are larger than the width
268of the screen, instead of wrapping onto a new screen line. By default,
269this variable is set to @code{Off}.
270
271@item mark-modified-lines
272@vindex mark-modified-lines
273This variable when set to @code{On}, says to display an asterisk
274(@samp{*}) at the starts of history lines which have been modified.
275This variable is off by default.
276
277@item prefer-visible-bell
278@vindex prefer-visible-bell
279If this variable is set to @code{On} it means to use a visible bell if
280one is available, rather than simply ringing the terminal bell. By
281default, the value is @code{Off}.
282@end table
283
284@item Key Bindings
285The syntax for controlling keybindings in the @file{~/.inputrc} file is
286simple. First you have to know the @i{name} of the command that you
287want to change. The following pages contain tables of the command name,
288the default keybinding, and a short description of what the command
289does.
290
291Once you know the name of the command, simply place the name of the key
292you wish to bind the command to, a colon, and then the name of the
293command on a line in the @file{~/.inputrc} file. The name of the key
294can be expressed in different ways, depending on which is most
295comfortable for you.
296
297@table @asis
298@item @w{@var{keyname}: @var{function-name} or @var{macro}}
299@var{keyname} is the name of a key spelled out in English. For example:
300@example
301Control-u: universal-argument
302Meta-Rubout: backward-kill-word
303Control-o: ">&output"
304@end example
305
0eb75940
RP
306In the above example, @key{C-u} is bound to the function
307@code{universal-argument}, and @key{C-o} is bound to run the macro
be9485d5
SG
308expressed on the right hand side (that is, to insert the text
309@samp{>&output} into the line).
310
311@item @w{"@var{keyseq}": @var{function-name} or @var{macro}}
312@var{keyseq} differs from @var{keyname} above in that strings denoting
313an entire key sequence can be specified. Simply place the key sequence
f9e903ee 314in double quotes. @sc{gnu} Emacs style key escapes can be used, as in the
be9485d5
SG
315following example:
316
317@example
318"\C-u": universal-argument
319"\C-x\C-r": re-read-init-file
320"\e[11~": "Function Key 1"
321@end example
322
0eb75940 323In the above example, @key{C-u} is bound to the function
be9485d5 324@code{universal-argument} (just as it was in the first example),
0eb75940
RP
325@key{C-x C-r} is bound to the function @code{re-read-init-file}, and
326@key{ESC [ 1 1 ~} is bound to insert the text @samp{Function Key 1}.
be9485d5
SG
327
328@end table
329@end table
330
331@menu
332* Commands For Moving:: Moving about the line.
333* Commands For History:: Getting at previous lines.
334* Commands For Text:: Commands for changing text.
335* Commands For Killing:: Commands for killing and yanking.
336* Numeric Arguments:: Specifying numeric arguments, repeat counts.
337* Commands For Completion:: Getting Readline to do the typing for you.
338* Miscellaneous Commands:: Other miscillaneous commands.
339@end menu
340
b1955f0b 341@need 2000
be9485d5
SG
342@node Commands For Moving
343@subsubsection Commands For Moving
b1955f0b 344
be9485d5 345@ftable @code
0eb75940 346@item beginning-of-line (@key{C-a})
be9485d5
SG
347Move to the start of the current line.
348
0eb75940 349@item end-of-line (@key{C-e})
be9485d5
SG
350Move to the end of the line.
351
0eb75940 352@item forward-char (@key{C-f})
be9485d5
SG
353Move forward a character.
354
0eb75940 355@item backward-char (@key{C-b})
be9485d5
SG
356Move back a character.
357
0eb75940 358@item forward-word (@key{M-f})
be9485d5
SG
359Move forward to the end of the next word.
360
0eb75940 361@item backward-word (@key{M-b})
be9485d5
SG
362Move back to the start of this, or the previous, word.
363
0eb75940 364@item clear-screen (@key{C-l})
be9485d5
SG
365Clear the screen leaving the current line at the top of the screen.
366
367@end ftable
368
b1955f0b 369@need 2000
be9485d5
SG
370@node Commands For History
371@subsubsection Commands For Manipulating The History
372
373@ftable @code
374@item accept-line (Newline, Return)
375Accept the line regardless of where the cursor is. If this line is
376non-empty, add it to the history list. If this line was a history
377line, then restore the history line to its original state.
378
0eb75940 379@item previous-history (@key{C-p})
be9485d5
SG
380Move `up' through the history list.
381
0eb75940 382@item next-history (@key{C-n})
be9485d5
SG
383Move `down' through the history list.
384
0eb75940 385@item beginning-of-history (@key{M-<})
be9485d5
SG
386Move to the first line in the history.
387
0eb75940 388@item end-of-history (@key{M->})
f9e903ee 389Move to the end of the input history, i.e., the line you are entering.
be9485d5 390
0eb75940 391@item reverse-search-history (@key{C-r})
be9485d5
SG
392Search backward starting at the current line and moving `up' through
393the history as necessary. This is an incremental search.
394
0eb75940 395@item forward-search-history (@key{C-s})
be9485d5 396Search forward starting at the current line and moving `down' through
b1955f0b 397the the history as necessary.
be9485d5
SG
398
399@end ftable
400
b1955f0b 401@need 2000
be9485d5
SG
402@node Commands For Text
403@subsubsection Commands For Changing Text
404
405@ftable @code
0eb75940 406@item delete-char (@key{C-d})
be9485d5
SG
407Delete the character under the cursor. If the cursor is at the
408beginning of the line, and there are no characters in the line, and
0eb75940 409the last character typed was not @key{C-d}, then return EOF.
be9485d5
SG
410
411@item backward-delete-char (Rubout)
f9e903ee 412Delete the character behind the cursor. A numeric argument says to kill
be9485d5
SG
413the characters instead of deleting them.
414
0eb75940 415@item quoted-insert (@key{C-q}, @key{C-v})
be9485d5 416Add the next character that you type to the line verbatim. This is
0eb75940 417how to insert things like @key{C-q} for example.
be9485d5 418
0eb75940 419@item tab-insert (@key{M-TAB})
be9485d5
SG
420Insert a tab character.
421
422@item self-insert (a, b, A, 1, !, ...)
423Insert yourself.
424
0eb75940 425@item transpose-chars (@key{C-t})
be9485d5
SG
426Drag the character before point forward over the character at point.
427Point moves forward as well. If point is at the end of the line, then
f9e903ee 428transpose the two characters before point. Negative arguments don't work.
be9485d5 429
0eb75940 430@item transpose-words (@key{M-t})
be9485d5
SG
431Drag the word behind the cursor past the word in front of the cursor
432moving the cursor over that word as well.
433
0eb75940 434@item upcase-word (@key{M-u})
5736b286
RP
435Uppercase all letters in the current (or following) word. With a
436negative argument, do the previous word, but do not move point.
be9485d5 437
0eb75940 438@item downcase-word (@key{M-l})
5736b286
RP
439Lowercase all letters in the current (or following) word. With a
440negative argument, do the previous word, but do not move point.
be9485d5 441
0eb75940 442@item capitalize-word (@key{M-c})
5736b286
RP
443Uppercase the first letter in the current (or following) word. With a
444negative argument, do the previous word, but do not move point.
be9485d5
SG
445
446@end ftable
447
b1955f0b 448@need 2000
be9485d5
SG
449@node Commands For Killing
450@subsubsection Killing And Yanking
451
452@ftable @code
0eb75940 453@item kill-line (@key{C-k})
be9485d5
SG
454Kill the text from the current cursor position to the end of the line.
455
456@item backward-kill-line ()
457Kill backward to the beginning of the line. This is normally unbound.
458
0eb75940 459@item kill-word (@key{M-d})
be9485d5
SG
460Kill from the cursor to the end of the current word, or if between
461words, to the end of the next word.
462
0eb75940 463@item backward-kill-word (@key{M-DEL})
be9485d5
SG
464Kill the word behind the cursor.
465
0eb75940 466@item unix-line-discard (@key{C-u})
f9e903ee
VM
467Kill the whole line the way @key{C-u} used to in Unix line input.
468The killed text is saved on the kill-ring.
be9485d5 469
0eb75940 470@item unix-word-rubout (@key{C-w})
f9e903ee
VM
471Kill the word the way @key{C-w} used to in Unix line input.
472The killed text is saved on the kill-ring. This is different than
473backward-kill-word because the word boundaries differ.
be9485d5 474
0eb75940 475@item yank (@key{C-y})
be9485d5
SG
476Yank the top of the kill ring into the buffer at point.
477
0eb75940 478@item yank-pop (@key{M-y})
be9485d5
SG
479Rotate the kill-ring, and yank the new top. You can only do this if
480the prior command is yank or yank-pop.
481@end ftable
482
b1955f0b 483@need 2000
be9485d5
SG
484@node Numeric Arguments
485@subsubsection Specifying Numeric Arguments
b1955f0b 486
be9485d5
SG
487@ftable @code
488
0eb75940 489@item digit-argument (@key{M-0}, @key{M-1}, ... @key{M--})
be9485d5 490Add this digit to the argument already accumulating, or start a new
0eb75940 491argument. @key{M--} starts a negative argument.
be9485d5
SG
492
493@item universal-argument ()
f9e903ee 494Do what @key{C-u} does in @sc{gnu} Emacs. By default, this is not bound.
be9485d5
SG
495@end ftable
496
497
b1955f0b 498@need 2000
be9485d5
SG
499@node Commands For Completion
500@subsubsection Letting Readline Type For You
501
502@ftable @code
503@item complete (TAB)
504Attempt to do completion on the text before point. This is
505implementation defined. Generally, if you are typing a filename
506argument, you can do filename completion; if you are typing a command,
507you can do command completion, if you are typing in a symbol to GDB, you
508can do symbol name completion, if you are typing in a variable to Bash,
f9e903ee 509you can do variable name completion.
be9485d5
SG
510
511@item possible-completions (M-?)
512List the possible completions of the text before point.
513@end ftable
514
b1955f0b 515@need 2000
be9485d5
SG
516@node Miscellaneous Commands
517@subsubsection Some Miscellaneous Commands
b1955f0b 518
be9485d5
SG
519@ftable @code
520
0eb75940 521@item re-read-init-file (@key{C-x} @key{C-r})
be9485d5
SG
522Read in the contents of your @file{~/.inputrc} file, and incorporate
523any bindings found there.
524
0eb75940 525@item abort (@key{C-g})
5736b286 526Stop running the current editing command.
be9485d5 527
5736b286
RP
528@ignore
529@c I have no idea what this means, and can't figure it out by
530@c experiment, and can't find it in the readline source.
aa917e71 531@c doc@cygnus.com, 20may1993.
0eb75940 532@item do-uppercase-version (@key{M-a}, @key{M-b}, ...)
be9485d5 533Run the command that is bound to your uppercase brother.
5736b286 534@end ignore
be9485d5
SG
535
536@item prefix-meta (ESC)
537Make the next character that you type be metafied. This is for people
0eb75940
RP
538without a meta key. Typing @key{ESC f} is equivalent to typing
539@key{M-f}.
be9485d5 540
0eb75940 541@item undo (@key{C-_})
be9485d5
SG
542Incremental undo, separately remembered for each line.
543
0eb75940 544@item revert-line (@key{M-r})
be9485d5
SG
545Undo all changes made to this line. This is like typing the `undo'
546command enough times to get back to the beginning.
547@end ftable
548
b1955f0b 549@need 2000
f9e903ee
VM
550@node Readline vi Mode
551@subsection Readline @code{vi} Mode
be9485d5 552
f8039a88
RP
553@cindex @code{vi} style command editing
554@kindex toggle-editing-mode
f9e903ee 555While the Readline library does not have a full set of @code{vi} editing
be9485d5
SG
556functions, it does contain enough to allow simple editing of the line.
557
f9e903ee
VM
558In order to switch interactively between @sc{gnu} Emacs and @code{vi}
559editing modes, use the command @key{M-C-j} (toggle-editing-mode).
be9485d5 560
f9e903ee 561When you enter a line in @code{vi} mode, you are already placed in `insertion'
be9485d5
SG
562mode, as if you had typed an `i'. Pressing @key{ESC} switches you into
563`edit' mode, where you can edit the text of the line with the standard
f9e903ee 564@code{vi} movement keys, move to previous history lines with `k', and following
be9485d5
SG
565lines with `j', and so forth.
566
This page took 0.18484 seconds and 4 git commands to generate.