📄 rluser.texinfo
字号:
@comment %**start of header (This is for running Texinfo on a region.)@setfilename rluser.info@comment %**end of header (This is for running Texinfo on a region.)@setchapternewpage odd@ignoreThis file documents the end user interface to the GNU command lineediting features. It is to be an appendix to manuals for programs whichuse these features. There is a document entitled "readline.texinfo"which contains both end-user and programmer documentation for the GNUReadline Library.Copyright (C) 1988 Free Software Foundation, Inc.Authored by Brian Fox and Chet Ramey.Permission is granted to process this file through Tex and print theresults, provided the printed document carries copying permission noticeidentical to this one except for the removal of this paragraph (thisparagraph not being relevant to the printed manual).Permission is granted to make and distribute verbatim copies of this manualprovided the copyright notice and this permission notice are preserved onall copies.Permission is granted to copy and distribute modified versions of thismanual under the conditions for verbatim copying, provided also that theGNU Copyright statement is available to the distributee, and provided thatthe entire resulting derived work is distributed under the terms of apermission notice identical to this one.Permission is granted to copy and distribute translations of this manualinto another language, under the above conditions for modified versions.@end ignore@comment If you are including this manual as an appendix, then set the@comment variable readline-appendix.@node Command Line Editing@chapter Command Line EditingThis chapter describes the basic features of the GNUcommand line editing interface.@menu* Introduction and Notation:: Notation used in this text.* Readline Interaction:: The minimum set of commands for editing a line.* Readline Init File:: Customizing Readline from a user's view.* Bindable Readline Commands:: A description of most of the Readline commands available for binding* Readline vi Mode:: A short description of how to make Readline behave like the vi editor.@end menu@node Introduction and Notation@section Introduction to Line EditingThe following paragraphs describe the notation used to representkeystrokes.The text @key{C-k} is read as `Control-K' and describes the characterproduced when the Control key is depressed and the @key{k} key is struck.The text @key{M-k} is read as `Meta-K' and describes the characterproduced when the meta key (if you have one) is depressed, and the @key{k}key is struck. If you do not have a meta key, the identical keystrokecan be generated by typing @key{ESC} @i{first}, and then typing @key{k}.Either process is known as @dfn{metafying} the @key{k} key.The text @key{M-C-k} is read as `Meta-Control-k' and describes thecharacter produced by @dfn{metafying} @key{C-k}.In addition, several keys have their own names. Specifically,@key{DEL}, @key{ESC}, @key{LFD}, @key{SPC}, @key{RET}, and @key{TAB} allstand for themselves when seen in this text, or in an init file(@pxref{Readline Init File}, for more info).@node Readline Interaction@section Readline Interaction@cindex interaction, readlineOften during an interactive session you type in a long line of text,only to notice that the first word on the line is misspelled. TheReadline library gives you a set of commands for manipulating the textas you type it in, allowing you to just fix your typo, and not forcingyou to retype the majority of the line. Using these editing commands,you move the cursor to the place that needs correction, and delete orinsert the text of the corrections. Then, when you are satisfied withthe line, you simply press @key{RETURN}. You do not have to be at theend of the line to press @key{RETURN}; the entire line is acceptedregardless of the location of the cursor within the line.@menu* Readline Bare Essentials:: The least you need to know about Readline.* Readline Movement Commands:: Moving about the input line.* Readline Killing Commands:: How to delete text, and how to get it back!* Readline Arguments:: Giving numeric arguments to commands.@end menu@node Readline Bare Essentials@subsection Readline Bare EssentialsIn order to enter characters into the line, simply type them. The typedcharacter appears where the cursor was, and then the cursor moves onespace to the right. If you mistype a character, you can use yourerase character to back up and delete the mistyped character.Sometimes you may miss typing a character that you wanted to type, andnot notice your error until you have typed several other characters. Inthat case, you can type @key{C-b} to move the cursor to the left, and thencorrect your mistake. Afterwards, you can move the cursor to the rightwith @key{C-f}.When you add text in the middle of a line, you will notice that charactersto the right of the cursor are `pushed over' to make room for the textthat you have inserted. Likewise, when you delete text behind the cursor,characters to the right of the cursor are `pulled back' to fill in theblank space created by the removal of the text. A list of the basic bareessentials for editing the text of an input line follows.@table @asis@item @key{C-b}Move back one character.@item @key{C-f}Move forward one character.@item @key{DEL}Delete the character to the left of the cursor.@item @key{C-d}Delete the character underneath the cursor.@item @w{Printing characters}Insert the character into the line at the cursor.@item @key{C-_}Undo the last thing that you did. You can undo all the way back to anempty line.@end table@node Readline Movement Commands@subsection Readline Movement CommandsThe above table describes the most basic possible keystrokes that you needin order to do editing of the input line. For your convenience, manyother commands have been added in addition to @key{C-b}, @key{C-f},@key{C-d}, and @key{DEL}. Here are some commands for moving more rapidlyabout the line.@table @key@item C-aMove to the start of the line.@item C-eMove to the end of the line.@item M-fMove forward a word.@item M-bMove backward a word.@item C-lClear the screen, reprinting the current line at the top.@end tableNotice how @key{C-f} moves forward a character, while @key{M-f} movesforward a word. It is a loose convention that control keystrokesoperate on characters while meta keystrokes operate on words.@node Readline Killing Commands@subsection Readline Killing Commands@cindex Killing text@cindex Yanking text@dfn{Killing} text means to delete the text from the line, but to saveit away for later use, usually by @dfn{yanking} (re-inserting)it back into the line.If the description for a command says that it `kills' text, then you canbe sure that you can get the text back in a different (or the same)place later.When you use a kill command, the text is saved in a @dfn{kill-ring}.Any number of consecutive kills save all of the killed text together, sothat when you yank it back, you get it all. The killring is not line specific; the text that you killed on a previouslytyped line is available to be yanked back later, when you are typinganother line.@cindex Kill ringHere is the list of commands for killing text.@table @key@item C-kKill the text from the current cursor position to the end of the line.@item M-dKill from the cursor to the end of the current word, or if betweenwords, to the end of the next word.@item M-DELKill from the cursor the start of the previous word, or if betweenwords, to the start of the previous word.@item C-wKill from the cursor to the previous whitespace. This is different than@key{M-DEL} because the word boundaries differ.@end tableAnd, here is how to @dfn{yank} the text back into the line. Yankingmeans to copy the most-recently-killed text from the kill buffer.@table @key@item C-yYank the most recently killed text back into the buffer at the cursor.@item M-yRotate the kill-ring, and yank the new top. You can only do this ifthe prior command is @key{C-y} or @key{M-y}.@end table@node Readline Arguments@subsection Readline ArgumentsYou can pass numeric arguments to Readline commands. Sometimes theargument acts as a repeat count, other times it is the @i{sign} of theargument that is significant. If you pass a negative argument to acommand which normally acts in a forward direction, that command willact in a backward direction. For example, to kill text back to thestart of the line, you might type @key{M--} @key{C-k}.The general way to pass numeric arguments to a command is to type metadigits before the command. If the first `digit' you type is a minussign (@key{-}), then the sign of the argument will be negative. Onceyou have typed one meta digit to get the argument started, you can typethe remainder of the digits, and then the command. For example, to givethe @key{C-d} command an argument of 10, you could type @key{M-1 0 C-d}.@node Readline Init File@section Readline Init FileAlthough the Readline library comes with a set of Emacs-likekeybindings installed by default,it is possible that you would like to use a different setof keybindings. You can customize programs that use Readline by puttingcommands in an @dfn{init} file in your home directory. The name of this@ifset BashFeaturesfile is taken from the value of the shell variable @code{INPUTRC}. If@end ifset@ifclear BashFeaturesfile is taken from the value of the environment variable @code{INPUTRC}. If@end ifclearthat variable is unset, the default is @file{~/.inputrc}.When a program which uses the Readline library starts up, theinit file is read, and the key bindings are set.In addition, the @code{C-x C-r} command re-reads this init file, thusincorporating any changes that you might have made to it.@menu* Readline Init Syntax:: Syntax for the commands in the inputrc file.* Conditional Init Constructs:: Conditional key bindings in the inputrc file.@end menu@node Readline Init Syntax@subsection Readline Init SyntaxThere are only a few basic constructs allowed in theReadline init file. Blank lines are ignored.Lines beginning with a @key{#} are comments.Lines beginning with a @key{$} indicate conditionalconstructs (@pxref{Conditional Init Constructs}). Other linesdenote variable settings and key bindings.@table @asis@item Variable SettingsYou can change the state of a few variables in Readline byusing the @code{set} command within the init file. Here is how youwould specify that you wish to use @code{vi} line editing commands:@exampleset editing-mode vi@end exampleRight now, there are only a few variables which can be set;so few, in fact, that we just list them here:@table @code@item editing-mode@vindex editing-modeThe @code{editing-mode} variable controls which editing mode you areusing. By default, Readline starts up in Emacs editing mode, wherethe keystrokes are most similar to Emacs. This variable can beset to either @code{emacs} or @code{vi}.@item horizontal-scroll-mode@vindex horizontal-scroll-modeThis variable can be set to either @code{On} or @code{Off}. Setting itto @code{On} means that the text of the lines that you edit will scrollhorizontally on a single screen line when they are longer than the widthof the screen, instead of wrapping onto a new screen line. By default,this variable is set to @code{Off}.@item mark-modified-lines@vindex mark-modified-linesThis variable, when set to @code{On}, says to display an asterisk(@samp{*}) at the start of history lines which have been modified.This variable is @code{off} by default.@item bell-style@vindex bell-styleControls what happens when Readline wants to ring the terminal bell.If set to @code{none}, Readline never rings the bell. If set to@code{visible}, Readline uses a visible bell if one is available.If set to @code{audible} (the default), Readline attempts to ringthe terminal's bell.@item comment-begin@vindex comment-beginThe string to insert at the beginning of the line when the@code{vi-comment} command is executed. The default valueis @code{"#"}.@item meta-flag@vindex meta-flagIf set to @code{on}, Readline will enable eight-bit input (itwill not strip the eighth bit from the characters it reads),regardless of what the terminal claims it can support. Thedefault value is @code{off}.@item convert-meta@vindex convert-metaIf set to @code{on}, Readline will convert characters with theeigth bit set to an ASCII key sequence by stripping the eigthbit and prepending an @key{ESC} character, converting them to ameta-prefixed key sequence. The default value is @code{on}.@item output-meta@vindex output-metaIf set to @code{on}, Readline will display characters with theeighth bit set directly rather than as a meta-prefixed escapesequence. The default is @code{off}.@item completion-query-items@vindex completion-query-itemsThe number of possible completions that determines when the user isasked whether he wants to see the list of possibilities. If thenumber of possible completions is greater than this value,Readline will ask the user whether or not he wishes to viewthem; otherwise, they are simply listed. The default limit is@code{100}.@item keymap@vindex keymapSets Readline's idea of the current keymap for key binding commands.Acceptable @code{keymap} names are@code{emacs},@code{emacs-standard},@code{emacs-meta},@code{emacs-ctlx},@code{vi},@code{vi-move},@code{vi-command}, and@code{vi-insert}.@code{vi} is equivalent to @code{vi-command}; @code{emacs} isequivalent to @code{emacs-standard}. The default value is @code{emacs}.The value of the @code{editing-mode} variable also affects thedefault keymap.@item show-all-if-ambiguous@vindex show-all-if-ambiguousThis alters the default behavior of the completion functions. Ifset to @code{on}, words which have more than one possible completion cause thematches to be listed immediately instead of ringing the bell.The default value is @code{off}.@item expand-tilde@vindex expand-tildeIf set to @code{on}, tilde expansion is performed when Readlineattempts word completion. The default is @code{off}.@end table@item Key BindingsThe syntax for controlling key bindings in the init file issimple. First you have to know the name of the command that youwant to change. The following pages contain tables of the command name,the default keybinding, and a short description of what the commanddoes.Once you know the name of the command, simply place the name of the keyyou wish to bind the command to, a colon, and then the name of thecommand on a line in the init file. The name of the keycan be expressed in different ways, depending on which is mostcomfortable for you.@table @asis@item @w{@var{keyname}: @var{function-name} or @var{macro}}@var{keyname} is the name of a key spelled out in English. For example:@exampleControl-u: universal-argumentMeta-Rubout: backward-kill-wordControl-o: ">&output"@end exampleIn the above example, @samp{C-u} is bound to the function@code{universal-argument}, and @samp{C-o} is bound to run the macroexpressed on the right hand side (that is, to insert the text@samp{>&output} into the line).@item @w{"@var{keyseq}": @var{function-name} or @var{macro}}@var{keyseq} differs from @var{keyname} above in that stringsdenoting an entire key sequence can be specified, by placingthe key sequence in double quotes. Some GNU Emacs style keyescapes can be used, as in the following example, but thespecial character names are not recognized.@example"\C-u": universal-argument"\C-x\C-r": re-read-init-file"\e[11~": "Function Key 1"@end exampleIn the above example, @samp{C-u} is bound to the function@code{universal-argument} (just as it was in the first example),@samp{C-x C-r} is bound to the function @code{re-read-init-file}, and@samp{ESC [ 1 1 ~} is bound to insert the text @samp{Function Key 1}.The following escape sequences are available when specifying keysequences:@table @code@item @kbd{\C-}control prefix@item @kbd{\M-}meta prefix@item @kbd{\e}an escape character@item @kbd{\\}backslash
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -