📄 readline.html
字号:
</P><P>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.</P><P>When you use a kill command, the text is saved in a <EM>kill-ring</EM>.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.<A NAME="IDX3"></A></P><P>Here is the list of commands for killing text.</P><P><DL COMPACT><DT><KBD>C-k</KBD><DD>Kill the text from the current cursor position to the end of the line.<P><DT><KBD>M-d</KBD><DD>Kill from the cursor to the end of the current word, or, if betweenwords, to the end of the next word.Word boundaries are the same as those used by <KBD>M-f</KBD>.<P><DT><KBD>M-<KBD>DEL</KBD></KBD><DD>Kill from the cursor the start of the current word, or, if betweenwords, to the start of the previous word.Word boundaries are the same as those used by <KBD>M-b</KBD>.<P><DT><KBD>C-w</KBD><DD>Kill from the cursor to the previous whitespace. This is different than<KBD>M-<KBD>DEL</KBD></KBD> because the word boundaries differ.<P></DL><P>Here is how to <EM>yank</EM> the text back into the line. Yankingmeans to copy the most-recently-killed text from the kill buffer.</P><P><DL COMPACT><DT><KBD>C-y</KBD><DD>Yank the most recently killed text back into the buffer at the cursor.<P><DT><KBD>M-y</KBD><DD>Rotate the kill-ring, and yank the new top. You can only do this ifthe prior command is <KBD>C-y</KBD> or <KBD>M-y</KBD>.</DL><P><A NAME="Readline Arguments"></A><HR SIZE="6"><A NAME="SEC7"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC6"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC8"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC8"> << </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC3"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC9"> >> </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC52">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_About"> ? </A>]</TD></TR></TABLE><H3> 1.2.4 Readline Arguments </H3><!--docid::SEC7::--><P>You can pass numeric arguments to Readline commands. Sometimes theargument acts as a repeat count, other times it is the <I>sign</I> 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 <SAMP>`M-- C-k'</SAMP>.</P><P>The general way to pass numeric arguments to a command is to type metadigits before the command. If the first `digit' typed is a minussign (<SAMP>`-'</SAMP>), 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 <KBD>C-d</KBD> command an argument of 10, you could type <SAMP>`M-1 0 C-d'</SAMP>,which will delete the next ten characters on the input line.</P><P><A NAME="Searching"></A><HR SIZE="6"><A NAME="SEC8"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC7"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC9"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC9"> << </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC3"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC9"> >> </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC52">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_About"> ? </A>]</TD></TR></TABLE><H3> 1.2.5 Searching for Commands in the History </H3><!--docid::SEC8::--><P>Readline provides commands for searching through the command historyfor lines containing a specified string.There are two search modes: <EM>incremental</EM> and <EM>non-incremental</EM>.</P><P>Incremental 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<KBD>C-r</KBD>. Typing <KBD>C-s</KBD> searches forward through the history.The characters present in the value of the <CODE>isearch-terminators</CODE> variableare used to terminate an incremental search.If that variable has not been assigned a value, the <KBD>ESC</KBD> and<KBD>C-J</KBD> characters will terminate an incremental search.<KBD>C-g</KBD> will abort an incremental search and restore the original line.When the search is terminated, the history entry containing thesearch string becomes the current line.</P><P>To find other matching entries in the history list, type <KBD>C-r</KBD> or<KBD>C-s</KBD> as appropriate.This will search backward or forward in the history for the nextentry 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 <KBD>RET</KBD> 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.</P><P>Readline remembers the last incremental search string. If two<KBD>C-r</KBD>s are typed without any intervening characters defining a newsearch string, any remembered search string is used.</P><P>Non-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.</P><P><A NAME="Readline Init File"></A><HR SIZE="6"><A NAME="SEC9"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC8"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC10"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC13"> << </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC1"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC13"> >> </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC52">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_About"> ? </A>]</TD></TR></TABLE><H2> 1.3 Readline Init File </H2><!--docid::SEC9::--><P>Although the Readline library comes with a set of Emacs-likekeybindings installed by default, it is possible to use a different setof keybindings.Any user can customize programs that use Readline by puttingcommands in an <EM>inputrc</EM> file, conventionally in his home directory.The name of thisfile is taken from the value of the environment variable <CODE>INPUTRC</CODE>. Ifthat variable is unset, the default is <TT>`~/.inputrc'</TT>.</P><P>When a program which uses the Readline library starts up, theinit file is read, and the key bindings are set.</P><P>In addition, the <CODE>C-x C-r</CODE> command re-reads this init file, thusincorporating any changes that you might have made to it.</P><P><BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC10">1.3.1 Readline Init File Syntax</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Syntax for the commands in the inputrc file.</TD></TR></TABLE><br><TABLE BORDER=0 CELLSPACING=0><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC11">1.3.2 Conditional Init Constructs</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Conditional key bindings in the inputrc file.</TD></TR></TABLE><br><TABLE BORDER=0 CELLSPACING=0><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC12">1.3.3 Sample Init File</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">An example inputrc file.</TD></TR></TABLE></BLOCKQUOTE><P><A NAME="Readline Init File Syntax"></A><HR SIZE="6"><A NAME="SEC10"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC9"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC11"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC13"> << </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC9"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC13"> >> </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC52">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_About"> ? </A>]</TD></TR></TABLE><H3> 1.3.1 Readline Init File Syntax </H3><!--docid::SEC10::--><P>There are only a few basic constructs allowed in theReadline init file. Blank lines are ignored.Lines beginning with a <SAMP>`#'</SAMP> are comments.Lines beginning with a <SAMP>`$'</SAMP> indicate conditionalconstructs (see section <A HREF="readline.html#SEC11">1.3.2 Conditional Init Constructs</A>). Other linesdenote variable settings and key bindings.</P><P><DL COMPACT><DT>Variable Settings<DD>You can modify the run-time behavior of Readline byaltering the values of variables in Readlineusing the <CODE>set</CODE> command within the init file.The syntax is simple:<P><TABLE><tr><td> </td><td class=example><pre>set <VAR>variable</VAR> <VAR>value</VAR></pre></td></tr></table></P><P>Here, for example, is how tochange from the default Emacs-like key binding to use<CODE>vi</CODE> line editing commands:</P><P><TABLE><tr><td> </td><td class=example><pre>set editing-mode vi</pre></td></tr></table></P><P>Variable names and values, where appropriate, are recognized without regardto case. </P><P>A great deal of run-time behavior is changeable with the followingvariables.</P><P><A NAME="IDX4"></A><DL COMPACT><DT><CODE>bell-style</CODE><DD><A NAME="IDX5"></A>Controls what happens when Readline wants to ring the terminal bell.If set to <SAMP>`none'</SAMP>, Readline never rings the bell. If set to<SAMP>`visible'</SAMP>, Readline uses a visible bell if one is available.If set to <SAMP>`audible'</SAMP> (the default), Readline attempts to ringthe terminal's bell.<P><DT><CODE>comment-begin</CODE><DD><A NAME="IDX6"></A>The string to insert at the beginning of the line when the<CODE>insert-comment</CODE> command is executed. The default valueis <CODE>"#"</CODE>.<P><DT><CODE>completion-ignore-case</CODE><DD>If set to <SAMP>`on'</SAMP>, Readline performs filename matching and completionin a case-insensitive fashion.The default value is <SAMP>`off'</SAMP>.<P><DT><CODE>completion-query-items</CODE><DD><A NAME="IDX7"></A>The number of possible completions that determines when the user isasked whether the list of possibilities should be displayed.If the number 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.This variable must be set to an integer value greater than or equal to 0.The default limit is <CODE>100</CODE>.<P><DT><CODE>convert-meta</CODE><DD><A NAME="IDX8"></A>If set to <SAMP>`on'</SAMP>, Readline will convert characters with theeighth bit set to an ASCII key sequence by stripping the eighthbit and prefixing an <KBD>ESC</KBD> character, converting them to ameta-prefixed key sequence. The default value is <SAMP>`on'</SAMP>.<P><DT><CODE>disable-completion</CODE><DD><A NAME="IDX9"></A>If set to <SAMP>`On'</SAMP>, Readline will inhibit word completion.Completion characters will be inserted into the line as if they hadbeen mapped to <CODE>self-insert</CODE>. The default is <SAMP>`off'</SAMP>.<P><DT><CODE>editing-mode</CODE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -