neulab/tldr huggingface dataset:
If no '!'  is appended to the command name, and the edit buffer has been modified since the last complete write, it shall be an error, unless the file is successfully written as specified by the autowrite option.
If one or more files is specified:
1. Set the argument list to the specified filenames.
2. Set the current argument list reference to be the first entry in the argument list.
3. Set the current pathname to the first filename specified.
1. It shall be an error if there are no more filenames in the argument list after the filename currently referenced.
2. Set the current pathname and the current argument list reference to the filename after the filename currently referenced in the argument list.
Replace the contents of the edit buffer with the contents of the file named by the current pathname. If for any reason the contents of the file cannot be accessed, the edit buffer shall be empty.
This command shall be affected by the autowrite and writeany edit options.
The +command option shall be <blank>-delimited; <blank> characters can be escaped by preceding them with a <backslash> character. The +command shall be interpreted as an ex command immediately after the contents of the edit buffer have been replaced and the current line and column have been set.
Current line: Set as described for the edit command.
Current column: Set as described for the edit command.
Number Synopsis:
[2addr] nu[mber][count][flags] [2addr] #[count][flags]
These commands shall be equivalent to the ex command:
[2addr] p[rint][count] #[flags]
Open Synopsis:
[1addr] o[pen] /pattern/ [flags]
This command need not be supported on block-mode terminals or terminals with insufficient capabilities. If standard input, standard output, or standard error are not terminal devices, the results are unspecified.
Enter open mode.
The trailing delimiter can be omitted from pattern at the end of the command line. If pattern is empty (for example, "//") or not specified, the last regular expression used in the editor shall be used as the pattern. The pattern can be delimited by <slash> characters (shown in the Synopsis), as well as any alphanumeric, or non-<blank> other than <backslash>, <vertical-line>, <newline>, or double-quote.
Current line: Set to the specified line.
Preserve Synopsis:
pre[serve]
Save the edit buffer in a form that can later be recovered by using the -r option or by using the ex recover command. After the file has been preserved, a mail message shall be sent to the user. This message shall be readable by invoking the mailx utility. The message shall contain the name of the file, the time of preservation, and an ex command that could be used to recover the file. Additional information may be included in the mail message.
Print Synopsis:
[2addr] p[rint][count][flags]
Write the addressed lines. The behavior is unspecified if the number of columns on the display is less than the number of columns required to write any single character in the lines being written.
Non-printable characters, except for the <tab>, shall be written as implementation-defined multi-character sequences.
If the # flag is specified or the number edit option is set, each line shall be preceded by its line number in the following format:
"%6d  ", <line number>
If the l flag is specified or the list edit option is set:
1. The characters listed in the Base Definitions volume of POSIX.1‐2017, Table 5-1, Escape Sequences and Associated Actions shall be written as the corresponding escape sequence.
2. Non-printable characters not in the Base Definitions volume of POSIX.1‐2017, Table 5-1, Escape Sequences and Associated Actions shall be written as one three-digit octal number (with a preceding <backslash>) for each byte in the character (most significant byte first).
3. The end of each line shall be marked with a '$', and literal '$' characters within the line shall be written with a preceding <backslash>.
Long lines shall be folded; the length at which folding occurs is unspecified, but should be appropriate for the output terminal, considering the number of columns of the terminal.
If a line is folded, and the l flag is not specified and the list edit option is not set, it is unspecified whether a multi-column character at the folding position is separated; it shall not be discarded.
Current line: Set to the last written line.
Current column: Unchanged if the current line is unchanged; otherwise, set to non-<blank>.
Put Synopsis:
[1addr] pu[t][buffer]
Append text from the specified buffer (by default, the unnamed buffer) to the specified line; line zero specifies that the text shall be placed at the beginning of the edit buffer. Each portion of a line in the buffer shall become a new line in the edit buffer, regardless of the mode of the buffer.
Current line: Set to the last line entered into the edit buffer.
Quit Synopsis:
q[uit][!]
If no '!'  is appended to the command name:
1. If the edit buffer has been modified since the last complete write, it shall be an error.
2. If there are filenames in the argument list after the filename currently referenced, and the last command was not a quit, wq, xit, or ZZ (see Exit) command, it shall be an error.
Otherwise, terminate the editing session.
Read Synopsis:
[1addr] r[ead][!][file]
If '!'  is not the first non-<blank> to follow the command name, a copy of the specified file shall be appended into the edit buffer after the specified line; line zero specifies that the copy shall be placed at the beginning of the edit buffer. The number of lines and bytes read shall be written. If no file is named, the current pathname shall be the default. If there is no current pathname, then file shall become the current pathname. If there is no current pathname or file operand, it shall be an error. Specifying a file that is not of type regular shall have unspecified results.
Otherwise, if file is preceded by '!', the rest of the line after the '!' shall have '%', '#', and '!'  characters expanded as described in Command Line Parsing in ex.
The ex utility shall then pass two arguments to the program named by the shell edit option; the first shall be -c and the second shall be the expanded arguments to the read command as a single argument. The standard input of the program shall be set to the standard input of the ex program when it was invoked. The standard error and standard output of the program shall be appended into the edit buffer after the specified line.
Each line in the copied file or program output (as delimited by <newline> characters or the end of the file or output if it is not immediately preceded by a <newline>), shall be a separate line in the edit buffer. Any occurrences of <carriage-return> and <newline> pairs in the output shall be treated as single <newline> characters.
The special meaning of the '!'  following the read command can be overridden by escaping it with a <backslash> character.
Current line: If no lines are added to the edit buffer, unchanged. Otherwise, if in open or visual mode, set to the first line entered into the edit buffer. Otherwise, set to the last line entered into the edit buffer.
Recover Synopsis:
rec[over][!] file
If no file operand is specified, then the current pathname shall be used. If there is no current pathname or file operand, it shall be an error.
If no recovery information has previously been saved about file, the recover command shall behave identically to the edit command, and an informational message to this effect shall be written.
Otherwise, set the current pathname to file, and replace the current contents of the edit buffer with the recovered contents of file.  If there are multiple instances of the file to be recovered, the one most recently saved shall be recovered, and an informational message that there are previous versions of the file that can be recovered shall be written. The editor shall behave as if the contents of the edit buffer have already been modified.
Current file: Set as described for the edit command.
Rewind Synopsis:
rew[ind][!]
If the argument list is empty, it shall be an error.
The current argument list reference and the current pathname shall be set to the first filename in the argument list.
Set Synopsis:
se[t][option[=[value]] ...][nooption ...][option? ...][all]
When no arguments are specified, write the value of the term edit option and those options whose values have been changed from the default settings; when the argument all is specified, write all of the option values.
Giving an option name followed by the character '?'  shall cause the current value of that option to be written. The '?'  can be separated from the option name by zero or more <blank> characters. The '?'  shall be necessary only for Boolean valued options. Boolean options can be given values by the form set option to turn them on or set nooption to turn them off; string and numeric options can be assigned by the form set option=value.  Any <blank> characters in strings can be included as is by preceding each <blank> with an escaping <backslash>.  More than one option can be set or listed by a single set command by specifying multiple arguments, each separated from the next by one or more <blank> characters.
See Edit Options in ex for details about specific options.
Shell Synopsis:
sh[ell]
Invoke the program named in the shell edit option with the single argument -i (interactive mode). Editing shall be resumed when the program exits.
Source Synopsis:
so[urce] file
Read and execute ex commands from file.  Lines in the file that are blank lines shall be ignored.
Current line: As specified for the individual ex commands.
Current column: As specified for the individual ex commands.
Substitute Synopsis:
[2addr] s[ubstitute][/pattern/repl/[options][count][flags]] [2addr] &[options][count][flags]] [2addr] ~[options][count][flags]]
Replace the first instance of the pattern pattern by the string repl on each specified line. (See Regular Expressions in ex and Replacement Strings in ex.)  Any non-alphabetic, non-<blank> delimiter other than <backslash>, '|', <newline>, or double-quote can be used instead of '/'. <backslash> characters can be used to escape delimiters, <backslash> characters, and other special characters.
The trailing delimiter can be omitted from pattern or from repl at the end of the command line. If both pattern and repl are not specified or are empty (for example, "//"), the last s command shall be repeated. If only pattern is not specified or is empty, the last regular expression used in the editor shall be used as the pattern. If only repl is not specified or is empty, the pattern shall be replaced by nothing.  If the entire replacement pattern is '%', the last replacement pattern to an s command shall be used.
Entering a <carriage-return> in repl (which requires an escaping <backslash> in ex mode and an escaping <control>‐V in open or vi mode) shall split the line at that point, creating a new line in the edit buffer. The <carriage-return> shall be discarded.
If options includes the letter 'g' (global), all non-overlapping instances of the pattern in the line shall be replaced.
If options includes the letter 'c' (confirm), then before each substitution the line shall be written; the written line shall reflect all previous substitutions. On the following line, <space> characters shall be written beneath the characters from the line that are before the pattern to be replaced, and '^' characters written beneath the characters included in the pattern to be replaced. The ex utility shall then wait for a response from the user. An affirmative response shall cause the substitution to be done, while any other input shall not make the substitution. An affirmative response shall consist of a line with the affirmative response (as defined by the current locale) at the beginning of the line. This line shall be subject to editing in the same way as the ex command line.
If interrupted (see the ASYNCHRONOUS EVENTS section), any modifications confirmed by the user shall be preserved in the edit buffer after the interrupt.
If the remembered search direction is not set, the s command shall set it to forward.
In the second Synopsis, the & command shall repeat the previous substitution, as if the & command were replaced by:
s/pattern/repl/
where pattern and repl are as specified in the previous s, &, or ~ command.
In the third Synopsis, the ~ command shall repeat the previous substitution, as if the '~' were replaced by:
where pattern shall be the last regular expression specified to the editor, and repl shall be from the previous substitution (including & and ~) command.
These commands shall be affected by the LC_MESSAGES environment variable.
Current line: Set to the last line in which a substitution occurred, or, unchanged if no substitution occurred.
Suspend Synopsis:
su[spend][!] st[op][!]
Allow control to return to the invoking process; ex shall suspend itself as if it had received the SIGTSTP signal. The suspension shall occur only if job control is enabled in the invoking shell (see the description of set -m).
These commands shall be affected by the autowrite and writeany edit options.
The current susp character (see stty) shall be equivalent to the suspend command.
Tag Synopsis:
ta[g][!] tagstring
The results are unspecified if the format of a tags file is not as specified by the ctags utility (see ctags) description.
The tag command shall search for tagstring in the tag files referred to by the tag edit option, in the order they are specified, until a reference to tagstring is found. Files shall be searched from beginning to end. If no reference is found, it shall be an error and an error message to this effect shall be written. If the reference is not found, or if an error occurs while processing a file referred to in the tag edit option, it shall be an error, and an error message shall be written at the first occurrence of such an error.
Otherwise, if the tags file contained a pattern, the pattern shall be treated as a regular expression used in the editor; for example, for the purposes of the s command.
If the tagstring is in a file with a different name than the current pathname, set the current pathname to the name of that file, and replace the contents of the edit buffer with the contents of that file. In this case, if no '!'  is appended to the command name, and the edit buffer has been modified since the last complete write, it shall be an error, unless the file is successfully written as specified by the autowrite option.
This command shall be affected by the autowrite, tag, taglength, and writeany edit options.
Current line: If the tags file contained a line number, set to that line number. If the line number is larger than the last line in the edit buffer, an error message shall be written and the current line shall be set as specified for the edit command.
If the tags file contained a pattern, set to the first occurrence of the pattern in the file. If no matching pattern is found, an error message shall be written and the current line shall be set as specified for the edit command.
Current column: If the tags file contained a line-number reference and that line-number was not larger than the last line in the edit buffer, or if the tags file contained a pattern and that pattern was found, set to non-<blank>.  Otherwise, set as specified for the edit command.
Unabbreviate Synopsis:
una[bbrev] lhs
If lhs is not an entry in the current list of abbreviations (see Abbreviate), it shall be an error. Otherwise, delete lhs from the list of abbreviations.
Undo Synopsis:
u[ndo]
Reverse the changes made by the last command that modified the contents of the edit buffer, including undo.  For this purpose, the global, v, open, and visual commands, and commands resulting from buffer executions and mapped character expansions, are considered single commands.
If no action that can be undone preceded the undo command, it shall be an error.
If the undo command restores lines that were marked, the mark shall also be restored unless it was reset subsequent to the deletion of the lines.
Current line:
1. If lines are added or changed in the file, set to the first line added or changed.
2. Set to the line before the first line deleted, if it exists.
3. Set to 1 if the edit buffer is not empty.
4. Set to zero.
Unmap Synopsis:
unm[ap][!] lhs
If '!'  is appended to the command name, and if lhs is not an entry in the list of text input mode map definitions, it shall be an error. Otherwise, delete lhs from the list of text input mode map definitions.
If no '!'  is appended to the command name, and if lhs is not an entry in the list of command mode map definitions, it shall be an error. Otherwise, delete lhs from the list of command mode map definitions.
Version Synopsis:
ve[rsion]
Write a message containing version information for the editor. The format of the message is unspecified.
Visual Synopsis:
[1addr] vi[sual][type][count][flags]
If ex is currently in open or visual mode, the Synopsis and behavior of the visual command shall be the same as the edit command, as specified by Edit.
Otherwise, this command need not be supported on block-mode terminals or terminals with insufficient capabilities. If standard input, standard output, or standard error are not terminal devices, the results are unspecified.
If count is specified, the value of the window edit option shall be set to count (as described in window).  If the '^' type character was also specified, the window edit option shall be set before being used by the type character.
Enter visual mode. If type is not specified, it shall be as if a type of '+' was specified. The type shall cause the following effects:
+     Place the beginning of the specified line at the top of the display.
-     Place the end of the specified line at the bottom of the display.
.     Place the beginning of the specified line in the middle of the display.
^     If the specified line is less than or equal to the value of the window edit option, set the line to 1; otherwise, decrement the line by the value of the window edit option minus 1. Place the beginning of this line as close to the bottom of the displayed lines as possible, while still displaying the value of the window edit option number of lines.
Write Synopsis:
[2addr] w[rite][!][>>][file] [2addr] w[rite][!][file] [2addr] wq[!][>>][file]
The command wq shall be equivalent to a write command followed by a quit command; wq!  shall be equivalent to write!  followed by quit.  In both cases, if the write command fails, the quit shall not be attempted.
If the command name is not followed by one or more <blank> characters, or file is not preceded by a '!'  character, the write shall be to a file.
1. If the >> argument is specified, and the file already exists, the lines shall be appended to the file instead of replacing its contents. If the >> argument is specified, and the file does not already exist, it is unspecified whether the write shall proceed as if the >> argument had not been specified or if the write shall fail.
2. If the readonly edit option is set (see readonly), the write shall fail.
3. If file is specified, and is not the current pathname, and the file exists, the write shall fail.
4. If file is not specified, the current pathname shall be used. If there is no current pathname, the write command shall fail.
5. If the current pathname is used, and the current pathname has been changed by the file or read commands, and the file exists, the write shall fail. If the write is successful, subsequent writes shall not fail for this reason (unless the current pathname is changed again).
6. If the whole edit buffer is not being written, and the file to be written exists, the write shall fail.
For rules 1., 2., 3., and 5., the write can be forced by appending the character '!'  to the command name.
For rules 2., 3., and 5., the write can be forced by setting the writeany edit option.
Additional, implementation-defined tests may cause the write to fail.
If the edit buffer is empty, a file without any contents shall be written.
An informational message shall be written noting the number of lines and bytes written.
Otherwise, if the command is followed by one or more <blank> characters, and the file is preceded by '!', the rest of the line after the '!' shall have '%', '#', and '!'  characters expanded as described in Command Line Parsing in ex.
The ex utility shall then pass two arguments to the program named by the shell edit option; the first shall be -c and the second shall be the expanded arguments to the write command as a single argument. The specified lines shall be written to the standard input of the command. The standard error and standard output of the program, if any, shall be written as described for the print command. If the last character in that output is not a <newline>, a <newline> shall be written at the end of the output.
The special meaning of the '!'  following the write command can be overridden by escaping it with a <backslash> character.
Write and Exit Synopsis:
[2addr] x[it][!][file]
If the edit buffer has not been modified since the last complete write, xit shall be equivalent to the quit command, or if a '!'  is appended to the command name, to quit!.
Otherwise, xit shall be equivalent to the wq command, or if a '!'  is appended to the command name, to wq!.
Yank Synopsis:
[2addr] ya[nk][buffer][count]
Copy the specified lines to the specified buffer (by default, the unnamed buffer), which shall become a line-mode buffer.
Adjust Window Synopsis:
[1addr] z[!][type ...][count][flags]
If no line is specified, the current line shall be the default; if type is omitted as well, the current line value shall first be incremented by 1. If incrementing the current line would cause it to be greater than the last line in the edit buffer, it shall be an error.
If there are <blank> characters between the type argument and the preceding z command name or optional '!'  character, it shall be an error.
If count is specified, the value of the window edit option shall be set to count (as described in window).  If count is omitted, it shall default to 2 times the value of the scroll edit option, or if !  was specified, the number of lines in the display minus 1.
If type is omitted, then count lines starting with the specified line shall be written. Otherwise, count lines starting with the line specified by the type argument shall be written.
The type argument shall change the lines to be written. The possible values of type are as follows:
-     The specified line shall be decremented by the following value:
(((number of '-' characters) x count) -1)
If the calculation would result in a number less than 1, it shall be an error. Write lines from the edit buffer, starting at the new value of line, until count lines or the last line in the edit buffer has been written.
+     The specified line shall be incremented by the following value:
(((number of '+' characters) -1) x count) +1
If the calculation would result in a number greater than the last line in the edit buffer, it shall be an error. Write lines from the edit buffer, starting at the new value of line, until count lines or the last line in the edit buffer has been written.
=,.   If more than a single '.'  or '=' is specified, it shall be an error. The following steps shall be taken:
1. If count is zero, nothing shall be written.
2. Write as many of the N lines before the current line in the edit buffer as exist. If count or '!'  was specified, N shall be:
(count -1) /2
Otherwise, N shall be:
(count -3) /2
If N is a number less than 3, no lines shall be written.
3. If '=' was specified as the type character, write a line consisting of the smaller of the number of columns in the display divided by two, or 40 '-' characters.
4. Write the current line.
5. Repeat step 3.
6. Write as many of the N lines after the current line in the edit buffer as exist.  N shall be defined as in step 2. If N is a number less than 3, no lines shall be written. If count is less than 3, no lines shall be written.
^     The specified line shall be decremented by the following value:
(((number of '^' characters) +1) x count) -1
Current line: Set to the last line written, unless the type is =, in which case, set to the specified line.
Escape Synopsis:
! command [addr]! command
The contents of the line after the '!'  shall have '%', '#', and '!' characters expanded as described in Command Line Parsing in ex.  If the expansion causes the text of the line to change, it shall be redisplayed, preceded by a single '!'  character.
The ex utility shall execute the program named by the shell edit option. It shall pass two arguments to the program; the first shall be -c, and the second shall be the expanded arguments to the !  command as a single argument.
If no lines are specified, the standard input, standard output, and standard error of the program shall be set to the standard input, standard output, and standard error of the ex program when it was invoked. In addition, a warning message shall be written if the edit buffer has been modified since the last complete write, and the warn edit option is set.
If lines are specified, they shall be passed to the program as standard input, and the standard output and standard error of the program shall replace those lines in the edit buffer. Each line in the program output (as delimited by <newline> characters or the end of the output if it is not immediately preceded by a <newline>), shall be a separate line in the edit buffer. Any occurrences of <carriage-return> and <newline> pairs in the output shall be treated as single <newline> characters. The specified lines shall be copied into the unnamed buffer before they are replaced, and the unnamed buffer shall become a line-mode buffer.
If in ex mode, a single '!'  character shall be written when the program completes.
This command shall be affected by the shell and warn edit options. If no lines are specified, this command shall be affected by the autowrite and writeany edit options. If lines are specified, this command shall be affected by the autoprint edit option.
1. If no lines are specified, unchanged.
2. Otherwise, set to the last line read in, if any lines are read in.
3. Otherwise, set to the line before the first line of the lines specified, if that line exists.
4. Otherwise, set to the first line of the edit buffer if the edit buffer is not empty.
5. Otherwise, set to zero.
Current column: If no lines are specified, unchanged. Otherwise, set to non-<blank>.
Shift Left Synopsis:
[2addr] <[< ...][count][flags]
Shift the specified lines to the start of the line; the number of column positions to be shifted shall be the number of command characters times the value of the shiftwidth edit option. Only leading <blank> characters shall be deleted or changed into other <blank> characters in shifting; other characters shall not be affected.
Lines to be shifted shall be copied into the unnamed buffer, which shall become a line-mode buffer.
This command shall be affected by the autoprint edit option.
Current line: Set to the last line in the lines specified.
Shift Right Synopsis:
[2addr] >[> ...][count][flags]
Shift the specified lines away from the start of the line; the number of column positions to be shifted shall be the number of command characters times the value of the shiftwidth edit option. The shift shall be accomplished by adding <blank> characters as a prefix to the line or changing leading <blank> characters into other <blank> characters. Empty lines shall not be changed.
<control>‐D Synopsis:
<control>-D
Write the next n lines, where n is the minimum of the values of the scroll edit option and the number of lines after the current line in the edit buffer. If the current line is the last line of the edit buffer it shall be an error.
Current line: Set to the last line written.
Write Line Number Synopsis:
[1addr] = [flags]
If line is not specified, it shall default to the last line in the edit buffer.  Write the line number of the specified line.
Execute Synopsis:
[2addr] @ buffer [2addr] * buffer
If no buffer is specified or is specified as '@' or '*', the last buffer executed shall be used. If no previous buffer has been executed, it shall be an error.
For each line specified by the addresses, set the current line ('.')  to the specified line, and execute the contents of the named buffer (as they were at the time the @ command was executed) as ex commands. For each line of a line-mode buffer, and all but the last line of a character-mode buffer, the ex command parser shall behave as if the line was terminated by a <newline>.
If an error occurs during this process, or a line specified by the addresses does not exist when the current line would be set to it, or more than a single line was specified by the addresses, and the contents of the edit buffer are replaced (for example, by the ex :edit command) an error message shall be written, and no more commands resulting from the execution of this command shall be processed.
Regular Expressions in ex The ex utility shall support regular expressions that are a superset of the basic regular expressions described in the Base Definitions volume of POSIX.1‐2017, Section 9.3, Basic Regular Expressions.  A null regular expression ("//") shall be equivalent to the last regular expression encountered.
Regular expressions can be used in addresses to specify lines and, in some commands (for example, the substitute command), to specify portions of a line to be substituted.
The following constructs can be used to enhance the basic regular expressions:
\<    Match the beginning of a word.  (See the definition of word at the beginning of Command Descriptions in ex.)
\>    Match the end of a word.
~     Match the replacement part of the last substitute command. The <tilde> ('~') character can be escaped in a regular expression to become a normal character with no special meaning. The <backslash> shall be discarded.
When the editor option magic is not set, the only characters with special meanings shall be '^' at the beginning of a pattern, '$' at the end of a pattern, and <backslash>.  The characters '.', '*', '[', and '~' shall be treated as ordinary characters unless preceded by a <backslash>; when preceded by a <backslash> they shall regain their special meaning, or in the case of <backslash>, be handled as a single <backslash>.  <backslash> characters used to escape other characters shall be discarded.
Replacement Strings in ex The character '&' ('\&' if the editor option magic is not set) in the replacement string shall stand for the text matched by the pattern to be replaced. The character '~' ('\~' if magic is not set) shall be replaced by the replacement part of the previous substitute command. The sequence '\n', where n is an integer, shall be replaced by the text matched by the corresponding back-reference expression. If the corresponding back- reference expression does not match, then the characters '\n' shall be replaced by the empty string.
The strings '\l', '\u', '\L', and '\U' can be used to modify the case of elements in the replacement string (using the '\&' or "\"digit) notation. The string '\l' ('\u') shall cause the character that follows to be converted to lowercase (uppercase). The string '\L' ('\U') shall cause all characters subsequent to it to be converted to lowercase (uppercase) as they are inserted by the substitution until the string '\e' or '\E', or the end of the replacement string, is encountered.
Otherwise, any character following a <backslash> shall be treated as that literal character, and the escaping <backslash> shall be discarded.
An example of case conversion with the s command is as follows:
:p The cat sat on the mat. :s/\<.at\>/\u&/gp The Cat Sat on the Mat. :s/S\(.*\)M/S\U\1\eM/p The Cat SAT ON THE Mat.
Edit Options in ex The ex utility has a number of options that modify its behavior. These options have default settings, which can be changed using the set command.
Options are Boolean unless otherwise specified.
autoindent, ai [Default unset]
If autoindent is set, each line in input mode shall be indented (using first as many <tab> characters as possible, as determined by the editor option tabstop, and then using <space> characters) to align with another line, as follows:
1. If in open or visual mode and the text input is part of a line- oriented command (see the EXTENDED DESCRIPTION in vi), align to the first column.
2. Otherwise, if in open or visual mode, indentation for each line shall be set as follows:
a. If a line was previously inserted as part of this command, it shall be set to the indentation of the last inserted line by default, or as otherwise specified for the <control>‐D character in Input Mode Commands in vi.
b. Otherwise, it shall be set to the indentation of the previous current line, if any; otherwise, to the first column.
3. For the ex a, i, and c commands, indentation for each line shall be set as follows:
a. If a line was previously inserted as part of this command, it shall be set to the indentation of the last inserted line by default, or as otherwise specified for the eof character in Scroll.
b. Otherwise, if the command is the ex a command, it shall be set to the line appended after, if any; otherwise to the first column.
c. Otherwise, if the command is the ex i command, it shall be set to the line inserted before, if any; otherwise to the first column.
d. Otherwise, if the command is the ex c command, it shall be set to the indentation of the line replaced.
autoprint, ap [Default set]
If autoprint is set, the current line shall be written after each ex command that modifies the contents of the current edit buffer, and after each tag command for which the tag search pattern was found or tag line number was valid, unless:
1. The command was executed while in open or visual mode.
2. The command was executed as part of a global or v command or @ buffer execution.
3. The command was the form of the read command that reads a file into the edit buffer.
4. The command was the append, change, or insert command.
5. The command was not terminated by a <newline>.
6. The current line shall be written by a flag specified to the command; for example, delete # shall write the current line as specified for the flag modifier to the delete command, and not as specified by the autoprint edit option.
autowrite, aw [Default unset]
If autowrite is set, and the edit buffer has been modified since it was last completely written to any file, the contents of the edit buffer shall be written as if the ex write command had been specified without arguments, before each command affected by the autowrite edit option is executed. Appending the character '!'  to the command name of any of the ex commands except '!'  shall prevent the write. If the write fails, it shall be an error and the command shall not be executed.
beautify, bf [Default unset]
If beautify is set, all non-printable characters, other than <tab>, <newline>, and <form-feed> characters, shall be discarded from text read in from files.
directory, dir [Default implementation-defined]
The value of this option specifies the directory in which the editor buffer is to be placed. If this directory is not writable by the user, the editor shall quit.
edcompatible, ed [Default unset]
Causes the presence of g and c suffixes on substitute commands to be remembered, and toggled by repeating the suffixes.
errorbells, eb [Default unset]
If the editor is in ex mode, and the terminal does not support a standout mode (such as inverse video), and errorbells is set, error messages shall be preceded by alerting the terminal.
exrc [Default unset]
If exrc is set, ex shall access any .exrc file in the current directory, as described in Initialization in ex and vi.  If exrc is not set, ex shall ignore any .exrc file in the current directory during initialization, unless the current directory is that named by the HOME environment variable.
ignorecase, ic [Default unset]
If ignorecase is set, characters that have uppercase and lowercase representations shall have those representations considered as equivalent for purposes of regular expression comparison.
The ignorecase edit option shall affect all remembered regular expressions; for example, unsetting the ignorecase edit option shall cause a subsequent vi n command to search for the last basic regular expression in a case-sensitive fashion.
list [Default unset]
If list is set, edit buffer lines written while in ex command mode shall be written as specified for the print command with the l flag specified. In open or visual mode, each edit buffer line shall be displayed as specified for the ex print command with the l flag specified. In open or visual text input mode, when the cursor does not rest on any character in the line, it shall rest on the '$' marking the end of the line.
magic [Default set]
If magic is set, modify the interpretation of characters in regular expressions and substitution replacement strings (see Regular Expressions in ex and Replacement Strings in ex).
mesg [Default set]
If mesg is set, the permission for others to use the write or talk commands to write to the terminal shall be turned on while in open or visual mode. The shell-level command mesg n shall take precedence over any setting of the ex mesg option; that is, if mesg y was issued before the editor started (or in a shell escape), such as:
:!mesg y
the mesg option in ex shall suppress incoming messages, but the mesg option shall not enable incoming messages if mesg n was issued.
number, nu [Default unset]
If number is set, edit buffer lines written while in ex command mode shall be written with line numbers, in the format specified by the print command with the # flag specified. In ex text input mode, each line shall be preceded by the line number it will have in the file.
In open or visual mode, each edit buffer line shall be displayed with a preceding line number, in the format specified by the ex print command with the # flag specified. This line number shall not be considered part of the line for the purposes of evaluating the current column; that is, column position 1 shall be the first column position after the format specified by the print command.
paragraphs, para [Default in the POSIX locale IPLPPPQPP LIpplpipbp]
The paragraphs edit option shall define additional paragraph boundaries for the open and visual mode commands. The paragraphs edit option can be set to a character string consisting of zero or more character pairs. It shall be an error to set it to an odd number of characters.
prompt [Default set]
If prompt is set, ex command mode input shall be prompted for with a <colon> (':'); when unset, no prompt shall be written.
readonly [Default see text]
If the readonly edit option is set, read-only mode shall be enabled (see Write).  The readonly edit option shall be initialized to set if either of the following conditions are true:
*  The command-line option -R was specified.
*  Performing actions equivalent to the access() function called with the following arguments indicates that the file lacks write permission:
1. The current pathname is used as the path argument.
2. The constant W_OK is used as the amode argument.
The readonly edit option may be initialized to set for other, implementation-defined reasons. The readonly edit option shall not be initialized to unset based on any special privileges of the user or process. The readonly edit option shall be reinitialized each time that the contents of the edit buffer are replaced (for example, by an edit or next command) unless the user has explicitly set it, in which case it shall remain set until the user explicitly unsets it. Once unset, it shall again be reinitialized each time that the contents of the edit buffer are replaced.
redraw [Default unset]
The editor simulates an intelligent terminal on a dumb terminal.  (Since this is likely to require a large amount of output to the terminal, it is useful only at high transmission speeds.)
remap [Default set]
If remap is set, map translation shall allow for maps defined in terms of other maps; translation shall continue until a final product is obtained. If unset, only a one-step translation shall be done.
report [Default 5]
The value of this report edit option specifies what number of lines being added, copied, deleted, or modified in the edit buffer will cause an informational message to be written to the user. The following conditions shall cause an informational message. The message shall contain the number of lines added, copied, deleted, or modified, but is otherwise unspecified.
*  An ex or vi editor command, other than open, undo, or visual, that modifies at least the value of the report edit option number of lines, and which is not part of an ex global or v command, or ex or vi buffer execution, shall cause an informational message to be written.
*  An ex yank or vi y or Y command, that copies at least the value of the report edit option plus 1 number of lines, and which is not part of an ex global or v command, or ex or vi buffer execution, shall cause an informational message to be written.
*  An ex global, v, open, undo, or visual command or ex or vi buffer execution, that adds or deletes a total of at least the value of the report edit option number of lines, and which is not part of an ex global or v command, or ex or vi buffer execution, shall cause an informational message to be written.  (For example, if 3 lines were added and 8 lines deleted during an ex visual command, 5 would be the number compared against the report edit option after the command completed.)
scroll, scr [Default (number of lines in the display -1)/2]
The value of the scroll edit option shall determine the number of lines scrolled by the ex <control>‐D and z commands. For the vi <control>‐D and <control>‐U commands, it shall be the initial number of lines to scroll when no previous <control>‐D or <control>‐U command has been executed.
sections [Default in the POSIX locale NHSHH HUnhsh]
The sections edit option shall define additional section boundaries for the open and visual mode commands. The sections edit option can be set to a character string consisting of zero or more character pairs; it shall be an error to set it to an odd number of characters.
shell, sh [Default from the environment variable SHELL]
The value of this option shall be a string. The default shall be taken from the SHELL environment variable. If the SHELL environment variable is null or empty, the sh (see sh) utility shall be the default.
shiftwidth, sw [Default 8]
The value of this option shall give the width in columns of an indentation level used during autoindentation and by the shift commands (< and >).
showmatch, sm [Default unset]
The functionality described for the showmatch edit option need not be supported on block-mode terminals or terminals with insufficient capabilities.
If showmatch is set, in open or visual mode, when a ')' or '}' is typed, if the matching '(' or '{' is currently visible on the display, the matching '(' or '{' shall be flagged moving the cursor to its location for an unspecified amount of time.
showmode [Default unset]
If showmode is set, in open or visual mode, the current mode that the editor is in shall be displayed on the last line of the display. Command mode and text input mode shall be differentiated; other unspecified modes and implementation-defined information may be displayed.
slowopen [Default unset]
If slowopen is set during open and visual text input modes, the editor shall not update portions of the display other than those display line columns that display the characters entered by the user (see Input Mode Commands in vi).
tabstop, ts [Default 8]
The value of this edit option shall specify the column boundary used by a <tab> in the display (see autoprint, ap and Input Mode Commands in vi).
taglength, tl [Default zero]
The value of this edit option shall specify the maximum number of characters that are considered significant in the user-specified tag name and in the tag name from the tags file. If the value is zero, all characters in both tag names shall be significant.
tags [Default see text]
The value of this edit option shall be a string of <blank>-delimited pathnames of files used by the tag command. The default value is unspecified.
term [Default from the environment variable TERM]
The value of this edit option shall be a string. The default shall be taken from the TERM variable in the environment. If the TERM environment variable is empty or null, the default is unspecified. The editor shall use the value of this edit option to determine the type of the display device.
The results are unspecified if the user changes the value of the term edit option after editor initialization.
terse [Default unset]
If terse is set, error messages may be less verbose. However, except for this caveat, error messages are unspecified. Furthermore, not all error messages need change for different settings of this option.
warn [Default set]
If warn is set, and the contents of the edit buffer have been modified since they were last completely written, the editor shall write a warning message before certain !  commands (see Escape).
window [Default see text]
A value used in open and visual mode, by the <control>‐B and <control>‐F commands, and, in visual mode, to specify the number of lines displayed when the screen is repainted.
If the -w command-line option is not specified, the default value shall be set to the value of the LINES environment variable. If the LINES environment variable is empty or null, the default shall be the number of lines in the display minus 1.
Setting the window edit option to zero or to a value greater than the number of lines in the display minus 1 (either explicitly or based on the -w option or the LINES environment variable) shall cause the window edit option to be set to the number of lines in the display minus 1.
The baud rate of the terminal line may change the default in an implementation-defined manner.
wrapmargin, wm [Default 0]
If the value of this edit option is zero, it shall have no effect.
If not in the POSIX locale, the effect of this edit option is implementation-defined.
Otherwise, it shall specify a number of columns from the ending margin of the terminal.
During open and visual text input modes, for each character for which any part of the character is displayed in a column that is less than wrapmargin columns from the ending margin of the display line, the editor shall behave as follows:
1. If the character triggering this event is a <blank>, it, and all immediately preceding <blank> characters on the current line entered during the execution of the current text input command, shall be discarded, and the editor shall behave as if the user had entered a single <newline> instead. In addition, if the next user-entered character is a <space>, it shall be discarded as well.
2. Otherwise, if there are one or more <blank> characters on the current line immediately preceding the last group of inserted non-<blank> characters which was entered during the execution of the current text input command, the <blank> characters shall be replaced as if the user had entered a single <newline> instead.
If the autoindent edit option is set, and the events described in 1. or 2. are performed, any <blank> characters at or after the cursor in the current line shall be discarded.
The ending margin shall be determined by the system or overridden by the user, as described for COLUMNS in the ENVIRONMENT VARIABLES section and the Base Definitions volume of POSIX.1‐2017, Chapter 8, Environment Variables.
wrapscan, ws [Default set]
If wrapscan is set, searches (the ex / or ?  addresses, or open and visual mode /, ?, N, and n commands) shall wrap around the beginning or end of the edit buffer; when unset, searches shall stop at the beginning or end of the edit buffer.
writeany, wa [Default unset]
If writeany is set, some of the checks performed when executing the ex write commands shall be inhibited, as described in editor option autowrite.
The following exit values shall be returned:
0    Successful completion.
>0    An error occurred.
When any error is encountered and the standard input is not a terminal device file, ex shall not write the file or return to command or text input mode, and shall terminate with a non-zero exit status.
Otherwise, when an unrecoverable error is encountered, it shall be equivalent to a SIGHUP asynchronous event.
Otherwise, when an error is encountered, the editor shall behave as specified in Command Line Parsing in ex.
If a SIGSEGV signal is received while ex is saving a file, the file might not be successfully saved.
The next command can accept more than one file, so usage such as:
next `ls [abc]*`