📄 readline.3
字号:
.B editing\-modealso affects the default keymap..TP.B mark\-directories (On)If set to \fBOn\fP, completed directory names have a slashappended..TP.B mark\-modified\-lines (Off)If set to \fBOn\fP, history lines that have been modified are displayedwith a preceding asterisk (\fB*\fP)..TP.B mark\-symlinked\-directories (Off)If set to \fBOn\fP, completed names which are symbolic links to directorieshave a slash appended (subject to the value of\fBmark\-directories\fP)..TP.B match\-hidden\-files (On)This variable, when set to \fBOn\fP, causes readline to match files whose names begin with a `.' (hidden files) when performing filename completion, unless the leading `.' is supplied by the user in the filename to be completed..TP.B output\-meta (Off)If set to \fBOn\fP, readline will display characters with theeighth bit set directly rather than as a meta-prefixed escapesequence..TP.B page\-completions (On)If set to \fBOn\fP, readline uses an internal \fImore\fP-like pagerto display a screenful of possible completions at a time..TP.B print\-completions\-horizontally (Off)If set to \fBOn\fP, readline will display completions with matchessorted horizontally in alphabetical order, rather than down the screen..TP.B show\-all\-if\-ambiguous (Off)This alters the default behavior of the completion functions. Ifset to.BR on ,words which have more than one possible completion cause thematches to be listed immediately instead of ringing the bell..TP.B visible\-stats (Off)If set to \fBOn\fP, a character denoting a file's type as reported by \fIstat\fP(2) is appended to the filename when listing possiblecompletions..PD.SS Conditional Constructs.PPReadline implements a facility similar in spirit to the conditionalcompilation features of the C preprocessor which allows keybindings and variable settings to be performed as the resultof tests. There are four parser directives used..IP \fB$if\fPThe .B $ifconstruct allows bindings to be made based on theediting mode, the terminal being used, or the application usingreadline. The text of the test extends to the end of the line;no characters are required to isolate it..RS.IP \fBmode\fPThe \fBmode=\fP form of the \fB$if\fP directive is used to testwhether readline is in emacs or vi mode.This may be used in conjunctionwith the \fBset keymap\fP command, for instance, to set bindings inthe \fIemacs-standard\fP and \fIemacs-ctlx\fP keymaps only ifreadline is starting out in emacs mode..IP \fBterm\fPThe \fBterm=\fP form may be used to include terminal-specifickey bindings, perhaps to bind the key sequences output by theterminal's function keys. The word on the right side of the.B =is tested against the full name of the terminal and the portionof the terminal name before the first \fB\-\fP. This allows.I sunto match both.I sunand.IR sun\-cmd ,for instance..IP \fBapplication\fPThe \fBapplication\fP construct is used to includeapplication-specific settings. Each program using the readlinelibrary sets the \fIapplication name\fP, and an initializationfile can test for a particular value.This could be used to bind key sequences to functions useful fora specific program. For instance, the following command adds akey sequence that quotes the current or previous word in Bash:.sp 1.RS.nf\fB$if\fP Bash# Quote the current or previous word"\eC-xq": "\eeb\e"\eef\e""\fB$endif\fP.fi.RE.RE.IP \fB$endif\fPThis command, as seen in the previous example, terminates an\fB$if\fP command..IP \fB$else\fPCommands in this branch of the \fB$if\fP directive are executed ifthe test fails..IP \fB$include\fPThis directive takes a single filename as an argument and reads commandsand bindings from that file. For example, the following directivewould read \fI/etc/inputrc\fP:.sp 1.RS.nf\fB$include\fP \^ \fI/etc/inputrc\fP.fi .RE.SH SEARCHING.PPReadline provides commands for searching through the command historyfor lines containing a specified string.There are two search modes:.I incrementaland.IR non-incremental ..PPIncremental searches begin before the user has finished typing thesearch string.As each character of the search string is typed, readline displaysthe next entry from the history matching the string typed so far.An incremental search requires only as many characters as needed tofind the desired history entry.To search backward in the history for a particular string, type\fBC\-r\fP. Typing \fBC\-s\fP searches forward through the history.The characters present in the value of the \fBisearch-terminators\fPvariable are used to terminate an incremental search.If that variable has not been assigned a value the \fIEscape\fP and\fBC\-J\fP characters will terminate an incremental search.\fBC\-G\fP will abort an incremental search and restore the originalline.When the search is terminated, the history entry containing thesearch string becomes the current line..PPTo find other matching entries in the history list, type \fBC\-s\fP or\fBC\-r\fP as appropriate.This will search backward or forward in the history for the nextline matching the search string typed so far.Any other key sequence bound to a readline command will terminatethe search and execute that command.For instance, a newline will terminate the search and acceptthe line, thereby executing the command from the history list.A movement command will terminate the search, make the last line foundthe current line, and begin editing..PPNon-incremental searches read the entire search string before startingto search for matching history lines. The search string may betyped by the user or be part of the contents of the current line..SH EDITING COMMANDS.PPThe following is a list of the names of the commands and the defaultkey sequences to which they are bound.Command names without an accompanying key sequence are unbound by default..PPIn the following descriptions, \fIpoint\fP refers to the current cursorposition, and \fImark\fP refers to a cursor position saved by the\fBset\-mark\fP command.The text between the point and mark is referred to as the \fIregion\fP..SS Commands for Moving.PP.PD 0.TP.B beginning\-of\-line (C\-a)Move to the start of the current line..TP.B end\-of\-line (C\-e)Move to the end of the line..TP.B forward\-char (C\-f)Move forward a character..TP.B backward\-char (C\-b)Move back a character..TP.B forward\-word (M\-f)Move forward to the end of the next word. Words are composed ofalphanumeric characters (letters and digits)..TP.B backward\-word (M\-b)Move back to the start of the current or previous word. Words arecomposed of alphanumeric characters (letters and digits)..TP.B clear\-screen (C\-l)Clear the screen leaving the current line at the top of the screen.With an argument, refresh the current line without clearing thescreen..TP.B redraw\-current\-lineRefresh the current line..PD.SS Commands for Manipulating the History.PP.PD 0.TP.B accept\-line (Newline, Return)Accept the line regardless of where the cursor is.If this line isnon-empty, it may be added to the history list for future recall with\fBadd_history()\fP.If the line is a modified history line, the history line is restored to its original state..TP.B previous\-history (C\-p)Fetch the previous command from the history list, moving back inthe list..TP.B next\-history (C\-n)Fetch the next command from the history list, moving forward in thelist..TP.B beginning\-of\-history (M\-<)Move to the first line in the history..TP.B end\-of\-history (M\->)Move to the end of the input history, i.e., the line currently beingentered..TP.B reverse\-search\-history (C\-r)Search backward starting at the current line and moving `up' throughthe history as necessary. This is an incremental search..TP.B forward\-search\-history (C\-s)Search forward starting at the current line and moving `down' throughthe history as necessary. This is an incremental search..TP.B non\-incremental\-reverse\-search\-history (M\-p)Search backward through the history starting at the current lineusing a non-incremental search for a string supplied by the user..TP.B non\-incremental\-forward\-search\-history (M\-n)Search forward through the history using a non-incremental searchfor a string supplied by the user..TP.B history\-search\-forwardSearch forward through the history for the string of charactersbetween the start of the current line and the current cursorposition (the \fIpoint\fP).This is a non-incremental search..TP.B history\-search\-backwardSearch backward through the history for the string of charactersbetween the start of the current line and the point.This is a non-incremental search..TP.B yank\-nth\-arg (M\-C\-y)Insert the first argument to the previous command (usuallythe second word on the previous line) at point.With an argument.IR n ,insert the \fIn\fPth word from the previous command (the wordsin the previous command begin with word 0). A negative argumentinserts the \fIn\fPth word from the end of the previous command..TP.Byank\-last\-arg (M\-.\^, M\-_\^)Insert the last argument to the previous command (the last word ofthe previous history entry). With an argument,behave exactly like \fByank\-nth\-arg\fP.Successive calls to \fByank\-last\-arg\fP move back through the historylist, inserting the last argument of each line in turn..PD.SS Commands for Changing Text.PP.PD 0.TP.B delete\-char (C\-d)Delete the character at point. If point is at thebeginning of the line, there are no characters in the line, andthe last character typed was not bound to \fBdelete\-char\fP, then return.SM.BR EOF ..TP.B backward\-delete\-char (Rubout)Delete the character behind the cursor. When given a numeric argument,save the deleted text on the kill ring..TP.B forward\-backward\-delete\-char Delete the character under the cursor, unless the cursor is at theend of the line, in which case the character behind the cursor isdeleted..TP.B quoted\-insert (C\-q, C\-v)Add the next character that you type to the line verbatim. This ishow to insert characters like \fBC\-q\fP, for example..TP.B tab\-insert (M-TAB)Insert a tab character..TP.B self\-insert (a,\ b,\ A,\ 1,\ !,\ ...)Insert the character typed..TP.B transpose\-chars (C\-t)Drag the character before point forward over the character at point,moving point forward as well.If point is at the end of the line, then this transposesthe two characters before point.Negative arguments have no effect..TP.B transpose\-words (M\-t)Drag the word before point past the word after point,moving point over that word as well.If point is at the end of the line, this transposesthe last two words on the line..TP.B upcase\-word (M\-u)Uppercase the current (or following) word. With a negative argument,uppercase the previous word, but do not move point..TP.B downcase\-word (M\-l)Lowercase the current (or following) word. With a negative argument,lowercase the previous word, but do not move point..TP.B capitalize\-word (M\-c)Capitalize the current (or following) word. With a negative argument,capitalize the previous word, but do not move point..TP.B overwrite\-modeToggle overwrite mode. With an explicit positive numeric argument,switches to overwrite mode. With an explicit non-positive numericargument, switches to insert mode. This command affects only\fBemacs\fP mode; \fBvi\fP mode does overwrite differently.Each call to \fIreadline()\fP starts in insert mode.In overwrite mode, characters bound to \fBself\-insert\fP replace the text at point rather than pushing the text to the right.Characters bound to \fBbackward\-delete\-char\fP replace the characterbefore point with a space. By default, this command is unbound..PD.SS Killing and Yanking.PP.PD 0.TP.B kill\-line (C\-k)Kill the text from point to the end of the line..TP.B backward\-kill\-line (C\-x Rubout)Kill backward to the beginning of the line..TP.B unix\-line\-discard (C\-u)Kill backward from point to the beginning of the line.The killed text is saved on the kill-ring..\" There is no real difference between this and backward-kill-line.TP.B kill\-whole\-lineKill all characters on the current line, no matter where point is..TP.B kill\-word (M\-d)Kill from point the end of the current word, or if betweenwords, to the end of the next word. Word boundaries are the same asthose used by \fBforward\-word\fP..TP.B backward\-kill\-word (M\-Rubout)Kill the word behind point.Word boundaries are the same as those used by \fBbackward\-word\fP..TP.B unix\-word\-rubout (C\-w)Kill the word behind point, using white space as a word boundary.The killed text is saved on the kill-ring..TP.B delete\-horizontal\-space (M\-\e)Delete all spaces and tabs around point..TP.B kill\-regionKill the text between the point and \fImark\fP (saved cursor position).This text is referred to as the \fIregion\fP..TP.B copy\-region\-as\-killCopy the text in the region to the kill buffer..TP.B copy\-backward\-wordCopy the word before point to the kill buffer.The word boundaries are the same as \fBbackward\-word\fP..TP.B copy\-forward\-wordCopy the word following point to the kill buffer.The word boundaries are the same as \fBforward\-word\fP..TP.B yank (C\-y)Yank the top of the kill ring into the buffer at point..TP.B yank\-pop (M\-y)Rotate the kill ring, and yank the new top. Only works following.B yankor.BR yank\-pop ..PD.SS Numeric Arguments.PP.PD 0.TP.B digit\-argument (M\-0, M\-1, ..., M\-\-)Add this digit to the argument already accumulating, or start a newargument. M\-\- starts a negative argument..TP.B universal\-argumentThis is another way to specify an argument.If this command is followed by one or more digits, optionally with aleading minus sign, those digits define the argument.If the command is followed by digits, executing.B universal\-argumentagain ends the numeric argument, but is otherwise ignored.As a special case, if this command is immediately followed by acharacter that is neither a digit or minus sign, the argument countfor the next command is multiplied by four.The argument count is initially one, so executing this function thefirst time makes the argument count four, a second time makes theargument count sixteen, and so on..PD.SS Completing.PP.PD 0.TP.B complete (TAB)Attempt to perform completion on the text before point.The actual completion performed is application-specific..BR Bash ,for instance, attempts completion treating the text as a variable(if the text begins with \fB$\fP), username (if the text begins with\fB~\fP), hostname (if the text begins with \fB@\fP), orcommand (including aliases and functions) in turn. If none
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -