📄 ex.html
字号:
<b>$HOME/.exrc</b>sets the editor option<b>exrc</b>,<i>ex</i>finally will attempt to readcommands from a file<b>.exrc</b>in the current directory.In the event that<i>EXINIT</i>is not set and the current directory is theuser's home directory, any<b>.exrc</b>file will only be processed once.No<b>.exrc</b>file will be read unless it is owned by thesame user ID as the effective user ID of the process.After any<b>.exrc</b>files are processed, any commands specified by the<b>-c</b>option will be processed.<p>By default,<i>ex</i>starts in the command mode, which is indicated by the <b>:</b> prompt.The input mode can be entered by<b>append</b>,<b>insert</b>or<b>change</b>commands;it can be exited (and command mode reentered) by typing a period(.)alone at the beginning of a line.There is one other mode, visual mode, in whichfull-screen editing is available.This is described more fully under the<b>visual</b>command and in the<i><a href="vi.html">vi</a></i>utility description.The command line can consist of multiple<i>ex</i>commands separatedby vertical-line characters(|).The use of commands that enter input orvisual modes in this manner, unless they are the final commandon the line, produces undefined results.<p>Command lines beginning with the double-quote character( )are ignored.This can be used for comments in an editor script.<h5><a name = "tag_001_014_598_001"> </a>Addressing in ex</h5><xref type="5" name="exaddr"></xref>Addressing in<i>ex</i>relates to the<i>current line</i>.In general, the current line isthe last line affected by a command;the exact effect on the current lineis discussed under the description ofeach command.When the buffer contains no lines, the current line is set to zero.<p>Addresses are constructed by one of the following methods:<ol><p><li>The address.(period)refers to the current line.<p><li>The address "$" refers to the last line of the buffer.<p><li>The address<i>n</i>,where<i>n</i>is a decimal number, refers to the<i>n</i>thline of the buffer.<p><li>The address<i>'x</i> refers to the line marked with themark-name character<i>x</i>,which must be a lower-case letter of the POSIX locale.Lines can be marked with the<b>ma</b>orkcommands described below.<p><li>A regular expression(RE)enclosed by slashes(/)is an address,and refers to the first line found by searchingforward from the line following the current linetoward the end of thebuffer and stopping at the first line containing astring matching the RE.The second slash can be omitted at the end of a command line.If the<b>wrapscan</b>option is set, the search will wraparound to the beginning of the bufferand continue up to and including the current line, so that the entirebuffer is searched.<p><li>An RE enclosed in question marks(?)addressesthe first line found by searchingbackwardfrom the lineprecedingthe current linetoward the beginning ofthe buffer and stopping at the first line containinga string matching the RE.The second question mark can be omitted at the end of a command line.If the<b>wrapscan</b>option is set, the search will wrap aroundfrom the beginning of the buffer to theend of the buffer and continue up to and including thecurrent line, so that the entire buffer is searched.<p><li>An address followed by a plus sign(+)or a minus sign(-)followed by adecimal numberis an offset address, and refers to the first address plus(respectively minus) the indicated number of lines.If the address is omitted, the addition or subtractionis taken with respect to the current line.<p><li>An address of "+" or "-" followed by a numberis taken with respect to the current line number; for example,-5is understood to mean.-5.<p><li>An address ending with "+" or "-" has 1 added to or subtractedfrom the address, respectively.As a consequence of this rule and of rule 8 above, the address "-"refers to the line preceding the current line.Moreover, trailing "+" and "-" characters have a cumulative effect;for example,--refers to the current line less 2.<p><li>A percent sign(%)stands for theaddress pair1,$.<p></ol><p>Commands require zero, one or two addresses.See the descriptions of<i>line</i>and<i>range</i>in<xref href=excmd><a href="#tag_001_014_598_002">Command Descriptions in ex</a></xref>.Commands that require zero addresses regard the presenceof an address as an error.<p>Adjacent addresses in a<i>range</i>must be separated from each other by a comma(,)or a semicolon(;).In the latter case, the current line(.)is set tothe first address,and only then is the second address calculated.This feature can be used to determine the startingline for forward and backward searches (see rules 5 and 6 above).The second address of any two-address sequencecorresponds to a line that follows,in the buffer, the line corresponding to the first address.The first address must be less than or equal to the second address.The first address must be greater than or equal to the first lineof the editing buffer and the last address must be less than or equalto the last line of the editing buffer.Any other case is an error.<p>All of the following examples are valid<i>addresses</i>:<dl compact><dt>+++<dd>three lines after the current line<dt>/<i>re</i>/-<dd>one line before the next occurrence of<i>re</i><dt>-2<dd>two lines before the current line.</dl><h5><a name = "tag_001_014_598_002"> </a>Command Descriptions in ex</h5><xref type="5" name="excmd"></xref>The following symbols are used in this section to representoptional modifiers.Any or all can be omitted; the defaults are shown.<dl compact><dt><i>line</i><dd>A single line address, given in any of theforms described in<xref href=exaddr><a href="#tag_001_014_598_001">Addressing in ex</a></xref>;the default for<i>line</i>is the current line.<dt><i>range</i><dd>A<i>line</i>,or a pair of line addresses, separated by a comma or semicolon(see<xref href=exaddr><a href="#tag_001_014_598_001">Addressing in ex</a></xref>for the difference between the two);the default for<i>range</i>is the current line only(.,.).A percent sign(%)stands for the range(1,$).If the range specified is such that the starting address exceedsthe ending address, the range is invalid and the command willnot be performed.If more than the expected number of addresses are given in a range,the greatest valid number of the last ones given will be used.For example,1,3,5pprints lines 3 to 5, inclusive (because two is thegreatest valid number in the range accepted by<b>print</b>).<dt><i>count</i><dd>A positive integer, specifying the number of lines to beaffected by the command;the default for<i>count</i>is 1.<dt><i>flags</i><dd>One of the characters"#",porl(ell),or both"#"andlto add numbers to list-format output.When a command with such a flagcompletes, theaddressed lineswill be written out as if by the corresponding<b>#</b>,<b>p</b>or<b>l</b>command.The use of<i>flags</i>applies to all lines written by the<b>list</b>,<b>number</b>,<b>open</b>,<b>print</b>,<b>substitute</b>,<b>visual</b>,<b>&</b>andzcommands; for other commands, it applies to thecurrent line at the completion of the command.In addition, any number of "+" or "-" characters can also begiven after the flags,in which case the line written is not the one affected by thecommand, but rather the line addressed by the offsetaddress as described above.The default for<i>flags</i>is null.<dt><i>buffer</i><dd>One of a number of named areas for saving text.The named buffersare specified by the lower-case letters of the POSIX locale.Specifying<i>buffer</i>causes 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 on the<b>put</b>command and the visual mode put commands(<b>p</b>and<b>P</b>)to specify the buffer that will provide the text to insert.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 mode<b>put</b>command) the buffer name can be specified in lower-case orupper-case with the same results.There is also one unnamed buffer, which is the repositoryfor all text deleted (with the<b>delete</b>or visual mode<b>d</b>command) or yanked (with the<b>yank</b>or visual mode<b>y</b>command) 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 is placed in buffer 1, the previous contents ofbuffer 1 are 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 does not modify the numbered buffers.Text cannot be placed directly into the numberedbuffers although it can be retrieved from them by using avisual mode<b>put</b>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>file</i><dd>A pattern used to derive a pathname; the default is thecurrent file, as defined above.If no current file has yet been established, a warning will be writtenand the command will be aborted, except where specifically notedin the individual command descriptions that follow.The pattern will be subjected to the process of shellword expansions (see<xref href=wordexp><a href="chap2.html#tag_001_006">Word Expansions</a></xref>);if more than a single pathname resultsand the command is expecting one file, the effects are unspecified.<dt><i>word</i><dd>In the POSIX locale, a<i>word</i>consists of a maximal sequence of letters, digits and underscores,delimited at both ends by characters other thanletters, digits or underscores, or by the beginning or end ofa line or the file.<dt><b>!</b><dd>A character that can beappended to the command to modify its operation, as detailedin the individual command descriptions.</dl><p>If both a<i>count</i>and a<i>range</i>are specified for acommand that uses them, the number of lines affected will betaken from the<i>count</i>value rather than the<i>range</i>.The starting line for the command is taken to be thefirst line addressed by the<i>range</i>.<p>When only a<i>line</i>or<i>range</i>is specified with nocommand, the implied command is either a<b>print</b>,<b>list</b>or<b>number</b>(<b>p</b>,<b>l</b>or<b>#</b>).The command selected will be the lastof these three commands to be used, including use as a<i>flag</i>.When no range or count is specified and the command lineis a blank line, the current line will bewritten, and the current line will be set to.+1.<p>Zero or more blank characters can precede or follow the addresses,<i>count</i>,<i>flags</i>or command name.Any object following a command name(such as<i>buffer</i>,<i>file</i>and so on)that begins with an alphabetic characterwill be separated from the command namewith at least oneblank character.<p>For each of thecommands listed below, the command can be entered as theabbreviation (those characters in the Synopsis command word preceding the<b>[),</b>the full command (all characters shown for the command word, omitting the<b>[</b>and<b>]),</b>or any subset of the characters of the full command down to the abbreviation.For example, the<b>args</b>command (shown as<b>ar[gs]</b>in the Synopsis)can be entered as<b>ar</b>,<b>arg</b>or<b>args</b>.<h5><a name = "tag_001_014_598_003"> </a>Abbreviate</h5><i>Synopsis</i>: ab<b>[</b>brev<b>]</b><i> word rhs</i><p>Add the named abbreviation to the current abbreviation list.In visual mode, if<i>word</i>is typed so that it is precededand followed by characters that cannot be part of a<i>word</i>(as defined previously),it will be replaced by the string<i>rhs</i>.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -