📄 ex.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>ex</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_001_014_586"> </a>NAME</h4><blockquote>ex - text editor</blockquote><h4><a name = "tag_001_014_587"> </a>SYNOPSIS</h4><blockquote><pre><code>ex <b>[</b>-rR<b>]</b>[-l<b>][</b>-s | -v <b>][</b>-c <i>command</i><b>]</b>-t <i>tagstring</i><b>][</b>-w <i>size</i><b>][</b><i>file</i>...<b>]</b>ex <b>[</b>-rR<b>][</b>-l<b>][</b>- | -v <b>][</b>+<i>command</i><b>][</b>-t <i>tagstring</i><b>][</b>-w <i>size</i><b>][</b><i>file</i>...<b>]</b></code></pre></blockquote><h4><a name = "tag_001_014_588"> </a>DESCRIPTION</h4><blockquote>The<i>ex</i>utility is a line-oriented text editor thatsupports both line and full-screen editing (see<i><a href="vi.html">vi</a></i>).<p>Certain block-mode terminals do not have all the capabilitiesnecessary to support the complete<i>ex</i>definition, such as thefull-screen editing commands(<i>visual</i>mode) or<i>open mode .</i>When these commands cannot be supported on such terminals, thiscondition will not produce an error message such as "not an editorcommand" nor report a syntax error.The implementation may either accept thecommands and produceresults on thescreen that are the result of an unsuccessful attempt to meet therequirements of this specification orreport an errordescribing the terminal-related deficiency.The affected commands arenoted as they occur later in this section.</blockquote><h4><a name = "tag_001_014_589"> </a>OPTIONS</h4><blockquote>The<i>ex</i>utility supports the <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b> </a> .<p>The following options are supported:<dl compact><dt><b>-c </b><i>command</i><dd><dt>+<i>command</i><dd>Begin editing by executing the specified<i>ex</i>command-mode commands.As with normal editing command-line entries, the<i>command</i>option-argument can consist of multiple<i>ex</i>commands separatedby vertical-line characters(|).The use of commands that enter input orvisual modes in this manner produces undefined results.<dt><b>-l</b><dd>(The letter ell.)Set lisp mode; indents appropriately for Lisp code; the<b>()</b>,<b>{}</b>,<b>[[</b>and<b>]]</b>commands in visual mode are modified to have meaning for Lisp.<dt><b>-r</b><dd>Recover the named files after an editor or system crash, afterthe editor has been terminated by a signal, or after the use of a<b>preserve</b>editor command.A<i>crash</i>in this context is anunexpected failure of the system or utility that requiresrestarting the failed system or utility.A system crash impliesthat any utilities running at the time also crash.In the case of an editor or system crash,the degree of recovery (the number of changesto the buffer since the most recent<b>preserve</b>command) available is unspecified.If no<i>file</i>operands are given,all other options, the<i>EXINIT</i>variable and any<b>.exrc</b>files will be ignored;a list of all recoverable filesavailable to the invoking user will be written;and<i>ex</i>will exit without reading files or processing user commands.<dt><b>-R</b><dd>Set read-only mode, preventing accidental overwriting of the files.Any command that would write to a file will require the"!"suffix (see, for example, the<b>write</b>command)to be effective in this mode.<dt><b>-s</b><dd><dt><b>-</b><dd>Prepare<i>ex</i>for batch use by taking the following actions:<ul><li>Suppress writing prompts and informational(but not diagnostic) messages.<li>Ignore the value of<i>TERM</i>and any implementation default terminal type andassume the terminal is a type incapable of supportingvisual mode; see the<b>visual</b>commandand the description of<i><a href="vi.html">vi</a></i>.<li>Suppress the use of the<i>EXINIT</i>environment variableand the reading of any<b>.exrc</b>file (see the EXTENDED DESCRIPTION section).</ul><dt><b>-t </b><i>tagstring</i><dd>Edit the file containing the specified<i>tagstring</i>and proceed as if the first command were<b>:tag</b><i>tagstring</i>.(See<i><a href="ctags.html">ctags</a></i>.)The tags feature represented by<b>-t</b> <i>tagstring</i>and the<b>ta</b>command are optional.It is provided on any system thatalso provides a conforming implementation of<i><a href="ctags.html">ctags</a></i>;otherwise, the use of<b>-t</b>produces undefined results.<dt><b>-v</b><dd>Invoke<i><a href="vi.html">vi</a></i>.<dt><b>-w </b><i>size</i><dd>Set the value of the<i>window</i>editor option to<i>size</i>.</dl><p>If both the<b>-t</b> <i>tagstring</i>and<b>-c</b> <i>command</i>(or the obsolescent<i>+command</i>)options are given, the<b>-t</b> <i>tagstring</i>will be processed first; that is,the file containing the tag is selected by<b>-t</b>and then the command is executed.</blockquote><h4><a name = "tag_001_014_590"> </a>OPERANDS</h4><blockquote>The following operand is supported:<dl compact><dt><i>file</i><dd>A pathname of a file to be edited.</dl></blockquote><h4><a name = "tag_001_014_591"> </a>STDIN</h4><blockquote>The standard input must be a text file consisting of commands,as described in the EXTENDED DESCRIPTION section.</blockquote><h4><a name = "tag_001_014_592"> </a>INPUT FILES</h4><blockquote>Input files must be text files or files that would be text filesexcept for an incomplete last line that is not longer than{LINE_MAX}-1bytes in length and contains no NUL characters.The editing of other forms of files may optionally be allowed by<i>ex</i>implementations.<p>The<b>.exrc</b>files (see the EXTENDED DESCRIPTION section)must be text files consisting of commands.<p>By default,<i>ex</i>reads lines from the files to be edited withoutinterpreting any of those lines as any form of editor command.</blockquote><h4><a name = "tag_001_014_593"> </a>ENVIRONMENT VARIABLES</h4><blockquote>The following environment variables affect the execution of<i>ex</i>:<dl compact><dt><i>COLUMNS</i><dd>Override the system-selected horizontal screen size.Seethe <b>XBD</b> specification, <a href="../xbd/envvar.html"><b>Environment Variables</b> </a> for valid values and results when it is unset or null.<dt><i>EXINIT</i><dd>Determine a list of<i>ex</i>commands that are executed on editor start-up,before reading the first file.The list can contain multiple commands by separatingthem using a vertical-line(|)character.See the EXTENDED DESCRIPTION sectionfor more details of the initialisation phase.<dt><i>HOME</i><dd>Determinea pathname of a directory that will be searched for an editorstart-up file named<b>.exrc</b>;see the EXTENDED DESCRIPTION section for details.<dt><i>LANG</i><dd>Provide a default value for the internationalisation variablesthat are unset or null.If<i>LANG</i>is unset or null, the corresponding value from theimplementation-dependent default locale will be used.If any of the internationalisation variables contains an invalid setting, theutility will behave as if none of the variables had been defined.<dt><i>LC_ALL</i><dd>If set to a non-empty string value,override the values of all the other internationalisation variables.<dt><i>LC_COLLATE</i><dd>Determine the locale for thebehaviour of ranges, equivalence classesand multi-character collating elementswithin regular expressions.<dt><i>LC_CTYPE</i><dd>Determine thelocale for the interpretation of sequences of bytes of text data ascharacters (for example, single- as opposed to multi-byte charactersin arguments and input files),the behaviour of character classes within regular expressions,the classification of characters as upper- or lower-case letters,the case conversion of letters,and the detection of word boundaries.<dt><i>LC_MESSAGES</i><dd>Determine the locale that should be used to affectthe format and contents of diagnosticmessages written to standard error.<dt><i>LINES</i><dd>Override the system-selected vertical screen size,used as the number of lines in a screenful and the verticalscreen size in visual mode.Seethe <b>XBD</b> specification, <a href="../xbd/envvar.html"><b>Environment Variables</b> </a> for valid values and results when it is unset or null.<dt><i>NLSPATH</i><dd>Determine the location of message cataloguesfor the processing of<i>LC_MESSAGES .</i><dt><i>PATH</i><dd>Determine the search pathfor the shell command specified in the editor commands<b>shell</b>,<b>read</b>and<b>write</b>;seethe description of command search and execution in<xref href=cmdsea><a href="chap2.html#tag_001_009_001_001">Command Search and Execution</a></xref>.<dt><i>SHELL</i><dd>Determine the preferred command-line interpreter for use in"!",<b>shell</b>,<b>read</b>and other commands with an operand of the form!<i>string</i>For the<b>shell</b>command, the program will be invoked with the single argument<b>-i</b>,for all others it will be invoked with the two arguments<b>-c</b>and<i>string</i>.If no<i>SHELL</i>environment variable is set,or it is set to a null string, the<i><a href="sh.html">sh</a></i>utility will be used.<dt><i>TERM</i><dd>Determine the name of the terminal type.If this variable isunset or null, an unspecified default terminal type will be used.</dl></blockquote><h4><a name = "tag_001_014_594"> </a>ASYNCHRONOUS EVENTS</h4><blockquote>The following actions will be taken upon receipt of signals:<dl compact><dt>SIGINT<dd>When an interrupt occurs,<i>ex</i>will alert the terminal and write a message.The current editor command will be aborted and<i>ex</i>will return to the command level andprompt for another command.If the standard input is not a terminal device,<i>ex</i>will exit at the interrupt and return a non-zero exit status.(The alerting actioncan be modified by the use of the<b>errorbells</b>editor option; see<xref href=exedops><a href="#tag_001_014_598_052">Edit Options in ex</a></xref>.)<dt>SIGCONT<dd>The screen will be refreshed (if in visual mode).<dt>SIGHUP<dd>If the current buffer has changed since the last<b>e</b>or<b>w</b>command,<i>ex</i>will attempt to save the current file in a state suchthat it can be recovered later by an<i>ex</i><b>-r</b>command.</dl><p>The action taken for all other signals is unspecified.<br></blockquote><h4><a name = "tag_001_014_595"> </a>STDOUT</h4><blockquote>The standard output is used only for writing prompts to the user,for informational messages and for writing lines from the file.</blockquote><h4><a name = "tag_001_014_596"> </a>STDERR</h4><blockquote>Used only for diagnostic messages.</blockquote><h4><a name = "tag_001_014_597"> </a>OUTPUT FILES</h4><blockquote>The output from<i>ex</i>must be text files that are identical tothe input files if no changes have been made to the filesby commands,with the exception that in all caseswhere a forced session termination (the<i>ex</i>commandq!)has not been issued prior to any file write,a trailingnewline characterwill be added to the last line of the file if one was notpresent in the input.</blockquote><h4><a name = "tag_001_014_598"> </a>EXTENDED DESCRIPTION</h4><blockquote>The pathname of the file being edited by<i>ex</i>is referred to as the<i>current</i>file.The text of the file is read into aworking version of the file (called<i>buffer</i>in this section;intermediate versions of the buffer may be keptin a file that is created in the directoryindicated by the<b>directory</b>editor option)and all editing changes are performed on that version;the changes have no effect on the original file until an<i>ex</i>command causes the file to be written out.Lines in the buffer may each be limited to{LINE_MAX}bytes and an error message may be written if the limit is exceededduring editing.<p>The<i>alternative</i>pathname is the name of the last file mentioned in aneditor command, or the previous current pathname if the last filementioned became the current file.When the character"%"appears in a pathname entered as part of a command argument,it is replaced by the current pathname;the character"#"is replaced by the alternative pathname.Any character, including"%"and"#",retains its literal value (is escaped)when preceded by a backslash.<p>When an error occurs,<i>ex</i>will alert the terminal and write a message.(The alerting actioncan be modified by the use of the<b>errorbells</b>editor option.)<p>If the system crashes,<i>ex</i>will attempt to preserve the buffer if any unwritten changes were made.The command-line option<b>-r</b>can be used to retrieve the saved changes.<p>During initialisation, before thefirst file is read or any user commands from the terminal are processed,if the environment variable<i>EXINIT</i>is set, the editor will execute the<i>ex</i>commands contained in that variable.If the variable is not set,<i>ex</i>will attempt to readcommands from the file<b>$HOME/.exrc</b>(the file<b>.exrc</b>in the directory referred to by the<i>HOME</i>environment variable).If and only if<i>EXINIT</i>or
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -