📄 vi.html
字号:
<p>An interrupt typed during text input,or during the input of a command on the bottom line,will terminate the input (or cancel the command)and will return the editor to command mode.During command mode, an interruptwill alert the terminal.In general, an alert indicates an error (such as unrecognised key).<p>Lines displayed on the screen containing only a tilde(~)indicatethat the last line above them is the last linein the editing buffer(the ~lines are past the end of the editing buffer).<p>There may be lines on the screen marked with an "@".These indicate space on the screen notcorresponding to lines in the file.This will happen if there is space at the bottomof the screen for some text, but the next line ofthe buffer will not fit.(It may also happen on a terminal with limited local intelligence.In this case, these lines can be removed by entering a<control>-R,forcing the editor to refresh the screen.)<h5><a name = "tag_001_014_2821_001"> </a>Command Descriptions in vi</h5>The cursor, in general, is placed on the current lineand in the current column position as noted for each commanddescribed below.If the current line is not in the display window,then the display window will be either scrolled or refreshedto cause the current line to be in the display window.If the screen is refreshed, the current line will be positionedas close to the center of the display window as possible.If the current line is less than one-half window linesfrom thebeginning of the editing buffer, the first line of the bufferwill be displayed on the first line of the display window.If the current line is less than one-half window linesfrom the end of the editing buffer, the remaining lines of the displaywindow after the last line of the file will contain only a~character in column position 1.If the screen is scrolled rather than refreshed, thecurrent line will be placed at the top of the display windowif the current line is before the first line displayed.If the current line is after the last line displayed,the display window will be scrolled up and the current linewill be placed on the last line of the display window.<p>As stated previously, the cursor is generally placedon the current column position of the current line.The one exception to this is if the current column positionis beyond the end of the current line.In this case, the cursor will be placed on the last characterof the current line.However, the current column position value will not be altered by this.Thus, if the current line changes to a longer line, the cursorwill be moved back out to the current column position orto the end of the line if it is shorter than the current column.<p>Unless otherwise specified, the commands are interpreted in commandmode and have no special effect in input mode.<p>Some of the following command descriptions (such asa,A,c,and so on) move the cursor and enter input mode.The indications of<i>Current line</i>and<i>Current column</i>are for the cursor movement up to the beginning of input mode.Depending on the text inserted, the cursor will generally wind upin a totally different location by the time command mode is reentered.The cursor movement that accompanies the transitionfrom input mode to command mode is described in<xref href=viterm><a href="#tag_001_014_2821_018">Terminate Command or Input Mode</a></xref>.<p>The following symbols are used in this section to representarguments to commands, to describe commands or to specify the newvalues of the current line and column indicators followingexecution of the command.<dl compact><dt><i>bigword</i><dd>A maximal sequence of non-blank characters preceded and followed byblankcharacters or the beginning or end of a line or the file.<dt><i>buffer</i><dd>One of a number of named areas for saving text.Commands that change or delete text can be preceded by abuffer specification argument<i>buffer</i>.It is specifiedin the form<b>"</b><i>c</i>,where<i>c</i>represents the name of abuffer, one of the lower-case letters of the POSIX locale.Specifying<i>buffer</i>will cause the area of text affected bythe command to be stored into the buffer as it was beforethe command took effect.This argument is also used onthe put commands(pandP)to specify the buffer that will provide the text to insert.When a command synopsis shows both<b>[</b><i>buffer</i><b>]</b>and<b>[</b><i>count</i><b>]</b>preceding the command letter,either can precede the other.If the buffer name is specified in upper-case,and the buffer is to be modified (as with adeletion or yanking command)the buffer will be appended torather than being overwritten.If the buffer is not to be modified (as in a visual modeput commands) the buffer name can be specified in lower-case orupper-case with the same results.There will be also one unnamed buffer, which is the repositoryfor all text deleted (with the<b>delete</b>or visual modedcommand) or yanked (with the<b>yank</b>or visual modeycommand) when no buffer is specified.There are alsonumbered buffers, 1 to 9, inclusive, which are accessible only fromvisual mode.These buffers are special in that,in visual mode, when deleted text is placed in the unnamed buffer,it also will be placed in buffer 1, the previous contents ofbuffer 1 will be placed in buffer 2, and so on.Any text in buffer 9 will be lost.Text that is yanked (or otherwise copied) into the unnamedbuffer will not modify the numbered buffers.Text cannot be placed directly into the numberedbuffers although it can be retrieved from them by using avisual mode put command with the buffer name given as a number.When the<i>buffer</i>modifier is not used in the commands below, the unnamed bufferis the default.<dt><i>column</i><dd>The (previous) value of the current column indicator.<dt><i>count</i><dd>A positive integer used as an optional argument to most commands,either to give a size or a position (fordisplay or movement commands), or as a repeat count (forcommands that change text).This argument is optionaland defaults to 1 unless otherwise noted in theindividual command description.<dt><i>end-of-line</i><dd>A description of the current column indicator valuemeaning that the current columnindicator will be set always to indicate the last character ofthe current line.Until the current column indicator ischanged, the cursor will be always positioned to the lastcharacter of whatever line is current.<dt><i>line</i><dd>The (previous) value of the current line indicator.<dt><i>non-blank</i><dd>A description of the current column indicator valuemeaning that the current column indicatorwill be set to the position of the firstnon-blank character of the current line.If the current line has no non-blank characters,the indicator will be set to the position of thelast character of the line.<dt><i>motion</i><dd>A command used as an optional trailing argument to some commands,indicating the extent of text to be affected by the command.The<i>motion</i>argument can be either the command character repeatedor a cursor movement command.In the former case, exactly the current line is affected.In the latter case, the region specified will be from the current cursorposition to just before the cursor position indicated by the motion command.If the command operates on linesonly, then all the lines that fall partly or whollywithin this region are affected.Otherwise, the exact region as described above is affected.The following commands are considered to be cursor motion commands:<pre><dl compact><dt> <dd><table <tr valign=top><th align=left>$<th align=left>^<th align=left>e<th align=left>M<tr valign=top><td align=left>%<td align=left>"<td align=left><control>-F<td align=left><control>-N<tr valign=top><td align=left>''<td align=left>`<i>letter</i><td align=left>F<td align=left>N<tr valign=top><td align=left>'<i>letter</i><td align=left>{<td align=left>f<td align=left>n<tr valign=top><td align=left>(<td align=left>|<td align=left>G<td align=left><control>-P<tr valign=top><td align=left>)<td align=left>}<td align=left><control>-H<td align=left><space><tr valign=top><td align=left>,<td align=left>0<td align=left>H<td align=left><control>-T<tr valign=top><td align=left>-<td align=left><control>-B<td align=left><control>-J<td align=left>T<tr valign=top><td align=left>/<td align=left>B<td align=left>j<td align=left>t<tr valign=top><td align=left>;<td align=left>b<td align=left>k<td align=left><control>-U<tr valign=top><td align=left>?<td align=left><control>-D<td align=left>L<td align=left>W<tr valign=top><td align=left>[[<td align=left><control>-E<td align=left>l<td align=left>w<tr valign=top><td align=left>]]<td align=left>E<td align=left><control>-M<td align=left><control>-Y</table></dl></pre><p>The optional<i>count</i>prefix available for some of the motion commandscan be included and is considered part of the<i>motion</i>argument.For example, in<b>c2w</b>,the<b>2w</b>is the<i>motion</i>argument.<p><dt><i>previous context</i><dd>A state set whenever a non-relative motion command is executed in<i>vi</i>.<p><dt><i>paragraph</i><dd>An area of text that begins with either the beginning of a file,an empty line, or section boundary and continuesuntil either an empty line, section boundary or the end ofthe editing buffer.Additional paragraph boundaries can be defined by the<i><a href="ex.html">ex</a></i><b>paragraph</b>option.<p><dt><i>section</i><dd>An area of text that starts with a line whose first characteris either aform-feed characteror an open brace({)and continues until the next section or theend of the editing buffer.The beginning and end of the editing buffer are also consideredsection boundaries.Additional section boundaries can be defined by the<i><a href="ex.html">ex</a></i><b>sections</b>option.<p><dt><i>sentence</i><dd>An area of text that begins with either the beginning ofthe editing buffer or the first non-blank character following theprevious sentence, paragraph or section boundaryand continues until the end of the editing buffer or aperiod, exclamation point or question mark (".", "!", "?")character followed by either an end-of-line or twospace characters.Any number of closing parentheses, brackets or double-quote(")", "]", """) characters can appear between theperiod, exclamation point or question mark and the space charactersor end-of-line.<p><dt><i>window</i><dd>The current value of the editor option<b>window</b>.<p><dt><i>word</i><dd>In the POSIX locale,<i>vi</i>recognises two kinds of words:<ul><p><li>A maximal sequence of letters, digits andunderscores, delimited at both ends by:characters other than letters, digits or underscores;the beginning or end of a line;or the end of the editing buffer.<p><li>A maximal sequence of characters otherthan letters, digits, underscores or white space,delimited at both ends by:a letter, digit, underscore or white space;the beginning or end of a line;or the end of the editing buffer.<p></ul><p><dt><b>!</b><dd>A character thatcan be appended to the command to modify its operation as detailedin the individual command descriptions.<p></dl><p>After processing acommand, if the current line and column indicators have beenchanged to specify a character not currently on the screen, theeditor will scroll or page thetext to bring the needed character onto the screen.If the new current line is within<i>window</i>lines of the previous current line, and the terminal is capable ofscrolling in the indicated direction, the text will be scrolled theminimum number of lines necessary to present the needed character.Otherwise, the screen will be redisplayed with the new current linepositioned in the middle of the screen.<p>The following rules specify how exceptions will be handled.When a movement command would cause a window to display beyondthe beginning of theediting buffer, the window displayed is the windowbeginning with the first line of the editing buffer.When a movementcommand would cause a window to be displayed beyond the end ofthe editing buffer,the terminal will be alertedand the command aborted.When the current line is empty, the cursorwill be placed in the first position of the line on the screen.When the current column indicator value is beyond the end of thecurrent line, the cursor will be placed on the last character of thecurrent line, but the current column indicator will be unchanged.<p>The following rules specify how position exceptions will be handled.When the current column indicator is at the beginning (end) of aline and would be set to a position before the beginning (afterthe end) of the current line, the command will not be executed,the terminal will be alerted,and the current positionwill remain unchanged.Otherwise, when the current column indicatorwould be set to a position before the beginning (after the end) ofthe current line, it will be set instead to the position of the first(last) character of that line.When the current line indicatorwould be set to a position before the beginning (after the end) ofthe editing buffer, the command will not be executed,the terminal will be alerted,and the current positionwill remain unchanged.<h5><a name = "tag_001_014_2821_002"> </a>Page Backwards</h5><pre><code><i>Synopsis</i>: <b>[</b><i>count</i><b>]</b> <control>-B</code></pre><p>Page backward in the file, allowing two lines ofoverlap, by displaying the window starting at line[<i>line</i>-(<i>count</i>*(<i>window</i>-2))].<p><i>Current line :</i>The last line displayed.<p><i>Current column :</i>Move to the first non-blank character of the current lineor the first character if the line is a blank line.<h5><a name = "tag_001_014_2821_003"> </a>Scroll Forward</h5><pre><code><i>Synopsis</i>: <b>[</b><i>count</i><b>]</b> <control>-D</code></pre><p>Scroll forward<i>count</i>lines in the file.If<i>count</i>isnot specified, the same number of lines will be scrolled as bythe previous<control>-Dor<control>-Ucommand.On thefirst<control>-Dor<control>-Ucommand, the amountscrolled will be one-half the number of lines in a screenful.See the<i><a href="ex.html">ex</a></i><b>scroll</b>option.<p><i>Current line :</i>(<i>line</i>+ amount scrolled).<p><i>Current column :</i>Move to the first non-blank character of the current lineor the first character if the line is a blank line.<h5><a name = "tag_001_014_2821_004"> </a>Scroll Forward by Line</h5><pre><code><i>Synopsis</i>: <b>[</b><i>count</i><b>]</b> <control>-E</code></pre><p>Scroll forward<i>count</i>lines, leaving the current lineand column as is if possible.<p><i>Current line :</i>Unchanged unless the current line scrolls off thescreen; otherwise, move to the first line displayed.<p><i>Current column :</i>Unchanged unless the current line scrolls off the screen; otherwise,move to the first character if it is a blank line or the last characterof the line if the position of the current column is further into theline than the position of the last column of the line.<h5><a name = "tag_001_014_2821_005"> </a>Page Forward</h5><pre><code><i>Synopsis</i>: <b>[</b><i>count</i><b>]</b> <control>-F</code></pre><p>Page forward in the file, allowing two lines ofoverlap, by displaying the window starting at line[<i>line</i>+(<i>count</i>*(<i>window</i>-2))].<p><i>Current line :</i>The first line displayed.<p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -