4 sam, B, sam.save, samterm \- screen editor with structural regular expressions
26 is a multi-file editor.
27 It modifies a local copy of an external file.
28 The copy is here called a
30 The files are listed in a menu available through mouse button 3
34 Each file has an associated name, usually the name of the
35 external file from which it was read, and a `modified' bit that indicates whether
36 the editor's file agrees with the external file.
37 The external file is not read into
38 the editor's file until it first becomes the current file\(emthat to
39 which editing commands apply\(emwhereupon its menu entry is printed.
44 Autoindent. In this mode, when a newline character is typed
45 in the terminal interface,
47 copies leading white space on the current line to the new line.
50 Do not `download' the terminal part of
52 Editing will be done with the command language only, as in
56 Run the host part remotely
57 on the specified machine, the terminal part locally.
60 Start the host part from the specified file on the remote host.
61 Only meaningful with the
66 Start the terminal part from the specified file. Useful
69 .SS Regular expressions
70 Regular expressions are as in
74 to represent newlines.
75 A regular expression may never contain a literal newline character.
77 regular expression stands for the last complete expression encountered.
78 A regular expression in
80 matches the longest leftmost substring formally
81 matched by the expression.
82 Searching in the reverse direction is equivalent
83 to searching backwards with the catenation operations reversed in
86 An address identifies a substring in a file.
87 In the following, `character
92 character in the file, with 1 the
93 first character in the file.
99 starting at the beginning of the file, of the regular expression
101 All files always have a current substring, called dot,
102 that is the default address.
107 The empty string after character
110 is the beginning of the file.
116 is the beginning of the file.
122 The substring that matches the regular expression,
123 found by looking toward the end
128 and if necessary continuing the search from the other end to the
129 starting point of the search.
130 The matched substring may straddle
132 When entering a pattern containing a literal question mark
133 for a backward search, the question mark should be
134 specified as a member of a class.
138 The string before the first full line.
139 This is not necessarily
147 The null string at the end of the file.
153 The mark in the file (see the
157 \fB"\f2regexp\fB"\f1\f1
158 Preceding a simple address (default
160 refers to the address evaluated in the unique file whose menu line
161 matches the regular expression.
163 .SS Compound Addresses
174 evaluated starting at the end of
180 evaluated looking in the reverse direction
181 starting at the beginning of
185 The substring from the beginning of
205 evaluated at the end of, and dot set to,
213 are high precedence, while
225 is a line or character address with a missing
226 number, the number defaults to 1.
236 are present and distinguishable,
241 expression; if it is delimited by
249 It is an error for a compound address to represent a malformed substring.
253 selects the line containing
254 the end (beginning) of a1.
256 locates the first match of the expression in the file.
259 sets dot unnecessarily.)
261 finds the second following occurrence of the expression,
266 In the following, text demarcated by slashes represents text delimited
268 character except alphanumerics.
270 trailing delimiters may be elided, with multiple elisions then representing
271 null strings, but the first delimiter must always
273 In any delimited text,
274 newline may not appear literally;
276 may be typed for newline; and
278 quotes the delimiter, here
280 Backslash is otherwise interpreted literally, except in
284 Most commands may be prefixed by an address to indicate their range
286 Those that may not are marked with a
290 an address and none is supplied, dot is used.
291 The sole exception is
294 command, which defaults to
296 In the description, `range' is used
297 to represent whatever address is supplied.
298 Many commands set the
299 value of dot as a side effect.
300 If so, it is always set to the `result'
301 of the change: the empty string for a deletion, the new text for an
302 insertion, etc. (but see the
321 Insert the text into the file after the range.
334 replaces the text, while
341 Delete the text in the range.
344 .BI s/ regexp / text /
347 for the first match to the regular expression in the range.
348 Set dot to the modified range.
353 stands for the string
354 that matched the expression.
355 Backslash behaves as usual unless followed by
358 stands for the string that matched the
359 subexpression begun by the
364 is followed immediately by a
371 match in the range is substituted.
373 command is followed by a
377 all matches in the range
396 Print the text in the range.
400 Print the line address and character address of the range.
403 Print just the character address of the range.
409 Set the current file to the first file named in the list
412 also has in its menu.
413 The list may be expressed
414 .BI < "Plan 9 command"
415 in which case the file names are taken as words (in the shell sense)
416 generated by the Plan 9 command.
421 except that file names not in the menu are entered there,
422 and all file names in the list are examined.
425 Print a menu of files.
430 indicating the file is modified or clean,
433 indicating the file is unread or has been read
436 means more than one window is open),
439 indicating the current file,
447 Delete the named files from the menu.
448 If no files are named, the current file is deleted.
451 a modified file, but a subsequent
453 will delete such a file.
459 Replace the file by the contents of the named external file.
460 Set dot to the beginning of the file.
463 Replace the text in the range by the contents of the named external file.
467 Write the range (default
469 to the named external file.
472 Set the file name and print the resulting menu entry.
474 If the file name is absent from any of these, the current file name is used.
476 always sets the file name;
480 do so if the file has no name.
482 .BI < " Plan 9-command
483 Replace the range by the standard output of the
486 .BI > " Plan 9-command
487 Send the range to the standard input of the
490 .BI | " Plan 9-command
491 Send the range to the standard input, and replace it by
492 the standard output, of the
495 .BI \*a! " Plan 9-command
499 .BI \*acd " directory
500 Change working directory.
501 If no directory is specified,
516 (of any type) is substituted.
521 (using the mouse and raster display, i.e. not using option
524 sets standard input to
534 for all) is placed in
536 and the first few lines are printed.
537 .SS Loops and Conditionals
540 .BI x/ regexp / " command
541 For each match of the regular expression in the range, run the command
542 with dot set to the match.
543 Set dot to the last match.
545 expression and its slashes are omitted,
548 Null string matches potentially occur before every character
549 of the range and at the end of the range.
551 .BI y/ regexp / " command
554 but run the command for each substring that lies before, between,
556 the matches that would be generated by
558 There is no default regular expression.
559 Null substrings potentially occur before every character
562 .BI \*aX/ regexp / " command
563 For each file whose menu entry matches the regular expression,
564 make that the current file and
566 If the expression is omitted, the command is run
569 .BI \*aY/ regexp / " command
572 but for files that do not match the regular expression,
573 and the expression is required.
575 .BI g/ regexp / " command
579 .BI v/ regexp / " command
580 If the range contains
584 a match for the expression,
585 set dot to the range and run the command.
587 These may be nested arbitrarily deeply, but only one instance of either
591 may appear in a \%single command.
592 An empty command in an
607 do not have defaults.
613 Set the current file's mark to the range. Does not set dot.
617 It is an error to quit with modified files, but a second
625 top-level commands that changed the contents or name of the
626 current file, and any other file whose most recent change was simultaneous
627 with the current file's change.
630 move further back in time.
631 The only commands for which u is ineffective are
642 `redoes,' undoing the undo, going forwards in time again.
645 If the range is explicit, set dot to the range.
648 is downloaded, the resulting dot is selected on the screen;
649 otherwise it is printed.
650 If no address is specified (the
651 command is a newline) dot is extended in either direction to
652 line boundaries and printed.
653 If dot is thereby unchanged, it is set to
657 .SS Grouping and multiple changes
658 Commands may be grouped by enclosing them in braces
660 Commands within the braces must appear on separate lines (no backslashes are
661 required between commands).
662 Semantically, an opening brace is like a command:
663 it takes an (optional) address and sets dot for each sub-command.
664 Commands within the braces are executed sequentially, but changes made
665 by one command are not visible to other commands (see the next
667 Braces may be nested arbitrarily.
669 When a command makes a number of changes to a file, as in
671 the addresses of all changes to the file are computed in the original file.
672 If the changes are in sequence,
673 they are applied to the file.
674 Successive insertions at the same address are catenated into a single
675 insertion composed of the several insertions in the order applied.
677 What follows refers to behavior of
679 when downloaded, that is, when
680 operating as a display editor on a raster display.
686 (no download) option provides access
687 to the command language only.
689 Each file may have zero or more windows open.
690 Each window is equivalent
691 and is updated simultaneously with changes in other windows on the same file.
692 Each window has an independent value of dot, indicated by a highlighted
693 substring on the display.
694 Dot may be in a region not within
696 There is usually a `current window',
697 marked with a dark border, to which typed text and editing
699 Text may be typed and edited as in
701 also the escape key (ESC) selects (sets dot to) text typed
702 since the last mouse button hit.
704 The button 3 menu controls window operations.
706 provides the following operators, each of which uses one or
709 cursors to prompt for selection of a window or sweeping
711 `Sweeping' a null rectangle gets a large window, disjoint
712 from the command window or the whole screen, depending on
713 where the null rectangle is.
717 Create a new, empty file.
720 Create a copy of an existing window.
728 In the last window of a file,
740 Below these operators is a list of available files, starting with
743 Selecting a file from the list makes the most recently
744 used window on that file current, unless it is already current, in which
745 case selections cycle through the open windows.
746 If no windows are open
747 on the file, the user is prompted to open one.
750 are marked with one of the characters
752 according as zero, one, or more windows
753 are open on the file.
756 appears on the file in the current window and
759 on a file modified since last write.
761 The command window, created automatically when
763 starts, is an ordinary window except that text typed to it
764 is interpreted as commands for the editor rather than passive text,
765 and text printed by editor commands appears in it.
768 with an `output point' that separates commands being typed from
770 Commands typed in the command window apply to the
771 current open file\(emthe file in the most recently
773 .SS Manipulating text
774 Button 1 changes selection, much like
776 Pointing to a non-current window with button 1 makes it current;
777 within the current window, button 1 selects text, thus setting dot.
778 Double-clicking selects text to the boundaries of words, lines,
779 quoted strings or bracketed strings, depending on the text at the click.
781 Button 2 provides a menu of editing commands:
785 Delete dot and save the deleted text in the snarf buffer.
788 Replace the text in dot by the contents of the snarf buffer.
791 Save the text in dot in the snarf buffer.
794 Send the text in the selection as a plumb
795 message. If the selection is empty,
796 the white-space-delimited block of text is sent as a plumb message
799 attribute defining where the selection lies (see
803 Search forward for the next occurrence of the literal text in dot.
804 If dot is the null string, the text in the snarf buffer is
806 The snarf buffer is unaffected.
809 Exchange snarf buffers with
813 Search forward for the next match of the last regular expression
815 (Not in command window.)
818 Send the text in dot, or the snarf buffer if
819 dot is the null string, as if it were typed to the command window.
820 Saves the sent text in the snarf buffer.
821 (Command window only.)
823 .SS External communication
828 If plumbing is not active,
833 which acts as an additional source of commands. Characters written to
834 the named pipe are treated as if they had been typed in the command window.
837 is a shell-level command that causes an instance of
839 running on the same terminal to load the named
842 uses either plumbing or the named pipe, whichever service is available.
843 If plumbing is not enabled,
844 the option allows a line number to be specified for
845 the initial position to display in the last named file
846 (plumbing provides a more general mechanism for this ability).
847 .SS Abnormal termination
850 terminates other than by a
852 command (by hangup, deleting its window, etc.), modified
853 files are saved in an
856 This program, when executed, asks whether to write
857 each file back to a external file.
860 causes writing; anything else skips the file.
862 .TF /sys/src/cmd/samterm
869 the program called to unpack
872 .TF /sys/src/cmd/samterm
879 .B /sys/src/cmd/samterm
880 source for the separate terminal part
891 ``The text editor sam''.