neulab/tldr huggingface dataset:
is valid; it would not be valid for the edit or read commands, for example, because they expect only one file and unspecified results occur.
The ex/vi specification is based on the historical practice found in the 4 BSD and System V implementations of ex and vi.
A restricted editor (both the historical red utility and modifications to ex) were considered and rejected for inclusion. Neither option provided the level of security that users might expect.
It is recognized that ex visual mode and related features would be difficult, if not impossible, to implement satisfactorily on a block-mode terminal, or a terminal without any form of cursor addressing; thus, it is not a mandatory requirement that such features should work on all terminals. It is the intention, however, that an ex implementation should provide the full set of capabilities on all terminals capable of supporting them.
Options The -c replacement for +command was inspired by the -e option of sed. Historically, all such commands (see edit and next as well) were executed from the last line of the edit buffer. This meant, for example, that "+/pattern" would fail unless the wrapscan option was set. POSIX.1‐2008 requires conformance to historical practice. The +command option is no longer specified by POSIX.1‐2008 but may be present in some implementations. Historically, some implementations restricted the ex commands that could be listed as part of the command line arguments.  For consistency, POSIX.1‐2008 does not permit these restrictions.
In historical implementations of the editor, the -R option (and the readonly edit option) only prevented overwriting of files; appending to files was still permitted, mapping loosely into the csh noclobber variable. Some implementations, however, have not followed this semantic, and readonly does not permit appending either. POSIX.1‐2008 follows the latter practice, believing that it is a more obvious and intuitive meaning of readonly.
The -s option suppresses all interactive user feedback and is useful for editing scripts in batch jobs. The list of specific effects is historical practice. The terminal type ``incapable of supporting open and visual modes'' has historically been named ``dumb''.
The -t option was required because the ctags utility appears in POSIX.1‐2008 and the option is available in all historical implementations of ex.
Historically, the ex and vi utilities accepted a -x option, which did encryption based on the algorithm found in the historical crypt utility. The -x option for encryption, and the associated crypt utility, were omitted because the algorithm used was not specifiable and the export control laws of some nations make it difficult to export cryptographic technology. In addition, it did not historically provide the level of security that users might expect.
Standard Input An end-of-file condition is not equivalent to an end-of-file character. A common end-of-file character, <control>‐D, is historically an ex command.
There was no maximum line length in historical implementations of ex. Specifically, as it was parsed in chunks, the addresses had a different maximum length than the filenames. Further, the maximum line buffer size was declared as BUFSIZ, which was different lengths on different systems. This version selected the value of {LINE_MAX} to impose a reasonable restriction on portable usage of ex and to aid test suite writers in their development of realistic tests that exercise this limit.
Input Files It was an explicit decision by the standard developers that a <newline> be added to any file lacking one. It was believed that this feature of ex and vi was relied on by users in order to make text files lacking a trailing <newline> more portable. It is recognized that this will require a user-specified option or extension for implementations that permit ex and vi to edit files of type other than text if such files are not otherwise identified by the system. It was agreed that the ability to edit files of arbitrary type can be useful, but it was not considered necessary to mandate that an ex or vi implementation be required to handle files other than text files.
The paragraph in the INPUT FILES section, ``By default, ...'', is intended to close a long-standing security problem in ex and vi; that of the ``modeline'' or ``modelines'' edit option. This feature allows any line in the first or last five lines of the file containing the strings "ex:" or "vi:" (and, apparently, "ei:" or "vx:") to be a line containing editor commands, and ex interprets all the text up to the next ':' or <newline> as a command. Consider the consequences, for example, of an unsuspecting user using ex or vi as the editor when replying to a mail message in which a line such as:
ex:! rm -rf :
appeared in the signature lines. The standard developers believed strongly that an editor should not by default interpret any lines of a file. Vendors are strongly urged to delete this feature from their implementations of ex and vi.
Asynchronous Events The intention of the phrase ``complete write'' is that the entire edit buffer be written to stable storage. The note regarding temporary files is intended for implementations that use temporary files to back edit buffers unnamed by the user.
Historically, SIGQUIT was ignored by ex, but was the equivalent of the Q command in visual mode; that is, it exited visual mode and entered ex mode. POSIX.1‐2008 permits, but does not require, this behavior. Historically, SIGINT was often used by vi users to terminate text input mode (<control>‐C is often easier to enter than <ESC>).  Some implementations of vi alerted the terminal on this event, and some did not. POSIX.1‐2008 requires that SIGINT behave identically to <ESC>, and that the terminal not be alerted.
Historically, suspending the ex editor during text input mode was similar to SIGINT, as completed lines were retained, but any partial line discarded, and the editor returned to command mode. POSIX.1‐2008 is silent on this issue; implementations are encouraged to follow historical practice, where possible.
Historically, the vi editor did not treat SIGTSTP as an asynchronous event, and it was therefore impossible to suspend the editor in visual text input mode.  There are two major reasons for this. The first is that SIGTSTP is a broadcast signal on UNIX systems, and the chain of events where the shell execs an application that then execs vi usually caused confusion for the terminal state if SIGTSTP was delivered to the process group in the default manner. The second was that most implementations of the UNIX curses package did not handle SIGTSTP safely, and the receipt of SIGTSTP at the wrong time would cause them to crash. POSIX.1‐2008 is silent on this issue; implementations are encouraged to treat suspension as an asynchronous event if possible.
Historically, modifications to the edit buffer made before SIGINT interrupted an operation were retained; that is, anywhere from zero to all of the lines to be modified might have been modified by the time the SIGINT arrived. These changes were not discarded by the arrival of SIGINT. POSIX.1‐2008 permits this behavior, noting that the undo command is required to be able to undo these partially completed commands.
The action taken for signals other than SIGINT, SIGCONT, SIGHUP, and SIGTERM is unspecified because some implementations attempt to save the edit buffer in a useful state when other signals are received.
Standard Error For ex/vi, diagnostic messages are those messages reported as a result of a failed attempt to invoke ex or vi, such as invalid options or insufficient resources, or an abnormal termination condition. Diagnostic messages should not be confused with the error messages generated by inappropriate or illegal user commands.
Initialization in ex and vi If an ex command (other than cd, chdir, or source) has a filename argument, one or both of the alternate and current pathnames will be set. Informally, they are set as follows:
1. If the ex command is one that replaces the contents of the edit buffer, and it succeeds, the current pathname will be set to the filename argument (the first filename argument in the case of the next command) and the alternate pathname will be set to the previous current pathname, if there was one.
2. In the case of the file read/write forms of the read and write commands, if there is no current pathname, the current pathname will be set to the filename argument.
3. Otherwise, the alternate pathname will be set to the filename argument.
For example, :edit foo and :recover foo, when successful, set the current pathname, and, if there was a previous current pathname, the alternate pathname. The commands :write, !command, and :edit set neither the current or alternate pathnames. If the :edit foo command were to fail for some reason, the alternate pathname would be set. The read and write commands set the alternate pathname to their file argument, unless the current pathname is not set, in which case they set the current pathname to their file arguments. The alternate pathname was not historically set by the :source command. POSIX.1‐2008 requires conformance to historical practice.  Implementations adding commands that take filenames as arguments are encouraged to set the alternate pathname as described here.
Historically, ex and vi read the .exrc file in the $HOME directory twice, if the editor was executed in the $HOME directory. POSIX.1‐2008 prohibits this behavior.
Historically, the 4 BSD ex and vi read the $HOME and local .exrc files if they were owned by the real ID of the user, or the sourceany option was set, regardless of other considerations. This was a security problem because it is possible to put normal UNIX system commands inside a .exrc file. POSIX.1‐2008 does not specify the sourceany option, and historical implementations are encouraged to delete it.
The .exrc files must be owned by the real ID of the user, and not writable by anyone other than the owner. The appropriate privileges exception is intended to permit users to acquire special privileges, but continue to use the .exrc files in their home directories.
System V Release 3.2 and later vi implementations added the option [no]exrc.  The behavior is that local .exrc files are read-only if the exrc option is set. The default for the exrc option was off, so by default, local .exrc files were not read. The problem this was intended to solve was that System V permitted users to give away files, so there is no possible ownership or writeability test to ensure that the file is safe. This is still a security problem on systems where users can give away files, but there is nothing additional that POSIX.1‐2008 can do. The implementation-defined exception is intended to permit groups to have local .exrc files that are shared by users, by creating pseudo-users to own the shared files.
POSIX.1‐2008 does not mention system-wide ex and vi start-up files. While they exist in several implementations of ex and vi, they are not present in any implementations considered historical practice by POSIX.1‐2008. Implementations that have such files should use them only if they are owned by the real user ID or an appropriate user (for example, root on UNIX systems) and if they are not writable by any user other than their owner. System-wide start-up files should be read before the EXINIT variable, $HOME/.exrc, or local .exrc files are evaluated.
Historically, any ex command could be entered in the EXINIT variable or the .exrc file, although ones requiring that the edit buffer already contain lines of text generally caused historical implementations of the editor to drop core.  POSIX.1‐2008 requires that any ex command be permitted in the EXINIT variable and .exrc files, for simplicity of specification and consistency, although many of them will obviously fail under many circumstances.
The initialization of the contents of the edit buffer uses the phrase ``the effect shall be'' with regard to various ex commands. The intent of this phrase is that edit buffer contents loaded during the initialization phase not be lost; that is, loading the edit buffer should fail if the .exrc file read in the contents of a file and did not subsequently write the edit buffer. An additional intent of this phrase is to specify that the initial current line and column is set as specified for the individual ex commands.
Historically, the -t option behaved as if the tag search were a +command; that is, it was executed from the last line of the file specified by the tag. This resulted in the search failing if the pattern was a forward search pattern and the wrapscan edit option was not set. POSIX.1‐2008 does not permit this behavior, requiring that the search for the tag pattern be performed on the entire file, and, if not found, that the current line be set to a more reasonable location in the file.
Historically, the empty edit buffer presented for editing when a file was not specified by the user was unnamed. This is permitted by POSIX.1‐2008; however, implementations are encouraged to provide users a temporary filename for this buffer because it permits them the use of ex commands that use the current pathname during temporary edit sessions.
Historically, the file specified using the -t option was not part of the current argument list. This practice is permitted by POSIX.1‐2008; however, implementations are encouraged to include its name in the current argument list for consistency.
Historically, the -c command was generally not executed until a file that already exists was edited. POSIX.1‐2008 requires conformance to this historical practice.  Commands that could cause the -c command to be executed include the ex commands edit, next, recover, rewind, and tag, and the vi commands <control>‐^ and <control>‐].  Historically, reading a file into an edit buffer did not cause the -c command to be executed (even though it might set the current pathname) with the exception that it did cause the -c command to be executed if: the editor was in ex mode, the edit buffer had no current pathname, the edit buffer was empty, and no read commands had yet been attempted. For consistency and simplicity of specification, POSIX.1‐2008 does not permit this behavior.
Historically, the -r option was the same as a normal edit session if there was no recovery information available for the file. This allowed users to enter:
vi -r *.c
and recover whatever files were recoverable. In some implementations, recovery was attempted only on the first file named, and the file was not entered into the argument list; in others, recovery was attempted for each file named. In addition, some historical implementations ignored -r if -t was specified or did not support command line file arguments with the -t option. For consistency and simplicity of specification, POSIX.1‐2008 disallows these special cases, and requires that recovery be attempted the first time each file is edited.
Historically, vi initialized the ` and ' marks, but ex did not. This meant that if the first command in ex mode was visual or if an ex command was executed first (for example, vi +10 file), vi was entered without the marks being initialized. Because the standard developers believed the marks to be generally useful, and for consistency and simplicity of specification, POSIX.1‐2008 requires that they always be initialized if in open or visual mode, or if in ex mode and the edit buffer is not empty. Not initializing it in ex mode if the edit buffer is empty is historical practice; however, it has always been possible to set (and use) marks in empty edit buffers in open and visual mode edit sessions.
Addressing Historically, ex and vi accepted the additional addressing forms '\/' and '\?'.  They were equivalent to "//" and "??", respectively. They are not required by POSIX.1‐2008, mostly because nobody can remember whether they ever did anything different historically.
Historically, ex and vi permitted an address of zero for several commands, and permitted the % address in empty files for others. For consistency, POSIX.1‐2008 requires support for the former in the few commands where it makes sense, and disallows it otherwise. In addition, because POSIX.1‐2008 requires that % be logically equivalent to "1,$", it is also supported where it makes sense and disallowed otherwise.
Historically, the % address could not be followed by further addresses. For consistency and simplicity of specification, POSIX.1‐2008 requires that additional addresses be supported.
All of the following are valid addresses:
+++       Three lines after the current line.
/re/-     One line before the next occurrence of re.
-2        Two lines before the current line.
3 ---- 2  Line one (note intermediate negative address).
1 2 3     Line six.
Any number of addresses can be provided to commands taking addresses; for example, "1,2,3,4,5p" prints lines 4 and 5, because two is the greatest valid number of addresses accepted by the print command. This, in combination with the <semicolon> delimiter, permits users to create commands based on ordered patterns in the file. For example, the command 3;/foo/;+2print will display the first line after line 3 that contains the pattern foo, plus the next two lines. Note that the address 3; must be evaluated before being discarded because the search origin for the /foo/ command depends on this.
Historically, values could be added to addresses by including them after one or more <blank> characters; for example, 3 - 5p wrote the seventh line of the file, and /foo/ 5 was the same as /foo/+5.  However, only absolute values could be added; for example, 5 /foo/ was an error. POSIX.1‐2008 requires conformance to historical practice.  Address offsets are separately specified from addresses because they could historically be provided to visual mode search commands.
Historically, any missing addresses defaulted to the current line. This was true for leading and trailing <comma>-delimited addresses, and for trailing <semicolon>-delimited addresses. For consistency, POSIX.1‐2008 requires it for leading <semicolon> addresses as well.
Historically, ex and vi accepted the '^' character as both an address and as a flag offset for commands. In both cases it was identical to the '-' character. POSIX.1‐2008 does not require or prohibit this behavior.
Historically, the enhancements to basic regular expressions could be used in addressing; for example, '~', '\<', and '\>'.  POSIX.1‐2008 requires conformance to historical practice; that is, that regular expression usage be consistent, and that regular expression enhancements be supported wherever regular expressions are used.
Command Line Parsing in ex Historical ex command parsing was even more complex than that described here. POSIX.1‐2008 requires the subset of the command parsing that the standard developers believed was documented and that users could reasonably be expected to use in a portable fashion, and that was historically consistent between implementations. (The discarded functionality is obscure, at best.)  Historical implementations will require changes in order to comply with POSIX.1‐2008; however, users are not expected to notice any of these changes.  Most of the complexity in ex parsing is to handle three special termination cases:
1. The !, global, v, and the filter versions of the read and write commands are delimited by <newline> characters (they can contain <vertical-line> characters that are usually shell pipes).
2. The ex, edit, next, and visual in open and visual mode commands all take ex commands, optionally containing <vertical-line> characters, as their first arguments.
3. The s command takes a regular expression as its first argument, and uses the delimiting characters to delimit the command.
Historically, <vertical-line> characters in the +command argument of the ex, edit, next, vi, and visual commands, and in the pattern and replacement parts of the s command, did not delimit the command, and in the filter cases for read and write, and the !, global, and v commands, they did not delimit the command at all. For example, the following commands are all valid:
:edit +25 | s/abc/ABC/ file.c :s/ | /PIPE/ :read !spell % | columnate :global/pattern/p | l :s/a/b/ | s/c/d | set
Historically, empty or <blank> filled lines in .exrc files and sourced files (as well as EXINIT variables and ex command scripts) were treated as default commands; that is, print commands. POSIX.1‐2008 specifically requires that they be ignored when encountered in .exrc and sourced files to eliminate a common source of new user error.
Historically, ex commands with multiple adjacent (or <blank>-separated) vertical lines were handled oddly when executed from ex mode. For example, the command ||| <carriage-return>, when the cursor was on line 1, displayed lines 2, 3, and 5 of the file.  In addition, the command | would only display the line after the next line, instead of the next two lines. The former worked more logically when executed from vi mode, and displayed lines 2, 3, and 4. POSIX.1‐2008 requires the vi behavior; that is, a single default command and line number increment for each command separator, and trailing <newline> characters after <vertical-line> separators are discarded.
Historically, ex permitted a single extra <colon> as a leading command character; for example, :g/pattern/:p was a valid command. POSIX.1‐2008 generalizes this to require that any number of leading <colon> characters be stripped.
Historically, any prefix of the delete command could be followed without intervening <blank> characters by a flag character because in the command d p, p is interpreted as the buffer p.  POSIX.1‐2008 requires conformance to historical practice.
Historically, the k command could be followed by the mark name without intervening <blank> characters. POSIX.1‐2008 requires conformance to historical practice.
Historically, the s command could be immediately followed by flag and option characters; for example, s/e/E/|s|sgc3p was a valid command. However, flag characters could not stand alone; for example, the commands sp and s l would fail, while the command sgp and s gl would succeed. (Obviously, the '#' flag character was used as a delimiter character if it followed the command.) Another issue was that option characters had to precede flag characters even when the command was fully specified; for example, the command s/e/E/pg would fail, while the command s/e/E/gp would succeed. POSIX.1‐2008 requires conformance to historical practice.
Historically, the first command name that had a prefix matching the input from the user was the executed command; for example, ve, ver, and vers all executed the version command. Commands were in a specific order, however, so that a matched append, not abbreviate.  POSIX.1‐2008 requires conformance to historical practice. The restriction on command search order for implementations with extensions is to avoid the addition of commands such that the historical prefixes would fail to work portably.
Historical implementations of ex and vi did not correctly handle multiple ex commands, separated by <vertical-line> characters, that entered or exited visual mode or the editor. Because implementations of vi exist that do not exhibit this failure mode, POSIX.1‐2008 does not permit it.
The requirement that alphabetic command names consist of all following alphabetic characters up to the next non-alphabetic character means that alphabetic command names must be separated from their arguments by one or more non-alphabetic characters, normally a <blank> or '!'  character, except as specified for the exceptions, the delete, k, and s commands.
Historically, the repeated execution of the ex default print commands (<control>‐D, eof, <newline>, <carriage-return>) erased any prompting character and displayed the next lines without scrolling the terminal; that is, immediately below any previously displayed lines. This provided a cleaner presentation of the lines in the file for the user. POSIX.1‐2008 does not require this behavior because it may be impossible in some situations; however, implementations are strongly encouraged to provide this semantic if possible.
Historically, it was possible to change files in the middle of a command, and have the rest of the command executed in the new file; for example:
:edit +25 file.c | s/abc/ABC/ | 1
was a valid command, and the substitution was attempted in the newly edited file. POSIX.1‐2008 requires conformance to historical practice. The following commands are examples that exercise the ex parser:
echo 'foo | bar' > file1; echo 'foo/bar' > file2; vi :edit +1 | s/|/PIPE/ | w file1 | e file2 | 1 | s/\//SLASH/ | wq
Historically, there was no protection in editor implementations to avoid ex global, v, @, or * commands changing edit buffers during execution of their associated commands. Because this would almost invariably result in catastrophic failure of the editor, and implementations exist that do exhibit these problems, POSIX.1‐2008 requires that changing the edit buffer during a global or v command, or during a @ or * command for which there will be more than a single execution, be an error. Implementations supporting multiple edit buffers simultaneously are strongly encouraged to apply the same semantics to switching between buffers as well.
The ex command quoting required by POSIX.1‐2008 is a superset of the quoting in historical implementations of the editor. For example, it was not historically possible to escape a <blank> in a filename; for example, :edit foo\\\ bar would report that too many filenames had been entered for the edit command, and there was no method of escaping a <blank> in the first argument of an edit, ex, next, or visual command at all. POSIX.1‐2008 extends historical practice, requiring that quoting behavior be made consistent across all ex commands, except for the map, unmap, abbreviate, and unabbreviate commands, which historically used <control>‐V instead of <backslash> characters for quoting. For those four commands, POSIX.1‐2008 requires conformance to historical practice.
Backslash quoting in ex is non-intuitive.  <backslash>-escapes are ignored unless they escape a special character; for example, when performing file argument expansion, the string "\\%" is equivalent to '\%', not "\<current pathname>".  This can be confusing for users because <backslash> is usually one of the characters that causes shell expansion to be performed, and therefore shell quoting rules must be taken into consideration. Generally, quoting characters are only considered if they escape a special character, and a quoting character must be provided for each layer of parsing for which the character is special. As another example, only a single <backslash> is necessary for the '\l' sequence in substitute replacement patterns, because the character 'l' is not special to any parsing layer above it.
<control>‐V quoting in ex is slightly different from backslash quoting. In the four commands where <control>‐V quoting applies (abbreviate, unabbreviate, map, and unmap), any character may be escaped by a <control>‐V whether it would have a special meaning or not. POSIX.1‐2008 requires conformance to historical practice.
Historical implementations of the editor did not require delimiters within character classes to be escaped; for example, the command :s/[/]// on the string "xxx/yyy" would delete the '/' from the string. POSIX.1‐2008 disallows this historical practice for consistency and because it places a large burden on implementations by requiring that knowledge of regular expressions be built into the editor parser.
Historically, quoting <newline> characters in ex commands was handled inconsistently. In most cases, the <newline> character always terminated the command, regardless of any preceding escape character, because <backslash> characters did not escape <newline> characters for most ex commands. However, some ex commands (for example, s, map, and abbreviation) permitted <newline> characters to be escaped (although in the case of map and abbreviation, <control>‐V characters escaped them instead of <backslash> characters). This was true in not only the command line, but also .exrc and sourced files. For example, the command:
map = foo<control-V><newline>bar
would succeed, although it was sometimes difficult to get the <control>‐V and the inserted <newline> passed to the ex parser. For consistency and simplicity of specification, POSIX.1‐2008 requires that it be possible to escape <newline> characters in ex commands at all times, using <backslash> characters for most ex commands, and using <control>‐V characters for the map and abbreviation commands. For example, the command print<newline>list is required to be parsed as the single command print<newline>list.  While this differs from historical practice, POSIX.1‐2008 developers believed it unlikely that any script or user depended on the historical behavior.
Historically, an error in a command specified using the -c option did not cause the rest of the -c commands to be discarded. POSIX.1‐2008 disallows this for consistency with mapped keys, the @, global, source, and v commands, the EXINIT environment variable, and the .exrc files.
Input Editing in ex One of the common uses of the historical ex editor is over slow network connections. Editors that run in canonical mode can require far less traffic to and from, and far less processing on, the host machine, as well as more easily supporting block-mode terminals. For these reasons, POSIX.1‐2008 requires that ex be implemented using canonical mode input processing, as was done historically.
POSIX.1‐2008 does not require the historical 4 BSD input editing characters ``word erase'' or ``literal next''. For this reason, it is unspecified how they are handled by ex, although they must have the required effect. Implementations that resolve them after the line has been ended using a <newline> or <control>‐M character, and implementations that rely on the underlying system terminal support for this processing, are both conforming.  Implementations are strongly urged to use the underlying system functionality, if at all possible, for compatibility with other system text input interfaces.
Historically, when the eof character was used to decrement the autoindent level, the cursor moved to display the new end of the autoindent characters, but did not move the cursor to a new line, nor did it erase the <control>‐D character from the line. POSIX.1‐2008 does not specify that the cursor remain on the same line or that the rest of the line is erased; however, implementations are strongly encouraged to provide the best possible user interface; that is, the cursor should remain on the same line, and any <control>‐D character on the line should be erased.
POSIX.1‐2008 does not require the historical 4 BSD input editing character ``reprint'', traditionally <control>‐R, which redisplayed the current input from the user. For this reason, and because the functionality cannot be implemented after the line has been terminated by the user, POSIX.1‐2008 makes no requirements about this functionality. Implementations are strongly urged to make this historical functionality available, if possible.
Historically, <control>‐Q did not perform a literal next function in ex, as it did in vi.  POSIX.1‐2008 requires conformance to historical practice to avoid breaking historical ex scripts and .exrc files.
eof Whether the eof character immediately modifies the autoindent characters in the prompt is left unspecified so that implementations can conform in the presence of systems that do not support this functionality. Implementations are encouraged to modify the line and redisplay it immediately, if possible.
The specification of the handling of the eof character differs from historical practice only in that eof characters are not discarded if they follow normal characters in the text input. Historically, they were always discarded.
Command Descriptions in ex Historically, several commands (for example, global, v, visual, s, write, wq, yank, !, <, >, &, and ~) were executable in empty files (that is, the default address(es) were 0), or permitted explicit addresses of 0 (for example, 0 was a valid address, or 0,0 was a valid range). Addresses of 0, or command execution in an empty file, make sense only for commands that add new text to the edit buffer or write commands (because users may wish to write empty files). POSIX.1‐2008 requires this behavior for such commands and disallows it otherwise, for consistency and simplicity of specification.
A count to an ex command has been historically corrected to be no greater than the last line in a file; for example, in a five-line file, the command 1,6print would fail, but the command 1print300 would succeed. POSIX.1‐2008 requires conformance to historical practice.
Historically, the use of flags in ex commands could be obscure. General historical practice was as described by POSIX.1‐2008, but there were some special cases. For instance, the list, number, and print commands ignored trailing address offsets; for example, 3p +++# would display line 3, and 3 would be the current line after the execution of the command. The open and visual commands ignored both the trailing offsets and the trailing flags.  Also, flags specified to the open and visual commands interacted badly with the list edit option, and setting and then unsetting it during the open/visual session would cause vi to stop displaying lines in the specified format. For consistency and simplicity of specification, POSIX.1‐2008 does not permit any of these exceptions to the general rule.
POSIX.1‐2008 uses the word copy in several places when discussing buffers. This is not intended to imply implementation.
Historically, ex users could not specify numeric buffers because of the ambiguity this would cause; for example, in the command 3 delete 2, it is unclear whether 2 is a buffer name or a count.  POSIX.1‐2008 requires conformance to historical practice by default, but does not preclude extensions.
Historically, the contents of the unnamed buffer were frequently discarded after commands that did not explicitly affect it; for example, when using the edit command to switch files. For consistency and simplicity of specification, POSIX.1‐2008 does not permit this behavior.
The ex utility did not historically have access to the numeric buffers, and, furthermore, deleting lines in ex did not modify their contents. For example, if, after doing a delete in vi, the user switched to ex, did another delete, and then switched back to vi, the contents of the numeric buffers would not have changed. POSIX.1‐2008 requires conformance to historical practice. Numeric buffers are described in the ex utility in order to confine the description of buffers to a single location in POSIX.1‐2008.
The metacharacters that trigger shell expansion in file arguments match historical practice, as does the method for doing shell expansion. Implementations wishing to provide users with the flexibility to alter the set of metacharacters are encouraged to provide a shellmeta string edit option.
Historically, ex commands executed from vi refreshed the screen when it did not strictly need to do so; for example, :!date > /dev/null does not require a screen refresh because the output of the UNIX date command requires only a single line of the screen. POSIX.1‐2008 requires that the screen be refreshed if it has been overwritten, but makes no requirements as to how an implementation should make that determination. Implementations may prompt and refresh the screen regardless.
Abbreviate Historical practice was that characters that were entered as part of an abbreviation replacement were subject to map expansions, the showmatch edit option, further abbreviation expansions, and so on; that is, they were logically pushed onto the terminal input queue, and were not a simple replacement. POSIX.1‐2008 requires conformance to historical practice.  Historical practice was that whenever a non-word character (that had not been escaped by a <control>‐V) was entered after a word character, vi would check for abbreviations. The check was based on the type of the character entered before the word character of the word/non- word pair that triggered the check. The word character of the word/non- word pair that triggered the check and all characters entered before the trigger pair that were of that type were included in the check, with the exception of <blank> characters, which always delimited the abbreviation.
This means that, for the abbreviation to work, the lhs must end with a word character, there can be no transitions from word to non-word characters (or vice versa) other than between the last and next-to-last characters in the lhs, and there can be no <blank> characters in the lhs. In addition, because of the historical quoting rules, it was impossible to enter a literal <control>‐V in the lhs.  POSIX.1‐2008 requires conformance to historical practice. Historical implementations did not inform users when abbreviations that could never be used were entered; implementations are strongly encouraged to do so.
For example, the following abbreviations will work:
:ab (p  REPLACE :ab p   REPLACE :ab ((p REPLACE
The following abbreviations will not work:
:ab (   REPLACE :ab (pp REPLACE
Historical practice is that words on the vi colon command line were subject to abbreviation expansion, including the arguments to the abbrev (and more interestingly) the unabbrev command. Because there are implementations that do not do abbreviation expansion for the first argument to those commands, this is permitted, but not required, by POSIX.1‐2008. However, the following sequence:
:ab foo bar :ab foo baz
resulted in the addition of an abbreviation of "baz" for the string "bar" in historical ex/vi, and the sequence:
:ab foo1 bar :ab foo2 bar :unabbreviate foo2
deleted the abbreviation "foo1", not "foo2".  These behaviors are not permitted by POSIX.1‐2008 because they clearly violate the expectations of the user.
It was historical practice that <control>‐V, not <backslash>, characters be interpreted as escaping subsequent characters in the abbreviate command. POSIX.1‐2008 requires conformance to historical practice; however, it should be noted that an abbreviation containing a <blank> will never work.
Append Historically, any text following a <vertical-line> command separator after an append, change, or insert command became part of the insert text. For example, in the command:
:g/pattern/append|stuff1
a line containing the text "stuff1" would be appended to each line matching pattern. It was also historically valid to enter:
:append|stuff1 stuff2 .
and the text on the ex command line would be appended along with the text inserted after it.  There was an historical bug, however, that the user had to enter two terminating lines (the '.'  lines) to terminate text input mode in this case. POSIX.1‐2008 requires conformance to historical practice, but disallows the historical need for multiple terminating lines.
Change See the RATIONALE for the append command. Historical practice for cursor positioning after the change command when no text is input, is as described in POSIX.1‐2008. However, one System V implementation is known to have been modified such that the cursor is positioned on the first address specified, and not on the line before the first address. POSIX.1‐2008 disallows this modification for consistency.
Historically, the change command did not support buffer arguments, although some implementations allow the specification of an optional buffer. This behavior is neither required nor disallowed by POSIX.1‐2008.
Change Directory A common extension in ex implementations is to use the elements of a cdpath edit option as prefix directories for path arguments to chdir that are relative pathnames and that do not have '.'  or ".." as their first component. Elements in the cdpath edit option are <colon>-separated.  The initial value of the cdpath edit option is the value of the shell CDPATH environment variable. This feature was not included in POSIX.1‐2008 because it does not exist in any of the implementations considered historical practice.
Copy Historical implementations of ex permitted copies to lines inside of the specified range; for example, :2,5copy3 was a valid command. POSIX.1‐2008 requires conformance to historical practice.
Delete POSIX.1‐2008 requires support for the historical parsing of a delete command followed by flags, without any intervening <blank> characters. For example:
1dp     Deletes the first line and prints the line that was second.
1delep  As for 1dp.
1d      Deletes the first line, saving it in buffer p.
1d p1l  (Pee-one-ell.) Deletes the first line, saving it in buffer p, and listing the line that was second.
Edit Historically, any ex command could be entered as a +command argument to the edit command, although some (for example, insert and append) were known to confuse historical implementations. For consistency and simplicity of specification, POSIX.1‐2008 requires that any command be supported as an argument to the edit command.
Historically, the command argument was executed with the current line set to the last line of the file, regardless of whether the edit command was executed from visual mode or not. POSIX.1‐2008 requires conformance to historical practice.
Historically, the +command specified to the edit and next commands was delimited by the first <blank>, and there was no way to quote them. For consistency, POSIX.1‐2008 requires that the usual ex backslash quoting be provided.
Historically, specifying the +command argument to the edit command required a filename to be specified as well; for example, :edit +100 would always fail. For consistency and simplicity of specification, POSIX.1‐2008 does not permit this usage to fail for that reason.
Historically, only the cursor position of the last file edited was remembered by the editor. POSIX.1‐2008 requires that this be supported; however, implementations are permitted to remember and restore the cursor position for any file previously edited.
File Historical versions of the ex editor file command displayed a current line and number of lines in the edit buffer of 0 when the file was empty, while the vi <control>‐G command displayed a current line and number of lines in the edit buffer of 1 in the same situation. POSIX.1‐2008 does not permit this discrepancy, instead requiring that a message be displayed indicating that the file is empty.
Global The two-pass operation of the global and v commands is not intended to imply implementation, only the required result of the operation.
The current line and column are set as specified for the individual ex commands. This requirement is cumulative; that is, the current line and column must track across all the commands executed by the global or v commands.
Insert See the RATIONALE for the append command.
Historically, insert could not be used with an address of zero; that is, not when the edit buffer was empty. POSIX.1‐2008 requires that this command behave consistently with the append command.
Join The action of the join command in relation to the special characters is only defined for the POSIX locale because the correct amount of white space after a period varies; in Japanese none is required, in French only a single space, and so on.
List The historical output of the list command was potentially ambiguous. The standard developers believed correcting this to be more important than adhering to historical practice, and POSIX.1‐2008 requires unambiguous output.
Map Historically, command mode maps only applied to command names; for example, if the character 'x' was mapped to 'y', the command fx searched for the 'x' character, not the 'y' character. POSIX.1‐2008 requires this behavior. Historically, entering <control>‐V as the first character of a vi command was an error. Several implementations have extended the semantics of vi such that <control>‐V means that the subsequent command character is not mapped. This is permitted, but not required, by POSIX.1‐2008. Regardless, using <control>‐V to escape the second or later character in a sequence of characters that might match a map command, or any character in text input mode, is historical practice, and stops the entered keys from matching a map. POSIX.1‐2008 requires conformance to historical practice.
Historical implementations permitted digits to be used as a map command lhs, but then ignored the map. POSIX.1‐2008 requires that the mapped digits not be ignored.
The historical implementation of the map command did not permit map commands that were more than a single character in length if the first character was printable. This behavior is permitted, but not required, by POSIX.1‐2008.
Historically, mapped characters were remapped unless the remap edit option was not set, or the prefix of the mapped characters matched the mapping characters; for example, in the map:
:map ab abcd
the characters "ab" were used as is and were not remapped, but the characters "cd" were mapped if appropriate. This can cause infinite loops in the vi mapping mechanisms. POSIX.1‐2008 requires conformance to historical practice, and that such loops be interruptible.
Text input maps had the same problems with expanding the lhs for the ex map!  and unmap!  command as did the ex abbreviate and unabbreviate commands. See the RATIONALE for the ex abbreviate command. POSIX.1‐2008 requires similar modification of some historical practice for the map and unmap commands, as described for the abbreviate and unabbreviate commands.
Historically, maps that were subsets of other maps behaved differently depending on the order in which they were defined.  For example:
:map! ab     short :map! abc    long
would always translate the characters "ab" to "short", regardless of how fast the characters "abc" were entered. If the entry order was reversed:
:map! abc    long :map! ab     short
the characters "ab" would cause the editor to pause, waiting for the completing 'c' character, and the characters might never be mapped to "short".  For consistency and simplicity of specification, POSIX.1‐2008 requires that the shortest match be used at all times.
The length of time the editor spends waiting for the characters to complete the lhs is unspecified because the timing capabilities of systems are often inexact and variable, and it may depend on other factors such as the speed of the connection. The time should be long enough for the user to be able to complete the sequence, but not long enough for the user to have to wait. Some implementations of vi have added a keytime option, which permits users to set the number of 0,1 seconds the editor waits for the completing characters. Because mapped terminal function and cursor keys tend to start with an <ESC> character, and <ESC> is the key ending vi text input mode, maps starting with <ESC> characters are generally exempted from this timeout period, or, at least timed out differently.
Mark Historically, users were able to set the ``previous context'' marks explicitly. In addition, the ex commands '' and '` and the vi commands '', ``, `', and '` all referred to the same mark. In addition, the previous context marks were not set if the command, with which the address setting the mark was associated, failed. POSIX.1‐2008 requires conformance to historical practice. Historically, if marked lines were deleted, the mark was also deleted, but would reappear if the change was undone. POSIX.1‐2008 requires conformance to historical practice.
The description of the special events that set the ` and ' marks matches historical practice. For example, historically the command /a/,/b/ did not set the ` and ' marks, but the command /a/,/b/delete did.
Next Historically, any ex command could be entered as a +command argument to the next command, although some (for example, insert and append) were known to confuse historical implementations. POSIX.1‐2008 requires that any command be permitted and that it behave as specified. The next command can accept more than one file, so usage such as:
next `ls [abc] `
is valid; it need not be valid for the edit or read commands, for example, because they expect only one filename.
Historically, the next command behaved differently from the :rewind command in that it ignored the force flag if the autowrite flag was set. For consistency, POSIX.1‐2008 does not permit this behavior.
Historically, the next command positioned the cursor as if the file had never been edited before, regardless. POSIX.1‐2008 does not permit this behavior, for consistency with the edit command.