📄 ch09_02.htm
字号:
<a name="IXT-9-123204" />Reverse the changes made by the last editing command.</p></td></tr><tr><td valign="top"><a name="unmap">unmap</a></a></td><td><p><tt class="literal">unm</tt>[<tt class="literal">!</tt>] <em class="replaceable"><tt>char</tt></em></p><p><a name="IXT-9-123205" />Remove <em class="emphasis">char</em> from the list of keyboard macros.Use <tt class="literal">!</tt> to remove a macro for input mode.</p></td></tr><tr><td valign="top"><a name="v">v</a></a></td><td><p>[<em class="replaceable"><tt>address</em>] <tt class="literal">v/</tt><em class="replaceable">pattern</em><tt class="literal">/</tt>[<em class="replaceable">commands</tt></em>]</p><p><a name="IXT-9-123206" />Execute <em class="emphasis">commands</em> on all lines <em class="emphasis">not</em>containing <em class="emphasis">pattern</em>. If <em class="emphasis">commands</em> are not specified, print all such lines.<tt class="literal">v</tt> is equivalent to <tt class="literal">g!</tt>.</p><h4 class="refsect2">Example</h4><blockquote><pre class="code">:v/#include/d <i class="lineannotation">Delete all lines except "#include" lines</i></pre></blockquote></td></tr><tr><td valign="top"><a name="version">version</a></a></td><td><p><tt class="literal">ve</tt></p><p><a name="IXT-9-123207" />Print the editor's current version number and date of last change.</p></td></tr><tr><td valign="top"><a name="visual">visual</a></a></td><td><p>[<em class="replaceable"><tt>address</em>] <tt class="literal">vi</tt> [<em class="replaceable">type</em>] [<em class="replaceable">count</tt></em>]</p><p><a name="IXT-9-123208" />Enter visual mode (<tt class="literal">vi</tt>) at the line specified by<em class="emphasis">address</em>. Exit with <tt class="literal">Q</tt>. <em class="emphasis">type</em> canbe one of <tt class="literal">-</tt>, <tt class="literal">^</tt>, or <tt class="literal">.</tt> (See the<tt class="literal">z</tt> command). <em class="emphasis">count</em> specifies an initial window size.</p></td></tr><tr><td valign="top"><a name="visual">visual</a></a></td><td><p><tt class="literal">vi</tt> [<tt class="literal">+</tt> <em class="replaceable"><tt>n</em>] <em class="emphasis">file</tt></em></p><p>Begin editing <em class="emphasis">file</em> in visual mode (<tt class="literal">vi</tt>),optionally at line <em class="emphasis">n</em>.</p></td></tr><tr><td valign="top"><a name="write">write</a></a></td><td><p>[<em class="replaceable"><tt>address</em>] <tt class="literal">w</tt>[<tt class="literal">!</tt>] [[<tt class="literal">>></tt>] <em class="replaceable">file</tt></em>]</p><p><a name="IXT-9-123209" />Write lines specified by <em class="emphasis">address</em> to <em class="emphasis">file</em>,or write full contents of buffer if <em class="emphasis">address</em> is not specified.If <em class="emphasis">file</em> is also omitted, save the contents of the buffer to the current filename.If <tt class="literal">>></tt> <em class="emphasis">file</em> is used, write contents to the end of the specified<em class="emphasis">file</em>.Add a <tt class="literal">!</tt> to force the editor to write over any currentcontents of <em class="emphasis">file</em>.</p><h4 class="refsect2">Example</h4><blockquote><pre class="code">:1,10w name_list <i class="lineannotation">Copy first 10 lines to name_list</i>:50w >> name_list <i class="lineannotation">Now append line 50</i></pre></blockquote></td></tr><tr><td valign="top"><a name="write">write</a></a></td><td><p>[<em class="replaceable"><tt>address</em>] <tt class="literal">w</tt> <tt class="literal">!</tt><em class="replaceable">command</tt></em></p><p>Write lines specified by <em class="emphasis">address</em> to <em class="emphasis">command</em>.</p><h4 class="refsect2">Example</h4><blockquote><pre class="code">:1,66w !pr -h myfile | lp <i class="lineannotation">Print first page of file</i></pre></blockquote></td></tr><tr><td valign="top"><a name="wq">wq</a></a></td><td><p><tt class="literal">wq</tt>[<tt class="literal">!</tt>]</p><p><a name="IXT-9-123210" />Write and quit the file in one movement.The file is always written.The <tt class="literal">!</tt> flag forces the editor to write over any current contents of <em class="emphasis">file</em>.</p></td></tr><tr><td valign="top"><a name="xit">xit</a></a></td><td><p><tt class="literal">x</tt></p><p><a name="IXT-9-123211" />Write the file if it was changed since the last write; then quit.</p></td></tr><tr><td valign="top"><a name="yank">yank</a></a></td><td><p>[<em class="replaceable"><tt>address</em>] <tt class="literal">ya</tt> [<em class="replaceable">char</em>] [<em class="replaceable">count</tt></em>]</p><p><a name="IXT-9-123212" />Place lines specified by <em class="emphasis">address</em> in named buffer <em class="emphasis">char</em>.If no <em class="emphasis">char</em> is given, place lines in general buffer.<em class="emphasis">count</em> specifies the number of lines to yank, starting with <em class="emphasis">address</em>.</p><h4 class="refsect2">Example</h4><blockquote><pre class="code">:101,200 ya a</pre></blockquote></td></tr><tr><td valign="top"><a name="z">z</a></a></td><td><p>[<em class="replaceable"><tt>address</em>] <tt class="literal">z</tt> [<em class="replaceable">type</em>] [<em class="replaceable">count</tt></em>]</p><p><a name="IXT-9-123213" />Print a window of text with the line specified by <em class="emphasis">address</em> at the top.<em class="emphasis">count</em> specifies the number of lines to be displayed.</p><h4 class="refsect2">Type</h4><dl><dt><tt class="literal">+</tt></dt><dd>Place specified line at the top of the window (default).</p></dd><dt><tt class="literal">-</tt></dt><dd>Place specified line at the bottom of the window.</p></dd><dt><tt class="literal">.</tt></dt><dd>Place specified line in the center of the window.</p></dd><dt><tt class="literal">^</tt></dt><dd>Print the previous window.</p></dd><dt><tt class="literal">=</tt></dt><dd>Place specified line in the center of the window and leavethe current line at this line.</p></dd></dl></td></tr><tr><td valign="top"><a name="!">!</a></a></td><td><p>[<tt><em class="replaceable"><tt>address</em></tt>] <tt class="literal">!</tt><tt><em class="replaceable">command</tt></em></tt></p><p><a name="IXT-9-123214" />Execute Unix <em class="emphasis">command</em></tt> in a shell. If <em class="emphasis">address</em></tt> is specified, applythe lines contained in <em class="emphasis">address</em></tt> as standard input to <em class="emphasis">command</em></tt>,and replace the lines with the output and error output.(This is called <em class="emphasis">filtering</em></tt> the textthrough the <em class="emphasis">command</em></tt>.)</p><h4 class="refsect2">Examples</h4><blockquote><pre class="code">:!ls <i class="lineannotation">List files in the current directory</i>:11,20!sort -f <i class="lineannotation">Sort lines 11–20 of current file</i></pre></blockquote></td></tr><tr><td valign="top"><a name="=">=</a></a></td><td><p>[<tt><em class="replaceable"><tt>address</tt></em></tt>] <tt class="literal">=</tt></p><p><a name="IXT-9-123215" />Print the line number of the line indicated by <em class="emphasis">address</em></tt>. Default is line number of the last line.</p></td></tr><tr><td valign="top"><a name="< >">< ></a></a></td><td>[<tt><em class="replaceable"><tt>address</em></tt>] <tt class="literal"><</tt> [<tt><em class="replaceable">count</em></tt>]<br>    <b class="emphasis-bold">or</b><br>[<tt><em class="replaceable">address</em></tt>] <tt class="literal">></tt> [<tt><em class="replaceable">count</tt></em></tt>]<p><a name="IXT-9-123216" /><a name="IXT-9-123217" />Shift lines specified by <em class="emphasis">address</em></tt>either left (<tt class="literal"><</tt>) or right (<tt class="literal">></tt>).Only leading spaces and tabs are added or removed when shifting lines.<em class="emphasis">count</em></tt> specifies the number of lines to shift, starting with <em class="emphasis">address</em></tt>.The <tt class="literal">shiftwidth</tt> option controls the number of columnsthat are shifted. Repeating the <tt class="literal"><</tt> or<tt class="literal">></tt> increases the shift amount.For example, <tt class="literal">:>>></tt> shifts three times asmuch as <tt class="literal">:></tt>.</p></td></tr><tr><td valign="top"><a name="address">address</a></a></td><td><p><tt><em class="replaceable"><tt>address</tt></em></tt></p><p>Print the lines specified in <em class="emphasis">address</em></tt>.</p></td></tr><tr><td valign="top"><a name="RETURN">RETURN</a></a></td><td><p /><p>Print the next line in the file.</p></td></tr><tr><td valign="top"><a name="&">&</a></a></td><td><p>[<tt><em class="replaceable"><tt>address</em></tt>] <tt class="literal">&</tt> [<tt><em class="replaceable">options</em></tt>] [<tt><em class="replaceable">count</tt></em></tt>]</p><p><a name="IXT-9-123218" />Repeat the previous substitute (<tt class="literal">s</tt>) command.<em class="emphasis">count</em></tt> specifies the number of lines on which to substitute,starting with <em class="emphasis">address</em></tt>. <em class="emphasis">options</em></tt> are the same as for the substitute command.</p><h4 class="refsect2">Examples</h4><blockquote><pre class="code">:s/Overdue/Paid/ <i class="lineannotation">Substitute once on current line</i>:g/Status/& <i class="lineannotation">Redo substitution on all “Status” lines</i></pre></blockquote></td></tr><tr><td valign="top"><a name="~">~</a></a></td><td><p>[<tt><em class="replaceable"><tt>address</em></tt>] <tt class="literal">~</tt> [<tt><em class="replaceable">count</tt></em></tt>]</p><p><a name="IXT-9-123219" />Replace the last used regular expression (even if from a search, and notfrom an <tt class="literal">s</tt> command) with the replacement pattern fromthe most recent <tt class="literal">s</tt> (substitute) command.This is rather obscure;see Chapter 6 of <em class="citetitle">Learning the vi Editor</em></tt> for details.<a name="IXT-9-123220" /></p></td></tr></table><p><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch09_01.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0" /></a></td><td align="right" valign="top" width="228"><a href="ch10_01.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr><tr><td align="left" valign="top" width="228">9. The ex Editor</td><td align="center" valign="top" width="228"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0" /></a></td><td align="right" valign="top" width="228">10. The sed Editor</td></tr></table></div><hr width="684" align="left" /><img src="../gifs/navbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links" /><p><p><font size="-1"><a href="copyrght.htm">Copyright © 2003</a> O'Reilly & Associates. All rights reserved.</font></p><map name="library-map"><area shape="rect" coords="1,0,88,96" href="../index.htm"><area shape="rect" coords="90,0,165,96" href="../upt/index.htm"><area shape="rect" coords="168,1,253,107" href="../mac/index.htm"><area shape="rect" coords="255,0,335,97" href="../korn/index.htm"><area shape="rect" coords="337,0,415,109" href="../unixnut/index.htm"><area shape="rect" coords="417,0,512,122" href="../sedawk/index.htm"><area shape="rect" coords="514,0,605,105" href="../lunix/index.htm"><area shape="rect" coords="611,2,694,121" href="../vi/index.htm"></map></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -