What buffers and commands exist in regular vi (NOT Vim/gVim/etc)?
I have to use regular vi often. I am curious about what buffers exists in regular vi.
I know I can reference buffer a with "a, and there are at least 26 buffers : a to z, and I can append to them with by using alternate buffers A to Z.
But I want to know about: what others buffers exists in vi? (is, like in Vim, one that contains the last ":command" ? the last normal-mode action ? the last deleted text ? etc.)
Note: Bonus point if you know about a good documentation for regular vi showing everything it can do (not just buffers, but what type of moves, what commands exist, etc). for "posix vi" and maybe others (AIX vi? Not sure if that one is posix)
(I looked at cheat-sheets, but couldn't find infos, and often I stumbled on sheets made for Vim instead)
"Buffer" (POSIX) is "register" (Vim); "editing buffer" (POSIX) is "buffer" (Vim).
POSIX defines "buffers" "a" to "z", also "1" to "9" and unnamed one (aka. quote-register). "Colon" register from Vim et al. not defined.
The Open Group spec is available for vi and ex separately.
To find the latest version open https://pubs.opengroup.org/onlinepubs/?C=M;O=D then hit the top row. Type item to find and hit the search button.
"Original vi" is a little bit difficult to define. The POSIX specification is the most authoritative source:
Many features of vi are not specified in the vi specification because it was just a "mode" of ex, so the whole feature set of vi must be pieced together from both specifications.
In this case, vi's buffers ("registers" in Vim) are described as part of ex. And since that document is authored in an awful way, you will have to search for buffers on your own.
Here is the section on buffers as of January 2025:
One of a number of named areas for holding text. The named buffers are specified by the alphanumeric characters of the POSIX locale. There shall also be one "unnamed" buffer. When no buffer is specified for editor commands that use a buffer, the unnamed buffer shall be used. Commands that store text into buffers shall store the text as it was before the command took effect, and shall store text occurring earlier in the file before text occurring later in the file, regardless of how the text region was specified. Commands that store text into buffers shall store the text into the unnamed buffer as well as any specified buffer.
In ex commands, buffer names are specified as the name by itself. In open or visual mode commands the name is preceded by a double-quote ( ' )' character.
If the specified buffer name is an uppercase character, and the buffer contents are to be modified, the buffer shall be appended to rather than being overwritten. If the buffer is not being modified, specifying the buffer name in lowercase and uppercase shall have identical results.
There shall also be buffers named by the numbers 1 through 9. In open and visual mode, if a region of text including characters from more than a single line is being modified by the vi c or d commands, the motion character associated with the c or d commands specifies that the buffer text shall be in line mode, or the commands %, `, /, ?, (, ), N, n, {, or } are used to define a region of text for the c or d commands, the contents of buffers 1 through 8 shall be moved into the buffer named by the next numerically greater value, the contents of buffer 9 shall be discarded, and the region of text shall be copied into buffer 1. This shall be in addition to copying the text into a user-specified buffer or unnamed buffer, or both. Numeric buffers can be specified as a source buffer for open and visual mode commands; however, specifying a numeric buffer as the write target of an open or visual mode command shall have unspecified results.
The text of each buffer shall have the characteristic of being in either line or character mode. Appending text to a non-empty buffer shall set the mode to match the characteristic of the text being appended. Appending text to a buffer shall cause the creation of at least one additional line in the buffer. All text stored into buffers by ex commands shall be in line mode. The ex commands that use buffers as the source of text specify individually how buffers of different modes are handled. Each open or visual mode command that uses buffers for any purpose specifies individually the mode of the text stored into the buffer and how buffers of different modes are handled.
From which we can gather the following list:
Yeah, the "IMproved" in "Vi IMproved" is not an exaggeration.