📄 vi.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>vi</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="vi"></a> <a name="tag_04_167"></a><!-- vi --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright © 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_04_167_01"></a>NAME</h4><blockquote>vi - screen-oriented (visual) display editor</blockquote><h4><a name="tag_04_167_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><div class="box"><code><tt><sup>[<a href="javascript:open_code('UP')">UP</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> vi</tt> <b>[</b><tt>-rR</tt><b>][</b><tt>-c</tt> <i>command</i><b>][</b><tt>-t</tt><i>tagstring</i><b>][</b><tt>-w</tt> <i>size</i><b>][</b><i>file</i> <tt>...</tt><b>]</b><tt><img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div></blockquote><h4><a name="tag_04_167_03"></a>DESCRIPTION</h4><blockquote><p>This utility shall be provided on systems that both support the User Portability Utilities option and define thePOSIX2_CHAR_TERM symbol. On other systems it is optional.</p><p>The <i>vi</i> (visual) utility is a screen-oriented text editor. Only the open and visual modes of the editor are described inIEEE Std 1003.1-2001; see the line editor <a href="../utilities/ex.html"><i>ex</i></a> for additional editingcapabilities used in <i>vi</i>. The user can switch back and forth between <i>vi</i> and <a href="../utilities/ex.html"><i>ex</i></a> and execute <a href="../utilities/ex.html"><i>ex</i></a> commands from within <i>vi</i>.</p><p>This reference page uses the term <i>edit buffer</i> to describe the current working text. No specific implementation is impliedby this term. All editing changes are performed on the edit buffer, and no changes to it shall affect any file until an editorcommand writes the file.</p><p>When using <i>vi</i>, the terminal screen acts as a window into the editing buffer. Changes made to the editing buffer shall bereflected in the screen display; the position of the cursor on the screen shall indicate the position within the editingbuffer.</p><p>Certain terminals do not have all the capabilities necessary to support the complete <i>vi</i> definition. When these commandscannot be supported on such terminals, this condition shall not produce an error message such as "not an editor command" orreport a syntax error. The implementation may either accept the commands and produce results on the screen that are the result ofan unsuccessful attempt to meet the requirements of this volume of IEEE Std 1003.1-2001 or report an error describing theterminal-related deficiency.</p></blockquote><h4><a name="tag_04_167_04"></a>OPTIONS</h4><blockquote><p>The <i>vi</i> utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap12.html#tag_12_02">Section 12.2, Utility Syntax Guidelines</a>.</p><p>The following options shall be supported:</p><dl compact><dt><b>-c </b> <i>command</i></dt><dd>See the <a href="../utilities/ex.html"><i>ex</i></a> command description of the <b>-c</b> option.</dd><dt><b>-r</b></dt><dd>See the <a href="../utilities/ex.html"><i>ex</i></a> command description of the <b>-r</b> option.</dd><dt><b>-R</b></dt><dd>See the <a href="../utilities/ex.html"><i>ex</i></a> command description of the <b>-R</b> option.</dd><dt><b>-t </b> <i>tagstring</i></dt><dd>See the <a href="../utilities/ex.html"><i>ex</i></a> command description of the <b>-t</b> option.</dd><dt><b>-w </b> <i>size</i></dt><dd>See the <a href="../utilities/ex.html"><i>ex</i></a> command description of the <b>-w</b> option.</dd></dl></blockquote><h4><a name="tag_04_167_05"></a>OPERANDS</h4><blockquote><p>See the OPERANDS section of the <a href="../utilities/ex.html"><i>ex</i></a> command for a description of the operands supportedby the <i>vi</i> command.</p></blockquote><h4><a name="tag_04_167_06"></a>STDIN</h4><blockquote><p>If standard input is not a terminal device, the results are undefined. The standard input consists of a series of commands andinput text, as described in the EXTENDED DESCRIPTION section.</p><p>If a read from the standard input returns an error, or if the editor detects an end-of-file condition from the standard input,it shall be equivalent to a SIGHUP asynchronous event.</p></blockquote><h4><a name="tag_04_167_07"></a>INPUT FILES</h4><blockquote><p>See the INPUT FILES section of the <a href="../utilities/ex.html"><i>ex</i></a> command for a description of the input filessupported by the <i>vi</i> command.</p></blockquote><h4><a name="tag_04_167_08"></a>ENVIRONMENT VARIABLES</h4><blockquote><p>See the ENVIRONMENT VARIABLES section of the <a href="../utilities/ex.html"><i>ex</i></a> command for the environment variablesthat affect the execution of the <i>vi</i> command.</p></blockquote><h4><a name="tag_04_167_09"></a>ASYNCHRONOUS EVENTS</h4><blockquote><p>See the ASYNCHRONOUS EVENTS section of the <a href="../utilities/ex.html"><i>ex</i></a> for the asynchronous events that affectthe execution of the <i>vi</i> command.</p></blockquote><h4><a name="tag_04_167_10"></a>STDOUT</h4><blockquote><p>If standard output is not a terminal device, undefined results occur.</p><p>Standard output may be used for writing prompts to the user, for informational messages, and for writing lines from thefile.</p></blockquote><h4><a name="tag_04_167_11"></a>STDERR</h4><blockquote><p>If standard output is not a terminal device, undefined results occur.</p><p>The standard error shall be used only for diagnostic messages.</p></blockquote><h4><a name="tag_04_167_12"></a>OUTPUT FILES</h4><blockquote><p>See the OUTPUT FILES section of the <a href="../utilities/ex.html"><i>ex</i></a> command for a description of the output filessupported by the <i>vi</i> command.</p></blockquote><h4><a name="tag_04_167_13"></a>EXTENDED DESCRIPTION</h4><blockquote><p>If the terminal does not have the capabilities necessary to support an unspecified portion of the <i>vi</i> definition,implementations shall start initially in <a href="../utilities/ex.html"><i>ex</i></a> mode or open mode. Otherwise, afterinitialization, <i>vi</i> shall be in command mode; text input mode can be entered by one of several commands used to insert orchange text. In text input mode, <ESC> can be used to return to command mode; other uses of <ESC> are described laterin this section; see <a href="#tag_04_167_13_16">Terminate Command or Input Mode</a> .</p><h5><a name="tag_04_167_13_01"></a>Initialization in ex and vi</h5><p>See <a href="ex.html#tag_04_45_13_01"><i>Initialization in ex and vi</i></a> for a description of <a href="../utilities/ex.html"><i>ex</i></a> and <i>vi</i> initialization for the <i>vi</i> utility.</p><h5><a name="tag_04_167_13_02"></a>Command Descriptions in vi</h5><p>The following symbols are used in this reference page to represent arguments to commands.</p><dl compact><dt><i>buffer</i></dt><dd>See the description of <i>buffer</i> in the EXTENDED DESCRIPTION section of the <a href="../utilities/ex.html"><i>ex</i></a>utility; see <a href="ex.html#tag_04_45_13_10"><i>Command Descriptions in ex</i></a> . <p>In open and visual mode, when a command synopsis shows both [ <i>buffer</i>] and [ <i>count</i>] preceding the command name,they can be specified in either order.</p></dd><dt><i>count</i></dt><dd>A positive integer used as an optional argument to most commands, either to give a repeat count or as a size. This argument isoptional and shall default to 1 unless otherwise specified. <p>The Synopsis lines for the <i>vi</i> commands <control>-G, <control>-L, <control>-R, <control>-],<b>%</b>, <b>&</b>, <b>^</b>, <b>D</b>, <b>m</b>, <b>M</b>, <b>Q</b>, <b>u</b>, <b>U</b>, and <b>ZZ</b> do not have<i>count</i> as an optional argument. Regardless, it shall not be an error to specify a <i>count</i> to these commands, and anyspecified <i>count</i> shall be ignored.</p></dd><dt><i>motion</i></dt><dd>An optional trailing argument used by the <b>!</b>, <b><</b>, <b>></b>, <b>c</b>, <b>d</b>, and <b>y</b> commands, whichis used to indicate the region of text that shall be affected by the command. The motion can be either one of the commandcharacters repeated or one of several other <i>vi</i> commands (listed in the following table). Each of the applicable commandsspecifies the region of text matched by repeating the command; each command that can be used as a motion command specifies theregion of text it affects. <p>Commands that take <i>motion</i> arguments operate on either lines or characters, depending on the circumstances. When operatingon lines, all lines that fall partially or wholly within the text region specified for the command shall be affected. Whenoperating on characters, only the exact characters in the specified text region shall be affected. Each motion command specifiesthis individually.</p><p>When commands that may be motion commands are not used as motion commands, they shall set the current position to the currentline and column as specified.</p><p>The following commands shall be valid cursor motion commands:</p><pre><tt><apostrophe> ( - j H<carriage-return> ) $ k L<comma> [[ % l M<control>-H ]] _ n N<control>-N { ; t T<control>-P } ? w W<grave accent> ^ b B<newline> + e E<space> | f F<zero> / h G</tt></pre><p>Any <i>count</i> that is specified to a command that has an associated motion command shall be applied to the motion command. Ifa <i>count</i> is applied to both the command and its associated motion command, the effect shall be multiplicative.</p></dd></dl><p>The following symbols are used in this section to specify locations in the edit buffer:</p><dl compact><dt><i>current character</i></dt><dd><br>The character that is currently indicated by the cursor.</dd><dt><i>end of a line</i></dt><dd><br>The point located between the last non- <newline> (if any) and the terminating <newline> of a line. For an empty line,this location coincides with the beginning of the line.</dd><dt><i>end of the edit buffer</i></dt><dd><br>The location corresponding to the end of the last line in the edit buffer.</dd></dl><p>The following symbols are used in this section to specify command actions:</p><dl compact><dt><i>bigword</i></dt><dd>In the POSIX locale, <i>vi</i> shall recognize four kinds of <i>bigwords</i>: <ol><li><p>A maximal sequence of non- <blank>s preceded and followed by <blank>s or the beginning or end of a line or the editbuffer</p></li><li><p>One or more sequential blank lines</p></li><li><p>The first character in the edit buffer</p></li><li><p>The last non- <newline> in the edit buffer</p></li></ol></dd><dt><i>word</i></dt><dd>In the POSIX locale, <i>vi</i> shall recognize five kinds of words: <ol><li><p>A maximal sequence of letters, digits, and underscores, delimited at both ends by:</p><ul><li><p>Characters other than letters, digits, or underscores</p></li><li><p>The beginning or end of a line</p></li><li><p>The beginning or end of the edit buffer</p></li></ul></li><li><p>A maximal sequence of characters other than letters, digits, underscores, or <blank>s, delimited at both ends by:</p><ul><li><p>A letter, digit, underscore</p></li><li><p><blank>s</p></li><li><p>The beginning or end of a line</p></li><li><p>The beginning or end of the edit buffer</p></li></ul></li><li><p>One or more sequential blank lines</p></li><li><p>The first character in the edit buffer</p></li><li><p>The last non- <newline> in the edit buffer</p></li></ol></dd><dt><i>section boundary</i></dt><dd><br>A <i>section boundary</i> is one of the following: <ol><li><p>A line whose first character is a <form-feed></p></li><li><p>A line whose first character is an open curly brace ( <tt>'{'</tt> )</p></li><li><p>A line whose first character is a period and whose second and third characters match a two-character pair in the <b>sections</b>edit option (see <a href="../utilities/ed.html"><i>ed</i></a>)</p></li><li><p>A line whose first character is a period and whose only other character matches the first character of a two-character pair inthe <b>sections</b> edit option, where the second character of the two-character pair is a <space></p></li><li><p>The first line of the edit buffer</p></li><li><p>The last line of the edit buffer if the last line of the edit buffer is empty or if it is a <b>]]</b> or <b>}</b> command;otherwise, the last non- <newline> of the last line of the edit buffer</p></li></ol></dd><dt><i>paragraph boundary</i></dt><dd><br>A <i>paragraph boundary</i> is one of the following:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -