2 cfa37a7b 2004-04-10 devnull .ds a \fR*\ \fP
4 058b0118 2005-01-03 devnull sam, B, E, sam.save, samterm, samsave \- screen editor with structural regular expressions
5 cfa37a7b 2004-04-10 devnull .SH SYNOPSIS
8 cfa37a7b 2004-04-10 devnull .I option ...
15 cfa37a7b 2004-04-10 devnull .I machine
17 cfa37a7b 2004-04-10 devnull .B sam.save
20 058b0118 2005-01-03 devnull .IB file \fR[\fP: line \fR]
25 cfa37a7b 2004-04-10 devnull .SH DESCRIPTION
27 cfa37a7b 2004-04-10 devnull is a multi-file editor.
28 cfa37a7b 2004-04-10 devnull It modifies a local copy of an external file.
29 cfa37a7b 2004-04-10 devnull The copy is here called a
30 cfa37a7b 2004-04-10 devnull .IR file .
31 cfa37a7b 2004-04-10 devnull The files are listed in a menu available through mouse button 3
35 cfa37a7b 2004-04-10 devnull Each file has an associated name, usually the name of the
36 cfa37a7b 2004-04-10 devnull external file from which it was read, and a `modified' bit that indicates whether
37 cfa37a7b 2004-04-10 devnull the editor's file agrees with the external file.
38 cfa37a7b 2004-04-10 devnull The external file is not read into
39 cfa37a7b 2004-04-10 devnull the editor's file until it first becomes the current file\(emthat to
40 cfa37a7b 2004-04-10 devnull which editing commands apply\(emwhereupon its menu entry is printed.
41 cfa37a7b 2004-04-10 devnull The options are
42 cfa37a7b 2004-04-10 devnull .TF -rmachine
45 d93fca6a 2005-02-11 devnull Autoindent. In this mode, when a newline character is typed
46 d93fca6a 2005-02-11 devnull in the terminal interface,
47 d93fca6a 2005-02-11 devnull .I samterm
48 d93fca6a 2005-02-11 devnull copies leading white space on the current line to the new line.
51 cfa37a7b 2004-04-10 devnull Do not `download' the terminal part of
52 cfa37a7b 2004-04-10 devnull .IR sam .
53 cfa37a7b 2004-04-10 devnull Editing will be done with the command language only, as in
54 cfa37a7b 2004-04-10 devnull .IR ed (1).
56 cfa37a7b 2004-04-10 devnull .BI -r " machine
57 cfa37a7b 2004-04-10 devnull Run the host part remotely
58 cfa37a7b 2004-04-10 devnull on the specified machine, the terminal part locally.
60 cfa37a7b 2004-04-10 devnull .BI -s " path
61 cfa37a7b 2004-04-10 devnull Start the host part from the specified file on the remote host.
62 cfa37a7b 2004-04-10 devnull Only meaningful with the
66 cfa37a7b 2004-04-10 devnull .BI -t " path
67 cfa37a7b 2004-04-10 devnull Start the terminal part from the specified file. Useful
68 cfa37a7b 2004-04-10 devnull for debugging.
70 cfa37a7b 2004-04-10 devnull .SS Regular expressions
71 cfa37a7b 2004-04-10 devnull Regular expressions are as in
72 058b0118 2005-01-03 devnull .IR regexp (7)
73 cfa37a7b 2004-04-10 devnull with the addition of
75 cfa37a7b 2004-04-10 devnull to represent newlines.
76 cfa37a7b 2004-04-10 devnull A regular expression may never contain a literal newline character.
77 cfa37a7b 2004-04-10 devnull The empty
78 cfa37a7b 2004-04-10 devnull regular expression stands for the last complete expression encountered.
79 cfa37a7b 2004-04-10 devnull A regular expression in
81 cfa37a7b 2004-04-10 devnull matches the longest leftmost substring formally
82 cfa37a7b 2004-04-10 devnull matched by the expression.
83 cfa37a7b 2004-04-10 devnull Searching in the reverse direction is equivalent
84 cfa37a7b 2004-04-10 devnull to searching backwards with the catenation operations reversed in
85 cfa37a7b 2004-04-10 devnull the expression.
86 cfa37a7b 2004-04-10 devnull .SS Addresses
87 cfa37a7b 2004-04-10 devnull An address identifies a substring in a file.
88 cfa37a7b 2004-04-10 devnull In the following, `character
90 cfa37a7b 2004-04-10 devnull means the null string
91 cfa37a7b 2004-04-10 devnull after the
92 cfa37a7b 2004-04-10 devnull .IR n -th
93 cfa37a7b 2004-04-10 devnull character in the file, with 1 the
94 cfa37a7b 2004-04-10 devnull first character in the file.
97 cfa37a7b 2004-04-10 devnull means the
98 cfa37a7b 2004-04-10 devnull .IR n -th
100 cfa37a7b 2004-04-10 devnull starting at the beginning of the file, of the regular expression
101 cfa37a7b 2004-04-10 devnull .LR .*\en? .
102 cfa37a7b 2004-04-10 devnull All files always have a current substring, called dot,
103 cfa37a7b 2004-04-10 devnull that is the default address.
104 cfa37a7b 2004-04-10 devnull .SS Simple Addresses
108 cfa37a7b 2004-04-10 devnull The empty string after character
111 cfa37a7b 2004-04-10 devnull is the beginning of the file.
117 cfa37a7b 2004-04-10 devnull is the beginning of the file.
119 cfa37a7b 2004-04-10 devnull .BI / regexp /
122 cfa37a7b 2004-04-10 devnull .BI ? regexp ?
123 cfa37a7b 2004-04-10 devnull The substring that matches the regular expression,
124 cfa37a7b 2004-04-10 devnull found by looking toward the end
125 cfa37a7b 2004-04-10 devnull .RB ( / )
126 cfa37a7b 2004-04-10 devnull or beginning
127 cfa37a7b 2004-04-10 devnull .RB ( ? )
128 cfa37a7b 2004-04-10 devnull of the file,
129 cfa37a7b 2004-04-10 devnull and if necessary continuing the search from the other end to the
130 cfa37a7b 2004-04-10 devnull starting point of the search.
131 cfa37a7b 2004-04-10 devnull The matched substring may straddle
132 cfa37a7b 2004-04-10 devnull the starting point.
133 cfa37a7b 2004-04-10 devnull When entering a pattern containing a literal question mark
134 cfa37a7b 2004-04-10 devnull for a backward search, the question mark should be
135 cfa37a7b 2004-04-10 devnull specified as a member of a class.
139 cfa37a7b 2004-04-10 devnull The string before the first full line.
140 cfa37a7b 2004-04-10 devnull This is not necessarily
141 cfa37a7b 2004-04-10 devnull the null string; see
148 cfa37a7b 2004-04-10 devnull The null string at the end of the file.
154 cfa37a7b 2004-04-10 devnull The mark in the file (see the
156 cfa37a7b 2004-04-10 devnull command below).
158 cfa37a7b 2004-04-10 devnull \fB"\f2regexp\fB"\f1\f1
159 cfa37a7b 2004-04-10 devnull Preceding a simple address (default
160 cfa37a7b 2004-04-10 devnull .BR . ),
161 cfa37a7b 2004-04-10 devnull refers to the address evaluated in the unique file whose menu line
162 cfa37a7b 2004-04-10 devnull matches the regular expression.
164 cfa37a7b 2004-04-10 devnull .SS Compound Addresses
165 cfa37a7b 2004-04-10 devnull In the following,
169 cfa37a7b 2004-04-10 devnull are addresses.
170 cfa37a7b 2004-04-10 devnull .TF a1+a2
172 cfa37a7b 2004-04-10 devnull .IB a1 + a2
173 cfa37a7b 2004-04-10 devnull The address
175 cfa37a7b 2004-04-10 devnull evaluated starting at the end of
176 cfa37a7b 2004-04-10 devnull .IR a1 .
178 cfa37a7b 2004-04-10 devnull .IB a1 - a2
179 cfa37a7b 2004-04-10 devnull The address
181 cfa37a7b 2004-04-10 devnull evaluated looking in the reverse direction
182 cfa37a7b 2004-04-10 devnull starting at the beginning of
183 cfa37a7b 2004-04-10 devnull .IR a1 .
185 cfa37a7b 2004-04-10 devnull .IB a1 , a2
186 cfa37a7b 2004-04-10 devnull The substring from the beginning of
188 cfa37a7b 2004-04-10 devnull to the end of
189 cfa37a7b 2004-04-10 devnull .IR a2 .
192 cfa37a7b 2004-04-10 devnull is missing,
194 cfa37a7b 2004-04-10 devnull is substituted.
197 cfa37a7b 2004-04-10 devnull is missing,
199 cfa37a7b 2004-04-10 devnull is substituted.
201 cfa37a7b 2004-04-10 devnull .IB a1 ; a2
203 cfa37a7b 2004-04-10 devnull .IB a1 , a2\f1,
204 cfa37a7b 2004-04-10 devnull but with
206 cfa37a7b 2004-04-10 devnull evaluated at the end of, and dot set to,
207 cfa37a7b 2004-04-10 devnull .IR a1 .
210 cfa37a7b 2004-04-10 devnull The operators
214 cfa37a7b 2004-04-10 devnull are high precedence, while
218 cfa37a7b 2004-04-10 devnull are low precedence.
224 cfa37a7b 2004-04-10 devnull forms, if
226 cfa37a7b 2004-04-10 devnull is a line or character address with a missing
227 cfa37a7b 2004-04-10 devnull number, the number defaults to 1.
230 cfa37a7b 2004-04-10 devnull is missing,
232 cfa37a7b 2004-04-10 devnull is substituted.
237 cfa37a7b 2004-04-10 devnull are present and distinguishable,
239 cfa37a7b 2004-04-10 devnull may be elided.
241 cfa37a7b 2004-04-10 devnull may be a regular
242 cfa37a7b 2004-04-10 devnull expression; if it is delimited by
243 cfa37a7b 2004-04-10 devnull .LR ? 's,
244 cfa37a7b 2004-04-10 devnull the effect of the
248 cfa37a7b 2004-04-10 devnull is reversed.
250 cfa37a7b 2004-04-10 devnull It is an error for a compound address to represent a malformed substring.
251 cfa37a7b 2004-04-10 devnull Some useful idioms:
252 cfa37a7b 2004-04-10 devnull .IB a1 +-
253 cfa37a7b 2004-04-10 devnull \%(\f2a1\fB-+\f1)
254 cfa37a7b 2004-04-10 devnull selects the line containing
255 cfa37a7b 2004-04-10 devnull the end (beginning) of a1.
256 cfa37a7b 2004-04-10 devnull .BI 0/ regexp /
257 cfa37a7b 2004-04-10 devnull locates the first match of the expression in the file.
258 cfa37a7b 2004-04-10 devnull (The form
260 cfa37a7b 2004-04-10 devnull sets dot unnecessarily.)
261 cfa37a7b 2004-04-10 devnull .BI ./ regexp ///
262 cfa37a7b 2004-04-10 devnull finds the second following occurrence of the expression,
264 cfa37a7b 2004-04-10 devnull .BI .,/ regexp /
265 cfa37a7b 2004-04-10 devnull extends dot.
266 cfa37a7b 2004-04-10 devnull .SS Commands
267 cfa37a7b 2004-04-10 devnull In the following, text demarcated by slashes represents text delimited
268 cfa37a7b 2004-04-10 devnull by any printable
269 cfa37a7b 2004-04-10 devnull character except alphanumerics.
270 cfa37a7b 2004-04-10 devnull Any number of
271 cfa37a7b 2004-04-10 devnull trailing delimiters may be elided, with multiple elisions then representing
272 cfa37a7b 2004-04-10 devnull null strings, but the first delimiter must always
273 cfa37a7b 2004-04-10 devnull be present.
274 cfa37a7b 2004-04-10 devnull In any delimited text,
275 cfa37a7b 2004-04-10 devnull newline may not appear literally;
277 cfa37a7b 2004-04-10 devnull may be typed for newline; and
279 cfa37a7b 2004-04-10 devnull quotes the delimiter, here
281 cfa37a7b 2004-04-10 devnull Backslash is otherwise interpreted literally, except in
283 cfa37a7b 2004-04-10 devnull commands.
285 cfa37a7b 2004-04-10 devnull Most commands may be prefixed by an address to indicate their range
286 cfa37a7b 2004-04-10 devnull of operation.
287 cfa37a7b 2004-04-10 devnull Those that may not are marked with a
290 cfa37a7b 2004-04-10 devnull If a command takes
291 cfa37a7b 2004-04-10 devnull an address and none is supplied, dot is used.
292 cfa37a7b 2004-04-10 devnull The sole exception is
295 cfa37a7b 2004-04-10 devnull command, which defaults to
296 cfa37a7b 2004-04-10 devnull .BR 0,$ .
297 cfa37a7b 2004-04-10 devnull In the description, `range' is used
298 cfa37a7b 2004-04-10 devnull to represent whatever address is supplied.
299 cfa37a7b 2004-04-10 devnull Many commands set the
300 cfa37a7b 2004-04-10 devnull value of dot as a side effect.
301 cfa37a7b 2004-04-10 devnull If so, it is always set to the `result'
302 cfa37a7b 2004-04-10 devnull of the change: the empty string for a deletion, the new text for an
303 cfa37a7b 2004-04-10 devnull insertion, etc. (but see the
307 cfa37a7b 2004-04-10 devnull commands).
309 cfa37a7b 2004-04-10 devnull .ne 1.2i
310 cfa37a7b 2004-04-10 devnull .SS Text commands
313 cfa37a7b 2004-04-10 devnull .BI a/ text /
319 cfa37a7b 2004-04-10 devnull .I lines of text
322 cfa37a7b 2004-04-10 devnull Insert the text into the file after the range.
323 cfa37a7b 2004-04-10 devnull Set dot.
335 cfa37a7b 2004-04-10 devnull replaces the text, while
338 cfa37a7b 2004-04-10 devnull .I before
339 cfa37a7b 2004-04-10 devnull the range.
342 cfa37a7b 2004-04-10 devnull Delete the text in the range.
343 cfa37a7b 2004-04-10 devnull Set dot.
345 cfa37a7b 2004-04-10 devnull .BI s/ regexp / text /
346 cfa37a7b 2004-04-10 devnull Substitute
348 cfa37a7b 2004-04-10 devnull for the first match to the regular expression in the range.
349 cfa37a7b 2004-04-10 devnull Set dot to the modified range.
352 cfa37a7b 2004-04-10 devnull the character
354 cfa37a7b 2004-04-10 devnull stands for the string
355 cfa37a7b 2004-04-10 devnull that matched the expression.
356 cfa37a7b 2004-04-10 devnull Backslash behaves as usual unless followed by
357 cfa37a7b 2004-04-10 devnull a digit:
358 cfa37a7b 2004-04-10 devnull .BI \e d
359 cfa37a7b 2004-04-10 devnull stands for the string that matched the
360 cfa37a7b 2004-04-10 devnull subexpression begun by the
361 cfa37a7b 2004-04-10 devnull .IR d -th
362 cfa37a7b 2004-04-10 devnull left parenthesis.
365 cfa37a7b 2004-04-10 devnull is followed immediately by a
369 cfa37a7b 2004-04-10 devnull .BR s2/x/y/ ,
371 cfa37a7b 2004-04-10 devnull .IR n -th
372 cfa37a7b 2004-04-10 devnull match in the range is substituted.
374 cfa37a7b 2004-04-10 devnull command is followed by a
377 cfa37a7b 2004-04-10 devnull .BR s/x/y/g ,
378 cfa37a7b 2004-04-10 devnull all matches in the range
379 cfa37a7b 2004-04-10 devnull are substituted.
381 cfa37a7b 2004-04-10 devnull .BI m " a1
385 cfa37a7b 2004-04-10 devnull .BI t " a1
387 cfa37a7b 2004-04-10 devnull .RB ( m )
389 cfa37a7b 2004-04-10 devnull .RB ( t )
390 cfa37a7b 2004-04-10 devnull the range to after
391 cfa37a7b 2004-04-10 devnull .IR a1 .
392 cfa37a7b 2004-04-10 devnull Set dot.
393 cfa37a7b 2004-04-10 devnull .SS Display commands
397 cfa37a7b 2004-04-10 devnull Print the text in the range.
398 cfa37a7b 2004-04-10 devnull Set dot.
401 cfa37a7b 2004-04-10 devnull Print the line address and character address of the range.
404 cfa37a7b 2004-04-10 devnull Print just the character address of the range.
406 cfa37a7b 2004-04-10 devnull .SS File commands
409 cfa37a7b 2004-04-10 devnull .BI \*ab " file-list
410 cfa37a7b 2004-04-10 devnull Set the current file to the first file named in the list
413 cfa37a7b 2004-04-10 devnull also has in its menu.
414 cfa37a7b 2004-04-10 devnull The list may be expressed
415 cfa37a7b 2004-04-10 devnull .BI < "Plan 9 command"
416 cfa37a7b 2004-04-10 devnull in which case the file names are taken as words (in the shell sense)
417 cfa37a7b 2004-04-10 devnull generated by the Plan 9 command.
419 cfa37a7b 2004-04-10 devnull .BI \*aB " file-list
422 cfa37a7b 2004-04-10 devnull except that file names not in the menu are entered there,
423 cfa37a7b 2004-04-10 devnull and all file names in the list are examined.
426 cfa37a7b 2004-04-10 devnull Print a menu of files.
427 cfa37a7b 2004-04-10 devnull The format is:
430 cfa37a7b 2004-04-10 devnull .BR ' " or blank
431 cfa37a7b 2004-04-10 devnull indicating the file is modified or clean,
433 cfa37a7b 2004-04-10 devnull .BR - " or \&" +
434 cfa37a7b 2004-04-10 devnull indicating the file is unread or has been read
435 cfa37a7b 2004-04-10 devnull (in the terminal,
437 cfa37a7b 2004-04-10 devnull means more than one window is open),
439 cfa37a7b 2004-04-10 devnull .BR . " or blank
440 cfa37a7b 2004-04-10 devnull indicating the current file,
442 cfa37a7b 2004-04-10 devnull a blank,
444 cfa37a7b 2004-04-10 devnull and the file name.
447 cfa37a7b 2004-04-10 devnull .BI \*aD " file-list
448 cfa37a7b 2004-04-10 devnull Delete the named files from the menu.
449 cfa37a7b 2004-04-10 devnull If no files are named, the current file is deleted.
450 cfa37a7b 2004-04-10 devnull It is an error to
452 cfa37a7b 2004-04-10 devnull a modified file, but a subsequent
454 cfa37a7b 2004-04-10 devnull will delete such a file.
456 cfa37a7b 2004-04-10 devnull .SS I/O Commands
459 cfa37a7b 2004-04-10 devnull .BI \*ae " filename
460 cfa37a7b 2004-04-10 devnull Replace the file by the contents of the named external file.
461 cfa37a7b 2004-04-10 devnull Set dot to the beginning of the file.
463 cfa37a7b 2004-04-10 devnull .BI r " filename
464 cfa37a7b 2004-04-10 devnull Replace the text in the range by the contents of the named external file.
465 cfa37a7b 2004-04-10 devnull Set dot.
467 cfa37a7b 2004-04-10 devnull .BI w " filename
468 cfa37a7b 2004-04-10 devnull Write the range (default
469 cfa37a7b 2004-04-10 devnull .BR 0,$ )
470 cfa37a7b 2004-04-10 devnull to the named external file.
472 cfa37a7b 2004-04-10 devnull .BI \*af " filename
473 cfa37a7b 2004-04-10 devnull Set the file name and print the resulting menu entry.
475 cfa37a7b 2004-04-10 devnull If the file name is absent from any of these, the current file name is used.
477 cfa37a7b 2004-04-10 devnull always sets the file name;
481 cfa37a7b 2004-04-10 devnull do so if the file has no name.
483 cfa37a7b 2004-04-10 devnull .BI < " Plan 9-command
484 cfa37a7b 2004-04-10 devnull Replace the range by the standard output of the
485 cfa37a7b 2004-04-10 devnull Plan 9 command.
487 cfa37a7b 2004-04-10 devnull .BI > " Plan 9-command
488 cfa37a7b 2004-04-10 devnull Send the range to the standard input of the
489 cfa37a7b 2004-04-10 devnull Plan 9 command.
491 cfa37a7b 2004-04-10 devnull .BI | " Plan 9-command
492 cfa37a7b 2004-04-10 devnull Send the range to the standard input, and replace it by
493 cfa37a7b 2004-04-10 devnull the standard output, of the
494 cfa37a7b 2004-04-10 devnull Plan 9 command.
496 cfa37a7b 2004-04-10 devnull .BI \*a! " Plan 9-command
498 cfa37a7b 2004-04-10 devnull Plan 9 command.
500 cfa37a7b 2004-04-10 devnull .BI \*acd " directory
501 cfa37a7b 2004-04-10 devnull Change working directory.
502 cfa37a7b 2004-04-10 devnull If no directory is specified,
503 cfa37a7b 2004-04-10 devnull .B $home
504 cfa37a7b 2004-04-10 devnull is used.
507 cfa37a7b 2004-04-10 devnull In any of
514 cfa37a7b 2004-04-10 devnull .I Plan 9 command
515 cfa37a7b 2004-04-10 devnull is omitted the last
516 cfa37a7b 2004-04-10 devnull .I Plan 9 command
517 cfa37a7b 2004-04-10 devnull (of any type) is substituted.
521 cfa37a7b 2004-04-10 devnull .I downloaded
522 cfa37a7b 2004-04-10 devnull (using the mouse and raster display, i.e. not using option
523 cfa37a7b 2004-04-10 devnull .BR -d ),
525 cfa37a7b 2004-04-10 devnull sets standard input to
526 cfa37a7b 2004-04-10 devnull .BR /dev/null ,
527 cfa37a7b 2004-04-10 devnull and otherwise
528 cfa37a7b 2004-04-10 devnull unassigned output
529 cfa37a7b 2004-04-10 devnull .RB ( stdout
534 cfa37a7b 2004-04-10 devnull .B stderr
535 cfa37a7b 2004-04-10 devnull for all) is placed in
536 cfa37a7b 2004-04-10 devnull .B /tmp/sam.err
537 cfa37a7b 2004-04-10 devnull and the first few lines are printed.
538 cfa37a7b 2004-04-10 devnull .SS Loops and Conditionals
541 cfa37a7b 2004-04-10 devnull .BI x/ regexp / " command
542 cfa37a7b 2004-04-10 devnull For each match of the regular expression in the range, run the command
543 cfa37a7b 2004-04-10 devnull with dot set to the match.
544 cfa37a7b 2004-04-10 devnull Set dot to the last match.
545 cfa37a7b 2004-04-10 devnull If the regular
546 cfa37a7b 2004-04-10 devnull expression and its slashes are omitted,
547 cfa37a7b 2004-04-10 devnull .L /.*\en/
548 cfa37a7b 2004-04-10 devnull is assumed.
549 cfa37a7b 2004-04-10 devnull Null string matches potentially occur before every character
550 cfa37a7b 2004-04-10 devnull of the range and at the end of the range.
552 cfa37a7b 2004-04-10 devnull .BI y/ regexp / " command
555 cfa37a7b 2004-04-10 devnull but run the command for each substring that lies before, between,
556 cfa37a7b 2004-04-10 devnull or after
557 cfa37a7b 2004-04-10 devnull the matches that would be generated by
559 cfa37a7b 2004-04-10 devnull There is no default regular expression.
560 cfa37a7b 2004-04-10 devnull Null substrings potentially occur before every character
561 cfa37a7b 2004-04-10 devnull in the range.
563 cfa37a7b 2004-04-10 devnull .BI \*aX/ regexp / " command
564 cfa37a7b 2004-04-10 devnull For each file whose menu entry matches the regular expression,
565 cfa37a7b 2004-04-10 devnull make that the current file and
566 cfa37a7b 2004-04-10 devnull run the command.
567 cfa37a7b 2004-04-10 devnull If the expression is omitted, the command is run
568 cfa37a7b 2004-04-10 devnull in every file.
570 cfa37a7b 2004-04-10 devnull .BI \*aY/ regexp / " command
573 cfa37a7b 2004-04-10 devnull but for files that do not match the regular expression,
574 cfa37a7b 2004-04-10 devnull and the expression is required.
576 cfa37a7b 2004-04-10 devnull .BI g/ regexp / " command
580 cfa37a7b 2004-04-10 devnull .BI v/ regexp / " command
581 cfa37a7b 2004-04-10 devnull If the range contains
582 cfa37a7b 2004-04-10 devnull .RB ( g )
583 cfa37a7b 2004-04-10 devnull or does not contain
584 cfa37a7b 2004-04-10 devnull .RB ( v )
585 cfa37a7b 2004-04-10 devnull a match for the expression,
586 cfa37a7b 2004-04-10 devnull set dot to the range and run the command.
588 cfa37a7b 2004-04-10 devnull These may be nested arbitrarily deeply, but only one instance of either
592 cfa37a7b 2004-04-10 devnull may appear in a \%single command.
593 cfa37a7b 2004-04-10 devnull An empty command in an
597 cfa37a7b 2004-04-10 devnull defaults to
599 cfa37a7b 2004-04-10 devnull an empty command in
603 cfa37a7b 2004-04-10 devnull defaults to
608 cfa37a7b 2004-04-10 devnull do not have defaults.
610 cfa37a7b 2004-04-10 devnull .SS Miscellany
611 cfa37a7b 2004-04-10 devnull .TF (empty)
614 cfa37a7b 2004-04-10 devnull Set the current file's mark to the range. Does not set dot.
618 cfa37a7b 2004-04-10 devnull It is an error to quit with modified files, but a second
620 cfa37a7b 2004-04-10 devnull will succeed.
622 cfa37a7b 2004-04-10 devnull .BI \*au " n
623 cfa37a7b 2004-04-10 devnull Undo the last
625 cfa37a7b 2004-04-10 devnull (default 1)
626 cfa37a7b 2004-04-10 devnull top-level commands that changed the contents or name of the
627 cfa37a7b 2004-04-10 devnull current file, and any other file whose most recent change was simultaneous
628 cfa37a7b 2004-04-10 devnull with the current file's change.
629 cfa37a7b 2004-04-10 devnull Successive
630 cfa37a7b 2004-04-10 devnull .BR u 's
631 cfa37a7b 2004-04-10 devnull move further back in time.
632 cfa37a7b 2004-04-10 devnull The only commands for which u is ineffective are
633 cfa37a7b 2004-04-10 devnull .BR cd ,
641 cfa37a7b 2004-04-10 devnull is negative,
643 cfa37a7b 2004-04-10 devnull `redoes,' undoing the undo, going forwards in time again.
646 cfa37a7b 2004-04-10 devnull If the range is explicit, set dot to the range.
649 cfa37a7b 2004-04-10 devnull is downloaded, the resulting dot is selected on the screen;
650 cfa37a7b 2004-04-10 devnull otherwise it is printed.
651 cfa37a7b 2004-04-10 devnull If no address is specified (the
652 cfa37a7b 2004-04-10 devnull command is a newline) dot is extended in either direction to
653 cfa37a7b 2004-04-10 devnull line boundaries and printed.
654 cfa37a7b 2004-04-10 devnull If dot is thereby unchanged, it is set to
656 cfa37a7b 2004-04-10 devnull and printed.
658 cfa37a7b 2004-04-10 devnull .SS Grouping and multiple changes
659 cfa37a7b 2004-04-10 devnull Commands may be grouped by enclosing them in braces
660 cfa37a7b 2004-04-10 devnull .BR {} .
661 cfa37a7b 2004-04-10 devnull Commands within the braces must appear on separate lines (no backslashes are
662 cfa37a7b 2004-04-10 devnull required between commands).
663 cfa37a7b 2004-04-10 devnull Semantically, an opening brace is like a command:
664 cfa37a7b 2004-04-10 devnull it takes an (optional) address and sets dot for each sub-command.
665 cfa37a7b 2004-04-10 devnull Commands within the braces are executed sequentially, but changes made
666 cfa37a7b 2004-04-10 devnull by one command are not visible to other commands (see the next
667 cfa37a7b 2004-04-10 devnull paragraph).
668 cfa37a7b 2004-04-10 devnull Braces may be nested arbitrarily.
670 cfa37a7b 2004-04-10 devnull When a command makes a number of changes to a file, as in
671 cfa37a7b 2004-04-10 devnull .BR x/re/c/text/ ,
672 cfa37a7b 2004-04-10 devnull the addresses of all changes to the file are computed in the original file.
673 cfa37a7b 2004-04-10 devnull If the changes are in sequence,
674 cfa37a7b 2004-04-10 devnull they are applied to the file.
675 cfa37a7b 2004-04-10 devnull Successive insertions at the same address are catenated into a single
676 cfa37a7b 2004-04-10 devnull insertion composed of the several insertions in the order applied.
677 cfa37a7b 2004-04-10 devnull .SS The terminal
678 cfa37a7b 2004-04-10 devnull What follows refers to behavior of
680 cfa37a7b 2004-04-10 devnull when downloaded, that is, when
681 cfa37a7b 2004-04-10 devnull operating as a display editor on a raster display.
682 cfa37a7b 2004-04-10 devnull This is the default
683 cfa37a7b 2004-04-10 devnull behavior; invoking
685 cfa37a7b 2004-04-10 devnull with the
687 cfa37a7b 2004-04-10 devnull (no download) option provides access
688 cfa37a7b 2004-04-10 devnull to the command language only.
690 cfa37a7b 2004-04-10 devnull Each file may have zero or more windows open.
691 cfa37a7b 2004-04-10 devnull Each window is equivalent
692 cfa37a7b 2004-04-10 devnull and is updated simultaneously with changes in other windows on the same file.
693 cfa37a7b 2004-04-10 devnull Each window has an independent value of dot, indicated by a highlighted
694 cfa37a7b 2004-04-10 devnull substring on the display.
695 cfa37a7b 2004-04-10 devnull Dot may be in a region not within
696 cfa37a7b 2004-04-10 devnull the window.
697 cfa37a7b 2004-04-10 devnull There is usually a `current window',
698 cfa37a7b 2004-04-10 devnull marked with a dark border, to which typed text and editing
699 cfa37a7b 2004-04-10 devnull commands apply.
700 cfa37a7b 2004-04-10 devnull Text may be typed and edited as in
701 cfa37a7b 2004-04-10 devnull .IR rio (1);
702 cfa37a7b 2004-04-10 devnull also the escape key (ESC) selects (sets dot to) text typed
703 cfa37a7b 2004-04-10 devnull since the last mouse button hit.
705 cfa37a7b 2004-04-10 devnull The button 3 menu controls window operations.
706 cfa37a7b 2004-04-10 devnull The top of the menu
707 cfa37a7b 2004-04-10 devnull provides the following operators, each of which uses one or
709 cfa37a7b 2004-04-10 devnull .IR rio -like
710 cfa37a7b 2004-04-10 devnull cursors to prompt for selection of a window or sweeping
711 cfa37a7b 2004-04-10 devnull of a rectangle.
712 cfa37a7b 2004-04-10 devnull `Sweeping' a null rectangle gets a large window, disjoint
713 cfa37a7b 2004-04-10 devnull from the command window or the whole screen, depending on
714 cfa37a7b 2004-04-10 devnull where the null rectangle is.
715 cfa37a7b 2004-04-10 devnull .TF resize
718 cfa37a7b 2004-04-10 devnull Create a new, empty file.
720 cfa37a7b 2004-04-10 devnull .B zerox
721 cfa37a7b 2004-04-10 devnull Create a copy of an existing window.
723 cfa37a7b 2004-04-10 devnull .B resize
725 cfa37a7b 2004-04-10 devnull .IR rio .
727 cfa37a7b 2004-04-10 devnull .B close
728 cfa37a7b 2004-04-10 devnull Delete the window.
729 cfa37a7b 2004-04-10 devnull In the last window of a file,
730 cfa37a7b 2004-04-10 devnull .B close
731 cfa37a7b 2004-04-10 devnull is equivalent to a
733 cfa37a7b 2004-04-10 devnull for the file.
735 cfa37a7b 2004-04-10 devnull .B write
736 cfa37a7b 2004-04-10 devnull Equivalent to a
738 cfa37a7b 2004-04-10 devnull for the file.
741 cfa37a7b 2004-04-10 devnull Below these operators is a list of available files, starting with
742 cfa37a7b 2004-04-10 devnull .BR ~~sam~~ ,
743 cfa37a7b 2004-04-10 devnull the command window.
744 cfa37a7b 2004-04-10 devnull Selecting a file from the list makes the most recently
745 cfa37a7b 2004-04-10 devnull used window on that file current, unless it is already current, in which
746 cfa37a7b 2004-04-10 devnull case selections cycle through the open windows.
747 cfa37a7b 2004-04-10 devnull If no windows are open
748 cfa37a7b 2004-04-10 devnull on the file, the user is prompted to open one.
749 cfa37a7b 2004-04-10 devnull Files other than
750 cfa37a7b 2004-04-10 devnull .B ~~sam~~
751 cfa37a7b 2004-04-10 devnull are marked with one of the characters
753 cfa37a7b 2004-04-10 devnull according as zero, one, or more windows
754 cfa37a7b 2004-04-10 devnull are open on the file.
755 cfa37a7b 2004-04-10 devnull A further mark
757 cfa37a7b 2004-04-10 devnull appears on the file in the current window and
758 cfa37a7b 2004-04-10 devnull a single quote,
760 cfa37a7b 2004-04-10 devnull on a file modified since last write.
762 cfa37a7b 2004-04-10 devnull The command window, created automatically when
764 cfa37a7b 2004-04-10 devnull starts, is an ordinary window except that text typed to it
765 cfa37a7b 2004-04-10 devnull is interpreted as commands for the editor rather than passive text,
766 cfa37a7b 2004-04-10 devnull and text printed by editor commands appears in it.
767 cfa37a7b 2004-04-10 devnull The behavior is like
768 cfa37a7b 2004-04-10 devnull .IR rio ,
769 cfa37a7b 2004-04-10 devnull with an `output point' that separates commands being typed from
770 cfa37a7b 2004-04-10 devnull previous output.
771 cfa37a7b 2004-04-10 devnull Commands typed in the command window apply to the
772 cfa37a7b 2004-04-10 devnull current open file\(emthe file in the most recently
773 cfa37a7b 2004-04-10 devnull current window.
774 cfa37a7b 2004-04-10 devnull .SS Manipulating text
775 cfa37a7b 2004-04-10 devnull Button 1 changes selection, much like
776 cfa37a7b 2004-04-10 devnull .IR rio .
777 cfa37a7b 2004-04-10 devnull Pointing to a non-current window with button 1 makes it current;
778 cfa37a7b 2004-04-10 devnull within the current window, button 1 selects text, thus setting dot.
779 cfa37a7b 2004-04-10 devnull Double-clicking selects text to the boundaries of words, lines,
780 cfa37a7b 2004-04-10 devnull quoted strings or bracketed strings, depending on the text at the click.
782 cfa37a7b 2004-04-10 devnull Button 2 provides a menu of editing commands:
783 cfa37a7b 2004-04-10 devnull .TF /regexp
786 cfa37a7b 2004-04-10 devnull Delete dot and save the deleted text in the snarf buffer.
788 cfa37a7b 2004-04-10 devnull .B paste
789 cfa37a7b 2004-04-10 devnull Replace the text in dot by the contents of the snarf buffer.
791 cfa37a7b 2004-04-10 devnull .B snarf
792 cfa37a7b 2004-04-10 devnull Save the text in dot in the snarf buffer.
794 cfa37a7b 2004-04-10 devnull .B plumb
795 cfa37a7b 2004-04-10 devnull Send the text in the selection as a plumb
796 cfa37a7b 2004-04-10 devnull message. If the selection is empty,
797 cfa37a7b 2004-04-10 devnull the white-space-delimited block of text is sent as a plumb message
799 cfa37a7b 2004-04-10 devnull .B click
800 cfa37a7b 2004-04-10 devnull attribute defining where the selection lies (see
801 058b0118 2005-01-03 devnull .IR plumb (7)).
804 cfa37a7b 2004-04-10 devnull Search forward for the next occurrence of the literal text in dot.
805 cfa37a7b 2004-04-10 devnull If dot is the null string, the text in the snarf buffer is
807 cfa37a7b 2004-04-10 devnull The snarf buffer is unaffected.
809 cfa37a7b 2004-04-10 devnull .B <rio>
810 cfa37a7b 2004-04-10 devnull Exchange snarf buffers with
811 cfa37a7b 2004-04-10 devnull .IR rio .
813 cfa37a7b 2004-04-10 devnull .BI / regexp
814 cfa37a7b 2004-04-10 devnull Search forward for the next match of the last regular expression
815 cfa37a7b 2004-04-10 devnull typed in a command.
816 cfa37a7b 2004-04-10 devnull (Not in command window.)
819 cfa37a7b 2004-04-10 devnull Send the text in dot, or the snarf buffer if
820 cfa37a7b 2004-04-10 devnull dot is the null string, as if it were typed to the command window.
821 cfa37a7b 2004-04-10 devnull Saves the sent text in the snarf buffer.
822 cfa37a7b 2004-04-10 devnull (Command window only.)
824 cfa37a7b 2004-04-10 devnull .SS External communication
826 cfa37a7b 2004-04-10 devnull listens to the
828 cfa37a7b 2004-04-10 devnull plumb port.
829 cfa37a7b 2004-04-10 devnull If plumbing is not active,
830 cfa37a7b 2004-04-10 devnull on invocation
832 cfa37a7b 2004-04-10 devnull creates a named pipe
833 cfa37a7b 2004-04-10 devnull .BI /srv/sam. user
834 cfa37a7b 2004-04-10 devnull which acts as an additional source of commands. Characters written to
835 cfa37a7b 2004-04-10 devnull the named pipe are treated as if they had been typed in the command window.
838 cfa37a7b 2004-04-10 devnull is a shell-level command that causes an instance of
840 cfa37a7b 2004-04-10 devnull running on the same terminal to load the named
841 cfa37a7b 2004-04-10 devnull .IR files .
843 cfa37a7b 2004-04-10 devnull uses either plumbing or the named pipe, whichever service is available.
844 cfa37a7b 2004-04-10 devnull If plumbing is not enabled,
845 cfa37a7b 2004-04-10 devnull the option allows a line number to be specified for
846 cfa37a7b 2004-04-10 devnull the initial position to display in the last named file
847 cfa37a7b 2004-04-10 devnull (plumbing provides a more general mechanism for this ability).
850 058b0118 2005-01-03 devnull is a shell-level command that can be used as
851 058b0118 2005-01-03 devnull .B $EDITOR
852 058b0118 2005-01-03 devnull in a Unix environment.
857 c8b6342d 2005-01-13 devnull and then does not exit until
859 058b0118 2005-01-03 devnull is changed, which is taken as a signal that
861 058b0118 2005-01-03 devnull is done being edited.
862 cfa37a7b 2004-04-10 devnull .SS Abnormal termination
865 cfa37a7b 2004-04-10 devnull terminates other than by a
867 cfa37a7b 2004-04-10 devnull command (by hangup, deleting its window, etc.), modified
868 cfa37a7b 2004-04-10 devnull files are saved in an
869 cfa37a7b 2004-04-10 devnull executable file,
870 c8b6342d 2005-01-13 devnull .BR $HOME/sam.save .
871 cfa37a7b 2004-04-10 devnull This program, when executed, asks whether to write
872 cfa37a7b 2004-04-10 devnull each file back to a external file.
873 cfa37a7b 2004-04-10 devnull The answer
875 cfa37a7b 2004-04-10 devnull causes writing; anything else skips the file.
876 cfa37a7b 2004-04-10 devnull .SH FILES
877 c8b6342d 2005-01-13 devnull .TF $HOME/sam.save
879 c8b6342d 2005-01-13 devnull .B $HOME/sam.save
881 c8b6342d 2005-01-13 devnull .B $HOME/sam.err
883 c3674de4 2005-01-11 devnull .B \*9/bin/samsave
884 cfa37a7b 2004-04-10 devnull the program called to unpack
885 c8b6342d 2005-01-13 devnull .BR $HOME/sam.save .
886 cfa37a7b 2004-04-10 devnull .SH SOURCE
887 c3674de4 2005-01-11 devnull .TF \*9/src/cmd/samterm
889 c3674de4 2005-01-11 devnull .B \*9/src/cmd/sam
890 cfa37a7b 2004-04-10 devnull source for
894 c3674de4 2005-01-11 devnull .B \*9/src/cmd/samterm
895 cfa37a7b 2004-04-10 devnull source for the separate terminal part
897 c3674de4 2005-01-11 devnull .B \*9/bin/B
899 c8b6342d 2005-01-13 devnull .B \*9/bin/E
900 cfa37a7b 2004-04-10 devnull .SH SEE ALSO
901 cfa37a7b 2004-04-10 devnull .IR ed (1),
902 cfa37a7b 2004-04-10 devnull .IR sed (1),
903 cfa37a7b 2004-04-10 devnull .IR grep (1),
904 cfa37a7b 2004-04-10 devnull .IR rio (1),
905 058b0118 2005-01-03 devnull .IR regexp (7).
907 cfa37a7b 2004-04-10 devnull Rob Pike,
908 cfa37a7b 2004-04-10 devnull ``The text editor sam''.