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