9srv Manual Collection/plan9/sam(1) | 9srv Manual Collection/plan9/sam(1) |
---|
sam -r machine
sam.save
B [ -nnnn ] file ...
The operators + and - are high precedence, while , and ; are low precedence.
In both + and - forms, if a2 is a line or character address with a missing number, the number defaults to 1. If a1 is missing, . is substituted. If both a1 and a2 are present and distinguishable, + may be elided. a2 may be a regular expression; if it is delimited by ?'s, the effect of the + or - is reversed.
It is an error for a compound address to represent a malformed substring. Some useful idioms: a1+- %(a1-+) selects the line containing the end (beginning) of a1. 0/regexp/ locates the first match of the expression in the file. (The form 0;// sets dot unnecessarily.) ./regexp/// finds the second following occurrence of the expression, and .,/regexp/ extends dot.
Most commands may be prefixed by an address to indicate their range
of operation.
Those that may not are marked with a
*
below.
If a command takes
an address and none is supplied, dot is used.
The sole exception is
the
w
command, which defaults to
0,$.
In the description, `range' is used
to represent whatever address is supplied.
Many commands set the
value of dot as a side effect.
If so, it is always set to the `result'
of the change: the empty string for a deletion, the new text for an
insertion, etc. (but see the
s
and
e
commands).
In any of <, >, | or !, if the Plan 9 command is omitted the last Plan 9 command (of any type) is substituted. If sam is downloaded (using the mouse and raster display, i.e. not using option -d), ! sets standard input to /dev/null, and otherwise unassigned output (stdout for ! and >, stderr for all) is placed in /tmp/sam.err and the first few lines are printed.
When a command makes a number of changes to a file, as in x/re/c/text/, the addresses of all changes to the file are computed in the original file. If the changes are in sequence, they are applied to the file. Successive insertions at the same address are catenated into a single insertion composed of the several insertions in the order applied.
Each file may have zero or more windows open. Each window is equivalent and is updated simultaneously with changes in other windows on the same file. Each window has an independent value of dot, indicated by a highlighted substring on the display. Dot may be in a region not within the window. There is usually a `current window', marked with a dark border, to which typed text and editing commands apply. Text may be typed and edited as in rio(1); also the escape key (ESC) selects (sets dot to) text typed since the last mouse button hit.
The button 3 menu controls window operations. The top of the menu provides the following operators, each of which uses one or more rio-like cursors to prompt for selection of a window or sweeping of a rectangle. `Sweeping' a null rectangle gets a large window, disjoint from the command window or the whole screen, depending on where the null rectangle is.
Below these operators is a list of available files, starting with ~~sam~~, the command window. Selecting a file from the list makes the most recently used window on that file current, unless it is already current, in which case selections cycle through the open windows. If no windows are open on the file, the user is prompted to open one. Files other than ~~sam~~ are marked with one of the characters -+* according as zero, one, or more windows are open on the file. A further mark . appears on the file in the current window and a single quote, ', on a file modified since last write.
The command window, created automatically when sam starts, is an ordinary window except that text typed to it is interpreted as commands for the editor rather than passive text, and text printed by editor commands appears in it. The behavior is like rio, with an `output point' that separates commands being typed from previous output. Commands typed in the command window apply to the current open filethe file in the most recently current window.
Button 2 provides a menu of editing commands:
B is a shell-level command that causes an instance of sam running on the same terminal to load the named files. B uses either plumbing or the named pipe, whichever service is available. If plumbing is not enabled, the option allows a line number to be specified for the initial position to display in the last named file (plumbing provides a more general mechanism for this ability).
Rob Pike, ``The text editor sam''.
9srv Manual Collection/plan9/sam(1) | Rev: Sun Dec 02 23:42:16 GMT 2007 |