⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readline.html

📁 在非GUI环境下
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<HTML><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><!-- Created on July, 27  2004 by texi2html 1.64 --><!-- Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)            Karl Berry  <karl@freefriends.org>            Olaf Bachmann <obachman@mathematik.uni-kl.de>            and many others.Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>Send bugs and suggestions to <texi2html@mathematik.uni-kl.de> --><HEAD><TITLE>GNU Readline Library: </TITLE><META NAME="description" CONTENT="GNU Readline Library: "><META NAME="keywords" CONTENT="GNU Readline Library: "><META NAME="resource-type" CONTENT="document"><META NAME="distribution" CONTENT="global"><META NAME="Generator" CONTENT="texi2html 1.64"></HEAD><BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000"><A NAME="SEC_Top"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><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><H1>GNU Readline Library</H1></P><P>This document describes the GNU Readline Library, a utility which aidsin the consistency of user interface across discrete programs whichprovide a command line interface.</P><P><BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC1">1. Command Line Editing</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">GNU Readline User's Manual.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC23">2. Programming with GNU Readline</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">GNU Readline Programmer's Manual.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC49">A. Copying This Manual</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Copying this manual.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC52">Concept Index</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Index of concepts described in this manual.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC53">Function and Variable Index</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Index of externally visible functions				   and variables.</TD></TR></TABLE></BLOCKQUOTE><P><HR SIZE=1><A NAME="SEC1"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_Top"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC2"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_Top"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC23"> &gt;&gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <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><A NAME="Command Line Editing"></A><H1> 1. Command Line Editing </H1><!--docid::SEC1::--><P>This chapter describes the basic features of the GNUcommand line editing interface.</P><P><BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC2">1.1 Introduction to Line Editing</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Notation used in this text.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC3">1.2 Readline Interaction</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">The minimum set of commands for editing a line.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC9">1.3 Readline Init File</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Customizing Readline from a user's view.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC13">1.4 Bindable Readline Commands</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">A description of most of the Readline commands				available for binding</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC22">1.5 Readline vi Mode</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">A short description of how to make Readline				behave like the vi editor.</TD></TR></TABLE></BLOCKQUOTE><P><A NAME="Introduction and Notation"></A><HR SIZE="6"><A NAME="SEC2"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC1"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC3"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[ &lt;&lt; ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC1"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC23"> &gt;&gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <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.1 Introduction to Line Editing </H2><!--docid::SEC2::--><P>The following paragraphs describe the notation used to representkeystrokes.</P><P>The text <KBD>C-k</KBD> is read as `Control-K' and describes the characterproduced when the <KBD>k</KBD> key is pressed while the Control keyis depressed.</P><P>The text <KBD>M-k</KBD> is read as `Meta-K' and describes the characterproduced when the Meta key (if you have one) is depressed, and the <KBD>k</KBD>key is pressed.The Meta key is labeled <KBD>ALT</KBD> on many keyboards.On keyboards with two keys labeled <KBD>ALT</KBD> (usually to either side ofthe space bar), the <KBD>ALT</KBD> on the left side is generally set towork as a Meta key.The <KBD>ALT</KBD> key on the right may also be configured to work as aMeta key or may be configured as some other modifier, such as aCompose key for typing accented characters.</P><P>If you do not have a Meta or <KBD>ALT</KBD> key, or another key working asa Meta key, the identical keystroke can be generated by typing <KBD>ESC</KBD><EM>first</EM>, and then typing <KBD>k</KBD>.Either process is known as <EM>metafying</EM> the <KBD>k</KBD> key.</P><P>The text <KBD>M-C-k</KBD> is read as `Meta-Control-k' and describes thecharacter produced by <EM>metafying</EM> <KBD>C-k</KBD>.</P><P>In addition, several keys have their own names.  Specifically,<KBD>DEL</KBD>, <KBD>ESC</KBD>, <KBD>LFD</KBD>, <KBD>SPC</KBD>, <KBD>RET</KBD>, and <KBD>TAB</KBD> allstand for themselves when seen in this text, or in an init file(see section <A HREF="readline.html#SEC9">1.3 Readline Init File</A>).If your keyboard lacks a <KBD>LFD</KBD> key, typing <KBD>C-j</KBD> willproduce the desired character.The <KBD>RET</KBD> key may be labeled <KBD>Return</KBD> or <KBD>Enter</KBD> onsome keyboards.</P><P><A NAME="Readline Interaction"></A><HR SIZE="6"><A NAME="SEC3"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC2"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC4"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC9"> &lt;&lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC1"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC9"> &gt;&gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <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.2 Readline Interaction </H2><!--docid::SEC3::--><P>Often 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 <KBD>RET</KBD>.  You do not have to be at theend of the line to press <KBD>RET</KBD>; the entire line is acceptedregardless of the location of the cursor within the line.</P><P><BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC4">1.2.1 Readline Bare Essentials</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">The least you need to know about Readline.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC5">1.2.2 Readline Movement Commands</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Moving about the input line.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC6">1.2.3 Readline Killing Commands</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">How to delete text, and how to get it back!</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC7">1.2.4 Readline Arguments</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Giving numeric arguments to commands.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC8">1.2.5 Searching for Commands in the History</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Searching through previous lines.</TD></TR></TABLE></BLOCKQUOTE><P><A NAME="Readline Bare Essentials"></A><HR SIZE="6"><A NAME="SEC4"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC3"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC5"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC9"> &lt;&lt; </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"> &gt;&gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <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.1 Readline Bare Essentials </H3><!--docid::SEC4::--><P>In 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.</P><P>Sometimes you may mistype a character, andnot notice the error until you have typed several other characters.  Inthat case, you can type <KBD>C-b</KBD> to move the cursor to the left, and thencorrect your mistake.  Afterwards, you can move the cursor to the rightwith <KBD>C-f</KBD>.</P><P>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 bareessentials for editing the text of an input line follows.</P><P><DL COMPACT><DT><KBD>C-b</KBD><DD>Move back one character.<DT><KBD>C-f</KBD><DD>Move forward one character.<DT><KBD>DEL</KBD> or <KBD>Backspace</KBD><DD>Delete the character to the left of the cursor.<DT><KBD>C-d</KBD><DD>Delete the character underneath the cursor.<DT>Printing characters<DD>Insert the character into the line at the cursor.<DT><KBD>C-_</KBD> or <KBD>C-x C-u</KBD><DD>Undo the last editing command.  You can undo all the way back to anempty line.</DL><P>(Depending on your configuration, the <KBD>Backspace</KBD> key be set todelete the character to the left of the cursor and the <KBD>DEL</KBD> key setto delete the character underneath the cursor, like <KBD>C-d</KBD>, ratherthan the character to the left of the cursor.)</P><P><A NAME="Readline Movement Commands"></A><HR SIZE="6"><A NAME="SEC5"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC4"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC6"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC6"> &lt;&lt; </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"> &gt;&gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <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.2 Readline Movement Commands </H3><!--docid::SEC5::--><P>The above table describes the most basic keystrokes that you needin order to do editing of the input line.  For your convenience, manyother commands have been added in addition to <KBD>C-b</KBD>, <KBD>C-f</KBD>,<KBD>C-d</KBD>, and <KBD>DEL</KBD>.  Here are some commands for moving more rapidlyabout the line.</P><P><DL COMPACT><DT><KBD>C-a</KBD><DD>Move to the start of the line.<DT><KBD>C-e</KBD><DD>Move to the end of the line.<DT><KBD>M-f</KBD><DD>Move forward a word, where a word is composed of letters and digits.<DT><KBD>M-b</KBD><DD>Move backward a word.<DT><KBD>C-l</KBD><DD>Clear the screen, reprinting the current line at the top.</DL><P>Notice how <KBD>C-f</KBD> moves forward a character, while <KBD>M-f</KBD> movesforward a word.  It is a loose convention that control keystrokesoperate on characters while meta keystrokes operate on words.</P><P><A NAME="Readline Killing Commands"></A><HR SIZE="6"><A NAME="SEC6"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC5"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC7"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC7"> &lt;&lt; </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"> &gt;&gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <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.3 Readline Killing Commands </H3><!--docid::SEC6::--><P><A NAME="IDX1"></A><A NAME="IDX2"></A></P><P><EM>Killing</EM> text means to delete the text from the line, but to saveit away for later use, usually by <EM>yanking</EM> (re-inserting)it back into the line.(`Cut' and `paste' are more recent jargon for `kill' and `yank'.)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -