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