📄 ed.html
字号:
<h5><a name="tag_04_42_13_17"></a>List Command</h5><dl compact><dt><i>Synopsis</i>:</dt><dd><pre><tt>(.,.)l</tt></pre></dd></dl><p>The <b>l</b> command shall write to standard output the addressed lines in a visually unambiguous form. The characters listed inthe Base Definitions volume of IEEE Std 1003.1-2001, Table 5-1, Escape Sequences and Associated Actions ( <tt>'\\'</tt> ,<tt>'\a'</tt> , <tt>'\b'</tt> , <tt>'\f'</tt> , <tt>'\r'</tt> , <tt>'\t'</tt> , <tt>'\v'</tt> ) shall be written as thecorresponding escape sequence; the <tt>'\n'</tt> in that table is not applicable. Non-printable characters not in the table shallbe written as one three-digit octal number (with a preceding backslash character) for each byte in the character (most significantbyte first). If the size of a byte on the system is greater than nine bits, the format used for non-printable characters isimplementation-defined.</p><p>Long lines shall be folded, with the point of folding indicated by <newline> preceded by a backslash; the length at whichfolding occurs is unspecified, but should be appropriate for the output device. The end of each line shall be marked with a<tt>'$'</tt> , and <tt>'$'</tt> characters within the text shall be written with a preceding backslash. An <b>l</b> command can beappended to any other command other than <b>e</b>, <b>E</b>, <b>f</b>, <b>q</b>, <b>Q</b>, <b>r</b>, <b>w</b>, or <b>!</b>. Thecurrent line number shall be set to the address of the last line written.</p><h5><a name="tag_04_42_13_18"></a>Move Command</h5><dl compact><dt><i>Synopsis</i>:</dt><dd><pre><tt>(.,.)m</tt><i>address</i></pre></dd></dl><p>The <b>m</b> command shall reposition the addressed lines after the line addressed by <i>address</i>. Address 0 shall be validfor <i>address</i> and cause the addressed lines to be moved to the beginning of the buffer. It shall be an error if address<i>address</i> falls within the range of moved lines. The current line number shall be set to the address of the last linemoved.</p><h5><a name="tag_04_42_13_19"></a>Number Command</h5><dl compact><dt><i>Synopsis</i>:</dt><dd><pre><tt>(.,.)n</tt></pre></dd></dl><p>The <b>n</b> command shall write to standard output the addressed lines, preceding each line by its line number and a<tab>; the current line number shall be set to the address of the last line written. The <b>n</b> command can be appended toany command other than <b>e</b>, <b>E</b>, <b>f</b>, <b>q</b>, <b>Q</b>, <b>r</b>, <b>w</b>, or <b>!</b>.</p><h5><a name="tag_04_42_13_20"></a>Print Command</h5><dl compact><dt><i>Synopsis</i>:</dt><dd><pre><tt>(.,.)p</tt></pre></dd></dl><p>The <b>p</b> command shall write to standard output the addressed lines; the current line number shall be set to the address ofthe last line written. The <b>p</b> command can be appended to any command other than <b>e</b>, <b>E</b>, <b>f</b>, <b>q</b>,<b>Q</b>, <b>r</b>, <b>w</b>, or <b>!</b>.</p><h5><a name="tag_04_42_13_21"></a>Prompt Command</h5><dl compact><dt><i>Synopsis</i>:</dt><dd><pre><tt>P</tt></pre></dd></dl><p>The <b>P</b> command shall cause <i>ed</i> to prompt with an asterisk ( <tt>'*'</tt> ) (or <i>string</i>, if <b>-p</b> isspecified) for all subsequent commands. The <b>P</b> command alternatively shall turn this mode on and off; it shall be initiallyon if the <b>-p</b> option is specified; otherwise, off. The current line number shall be unchanged.</p><h5><a name="tag_04_42_13_22"></a>Quit Command</h5><dl compact><dt><i>Synopsis</i>:</dt><dd><pre><tt>q</tt></pre></dd></dl><p>The <b>q</b> command shall cause <i>ed</i> to exit. If the buffer has changed since the last time the entire buffer was written,the user shall be warned, as described previously.</p><h5><a name="tag_04_42_13_23"></a>Quit Without Checking Command</h5><dl compact><dt><i>Synopsis</i>:</dt><dd><pre><tt>Q</tt></pre></dd></dl><p>The <b>Q</b> command shall cause <i>ed</i> to exit without checking whether changes have been made in the buffer since the last<b>w</b> command.</p><h5><a name="tag_04_42_13_24"></a>Read Command</h5><dl compact><dt><i>Synopsis</i>:</dt><dd><pre><tt>($)r</tt> <b>[</b><i>file</i><b>]</b></pre></dd></dl><p>The <b>r</b> command shall read in the file named by the pathname <i>file</i> and append it after the addressed line. If no<i>file</i> argument is given, the currently remembered pathname, if any, shall be used (see the <b>e</b> and <b>f</b> commands).The currently remembered pathname shall not be changed unless there is no remembered pathname. Address 0 shall be valid for<b>r</b> and shall cause the file to be read at the beginning of the buffer. If the read is successful, and <b>-s</b> was notspecified, the number of bytes read shall be written to standard output in the following format:</p><pre><tt>"%d\n", <</tt><i>number of bytes read</i><tt>></tt></pre><p>The current line number shall be set to the address of the last line read in. If <i>file</i> is replaced by <tt>'!'</tt> , therest of the line shall be taken to be a shell command line whose output is to be read. Such a shell command line shall not beremembered as the current pathname.</p><h5><a name="tag_04_42_13_25"></a>Substitute Command</h5><dl compact><dt><i>Synopsis</i>:</dt><dd><pre><tt>(.,.)s/</tt><i>RE</i><tt>/</tt><i>replacement</i><tt>/</tt><i>flags</i></pre></dd></dl><p>The <b>s</b> command shall search each addressed line for an occurrence of the specified RE and replace either the first or all(non-overlapped) matched strings with the <i>replacement</i>; see the following description of the <b>g</b> suffix. It is an errorif the substitution fails on every addressed line. Any character other than <space> or <newline> can be used instead ofa slash to delimit the RE and the replacement. Within the RE, the RE delimiter itself can be used as a literal character if it ispreceded by a backslash. The current line shall be set to the address of the last line on which a substitution occurred.</p><p>An ampersand ( <tt>'&'</tt> ) appearing in the <i>replacement</i> shall be replaced by the string matching the RE on thecurrent line. The special meaning of <tt>'&'</tt> in this context can be suppressed by preceding it by backslash. As a moregeneral feature, the characters <tt>'\n'</tt> , where <i>n</i> is a digit, shall be replaced by the text matched by thecorresponding back-reference expression. When the character <tt>'%'</tt> is the only character in the <i>replacement</i>, the<i>replacement</i> used in the most recent substitute command shall be used as the <i>replacement</i> in the current substitutecommand; if there was no previous substitute command, the use of <tt>'%'</tt> in this manner shall be an error. The <tt>'%'</tt>shall lose its special meaning when it is in a replacement string of more than one character or is preceded by a backslash. Foreach backslash ( <tt>'\'</tt> ) encountered in scanning <i>replacement</i> from beginning to end, the following character shalllose its special meaning (if any). It is unspecified what special meaning is given to any character other than <tt>'&'</tt> ,<tt>'\'</tt> , <tt>'%'</tt> , or digits.</p><p>A line can be split by substituting a <newline> into it. The application shall ensure it escapes the <newline> inthe <i>replacement</i> by preceding it by backslash. Such substitution cannot be done as part of a <b>g</b> or <b>v</b> <i>commandlist</i>. The current line number shall be set to the address of the last line on which a substitution is performed. If nosubstitution is performed, the current line number shall be unchanged. If a line is split, a substitution shall be considered tohave been performed on each of the new lines for the purpose of determining the new current line number. A substitution shall beconsidered to have been performed even if the replacement string is identical to the string that it replaces.</p><p>The application shall ensure that the value of <i>flags</i> is zero or more of:</p><dl compact><dt><i>count</i></dt><dd>Substitute for the <i>count</i>th occurrence only of the RE found on each addressed line.</dd><dt><b>g</b></dt><dd>Globally substitute for all non-overlapping instances of the RE rather than just the first one. If both <b>g</b> and<i>count</i> are specified, the results are unspecified.</dd><dt><b>l</b></dt><dd>Write to standard output the final line in which a substitution was made. The line shall be written in the format specified forthe <b>l</b> command.</dd><dt><b>n</b></dt><dd>Write to standard output the final line in which a substitution was made. The line shall be written in the format specified forthe <b>n</b> command.</dd><dt><b>p</b></dt><dd>Write to standard output the final line in which a substitution was made. The line shall be written in the format specified forthe <b>p</b> command.</dd></dl><h5><a name="tag_04_42_13_26"></a>Copy Command</h5><dl compact><dt><i>Synopsis</i>:</dt><dd><pre><tt>(.,.)t</tt><i>address</i></pre></dd></dl><p>The <b>t</b> command shall be equivalent to the <b>m</b> command, except that a copy of the addressed lines shall be placedafter address <i>address</i> (which can be 0); the current line number shall be set to the address of the last line added.</p><h5><a name="tag_04_42_13_27"></a>Undo Command</h5><dl compact><dt><i>Synopsis</i>:</dt><dd><pre><tt>u</tt></pre></dd></dl><p>The <b>u</b> command shall nullify the effect of the most recent command that modified anything in the buffer, namely the mostrecent <b>a</b>, <b>c</b>, <b>d</b>, <b>g</b>, <b>i</b>, <b>j</b>, <b>m</b>, <b>r</b>, <b>s</b>, <b>t</b>, <b>u</b>, <b>v</b>,<b>G</b>, or <b>V</b> command. All changes made to the buffer by a <b>g</b>, <b>G</b>, <b>v</b>, or <b>V</b> global command shallbe undone as a single change; if no changes were made by the global command (such as with <b>g</b>/RE/ <b>p</b>), the <b>u</b>command shall have no effect. The current line number shall be set to the value it had immediately before the command being undonestarted.</p><h5><a name="tag_04_42_13_28"></a>Global Non-Matched Command</h5><dl compact><dt><i>Synopsis</i>:</dt><dd><pre><tt>(1,$)v/</tt><i>RE</i><tt>/</tt><i>command list</i></pre></dd></dl><p>This command shall be equivalent to the global command <b>g</b> except that the lines that are marked during the first stepshall be those for which the line excluding the terminating <newline> does not match the RE.</p><h5><a name="tag_04_42_13_29"></a>Interactive Global Not-Matched Command</h5><dl compact><dt><i>Synopsis</i>:</dt><dd><pre><tt>(1,$)V/</tt><i>RE</i><tt>/</tt></pre></dd></dl><p>This command shall be equivalent to the interactive global command <b>G</b> except that the lines that are marked during thefirst step shall be those for which the line excluding the terminating <newline> does not match the RE.</p><h5><a name="tag_04_42_13_30"></a>Write Command</h5><dl compact><dt><i>Synopsis</i>:</dt><dd><pre><tt>(1,$)w</tt> <b>[</b><i>file</i><b>]</b></pre></dd></dl><p>The <b>w</b> command shall write the addressed lines into the file named by the pathname <i>file</i>. The command shall createthe file, if it does not exist, or shall replace the contents of the existing file. The currently remembered pathname shall not bechanged unless there is no remembered pathname. If no pathname is given, the currently remembered pathname, if any, shall be used(see the <b>e</b> and <b>f</b> commands); the current line number shall be unchanged. If the command is successful, the number ofbytes written shall be written to standard output, unless the <b>-s</b> option was specified, in the following format:</p><pre><tt>"%d\n", <</tt><i>number of bytes written</i><tt>></tt></pre><p>If <i>file</i> begins with <tt>'!'</tt> , the rest of the line shall be taken to be a shell command line whose standard inputshall be the addressed lines. Such a shell command line shall not be remembered as the current pathname. This usage of the writecommand with <tt>'!'</tt> shall not be considered as a "last <b>w</b> command that wrote the entire buffer", as describedpreviously; thus, this alone shall not prevent the warning to the user if an attempt is made to destroy the editor buffer via the<b>e</b> or <b>q</b> commands.</p><h5><a name="tag_04_42_13_31"></a>Line Number Command</h5><dl compact><dt><i>Synopsis</i>:</dt><dd><pre><tt>($)=</tt></pre></dd></dl><p>The line number of the addressed line shall be written to standard output in the following format:</p><pre><tt>"%d\n", <</tt><i>line number</i><tt>></tt></pre><p>The current line number shall be unchanged by this command.</p><h5><a name="tag_04_42_13_32"></a>Shell Escape Command</h5><dl compact><dt><i>Synopsis</i>:</dt><dd><pre><tt>!</tt><i>command</i></pre></dd></dl><p>The remainder of the line after the <tt>'!'</tt> shall be sent to the command interpreter to be interpreted as a shell commandline. Within the text of that shell command line, the unescaped character <tt>'%'</tt> shall be replaced with the rememberedpathname; if a <tt>'!'</tt> appears as the first character of the command, it shall be replaced with the text of the previous shellcommand executed via <tt>'!'</tt> . Thus, <tt>"!!"</tt> shall repeat the previous !<i>command</i>. If any replacements of
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -