2 cfa37a7b 2004-04-10 devnull .ds a \fR*\ \fP
4 cfa37a7b 2004-04-10 devnull sam, B, sam.save \- 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
21 cfa37a7b 2004-04-10 devnull .BI -nnnn
23 cfa37a7b 2004-04-10 devnull .I file ...
24 cfa37a7b 2004-04-10 devnull .SH DESCRIPTION
26 cfa37a7b 2004-04-10 devnull is a multi-file editor.
27 cfa37a7b 2004-04-10 devnull It modifies a local copy of an external file.
28 cfa37a7b 2004-04-10 devnull The copy is here called a
29 cfa37a7b 2004-04-10 devnull .IR file .
30 cfa37a7b 2004-04-10 devnull The files are listed in a menu available through mouse button 3
34 cfa37a7b 2004-04-10 devnull Each file has an associated name, usually the name of the
35 cfa37a7b 2004-04-10 devnull external file from which it was read, and a `modified' bit that indicates whether
36 cfa37a7b 2004-04-10 devnull the editor's file agrees with the external file.
37 cfa37a7b 2004-04-10 devnull The external file is not read into
38 cfa37a7b 2004-04-10 devnull the editor's file until it first becomes the current file\(emthat to
39 cfa37a7b 2004-04-10 devnull which editing commands apply\(emwhereupon its menu entry is printed.
40 cfa37a7b 2004-04-10 devnull The options are
41 cfa37a7b 2004-04-10 devnull .TF -rmachine
44 cfa37a7b 2004-04-10 devnull Do not `download' the terminal part of
45 cfa37a7b 2004-04-10 devnull .IR sam .
46 cfa37a7b 2004-04-10 devnull Editing will be done with the command language only, as in
47 cfa37a7b 2004-04-10 devnull .IR ed (1).
49 cfa37a7b 2004-04-10 devnull .BI -r " machine
50 cfa37a7b 2004-04-10 devnull Run the host part remotely
51 cfa37a7b 2004-04-10 devnull on the specified machine, the terminal part locally.
53 cfa37a7b 2004-04-10 devnull .BI -s " path
54 cfa37a7b 2004-04-10 devnull Start the host part from the specified file on the remote host.
55 cfa37a7b 2004-04-10 devnull Only meaningful with the
59 cfa37a7b 2004-04-10 devnull .BI -t " path
60 cfa37a7b 2004-04-10 devnull Start the terminal part from the specified file. Useful
61 cfa37a7b 2004-04-10 devnull for debugging.
63 cfa37a7b 2004-04-10 devnull .SS Regular expressions
64 cfa37a7b 2004-04-10 devnull Regular expressions are as in
65 cfa37a7b 2004-04-10 devnull .IR regexp (6)
66 cfa37a7b 2004-04-10 devnull with the addition of
68 cfa37a7b 2004-04-10 devnull to represent newlines.
69 cfa37a7b 2004-04-10 devnull A regular expression may never contain a literal newline character.
70 cfa37a7b 2004-04-10 devnull The empty
71 cfa37a7b 2004-04-10 devnull regular expression stands for the last complete expression encountered.
72 cfa37a7b 2004-04-10 devnull A regular expression in
74 cfa37a7b 2004-04-10 devnull matches the longest leftmost substring formally
75 cfa37a7b 2004-04-10 devnull matched by the expression.
76 cfa37a7b 2004-04-10 devnull Searching in the reverse direction is equivalent
77 cfa37a7b 2004-04-10 devnull to searching backwards with the catenation operations reversed in
78 cfa37a7b 2004-04-10 devnull the expression.
79 cfa37a7b 2004-04-10 devnull .SS Addresses
80 cfa37a7b 2004-04-10 devnull An address identifies a substring in a file.
81 cfa37a7b 2004-04-10 devnull In the following, `character
83 cfa37a7b 2004-04-10 devnull means the null string
84 cfa37a7b 2004-04-10 devnull after the
85 cfa37a7b 2004-04-10 devnull .IR n -th
86 cfa37a7b 2004-04-10 devnull character in the file, with 1 the
87 cfa37a7b 2004-04-10 devnull first character in the file.
90 cfa37a7b 2004-04-10 devnull means the
91 cfa37a7b 2004-04-10 devnull .IR n -th
93 cfa37a7b 2004-04-10 devnull starting at the beginning of the file, of the regular expression
94 cfa37a7b 2004-04-10 devnull .LR .*\en? .
95 cfa37a7b 2004-04-10 devnull All files always have a current substring, called dot,
96 cfa37a7b 2004-04-10 devnull that is the default address.
97 cfa37a7b 2004-04-10 devnull .SS Simple Addresses
101 cfa37a7b 2004-04-10 devnull The empty string after character
104 cfa37a7b 2004-04-10 devnull is the beginning of the file.
110 cfa37a7b 2004-04-10 devnull is the beginning of the file.
112 cfa37a7b 2004-04-10 devnull .BI / regexp /
115 cfa37a7b 2004-04-10 devnull .BI ? regexp ?
116 cfa37a7b 2004-04-10 devnull The substring that matches the regular expression,
117 cfa37a7b 2004-04-10 devnull found by looking toward the end
118 cfa37a7b 2004-04-10 devnull .RB ( / )
119 cfa37a7b 2004-04-10 devnull or beginning
120 cfa37a7b 2004-04-10 devnull .RB ( ? )
121 cfa37a7b 2004-04-10 devnull of the file,
122 cfa37a7b 2004-04-10 devnull and if necessary continuing the search from the other end to the
123 cfa37a7b 2004-04-10 devnull starting point of the search.
124 cfa37a7b 2004-04-10 devnull The matched substring may straddle
125 cfa37a7b 2004-04-10 devnull the starting point.
126 cfa37a7b 2004-04-10 devnull When entering a pattern containing a literal question mark
127 cfa37a7b 2004-04-10 devnull for a backward search, the question mark should be
128 cfa37a7b 2004-04-10 devnull specified as a member of a class.
132 cfa37a7b 2004-04-10 devnull The string before the first full line.
133 cfa37a7b 2004-04-10 devnull This is not necessarily
134 cfa37a7b 2004-04-10 devnull the null string; see
141 cfa37a7b 2004-04-10 devnull The null string at the end of the file.
147 cfa37a7b 2004-04-10 devnull The mark in the file (see the
149 cfa37a7b 2004-04-10 devnull command below).
151 cfa37a7b 2004-04-10 devnull \fB"\f2regexp\fB"\f1\f1
152 cfa37a7b 2004-04-10 devnull Preceding a simple address (default
153 cfa37a7b 2004-04-10 devnull .BR . ),
154 cfa37a7b 2004-04-10 devnull refers to the address evaluated in the unique file whose menu line
155 cfa37a7b 2004-04-10 devnull matches the regular expression.
157 cfa37a7b 2004-04-10 devnull .SS Compound Addresses
158 cfa37a7b 2004-04-10 devnull In the following,
162 cfa37a7b 2004-04-10 devnull are addresses.
163 cfa37a7b 2004-04-10 devnull .TF a1+a2
165 cfa37a7b 2004-04-10 devnull .IB a1 + a2
166 cfa37a7b 2004-04-10 devnull The address
168 cfa37a7b 2004-04-10 devnull evaluated starting at the end of
169 cfa37a7b 2004-04-10 devnull .IR a1 .
171 cfa37a7b 2004-04-10 devnull .IB a1 - a2
172 cfa37a7b 2004-04-10 devnull The address
174 cfa37a7b 2004-04-10 devnull evaluated looking in the reverse direction
175 cfa37a7b 2004-04-10 devnull starting at the beginning 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 substring from the beginning of
181 cfa37a7b 2004-04-10 devnull to the end of
182 cfa37a7b 2004-04-10 devnull .IR a2 .
185 cfa37a7b 2004-04-10 devnull is missing,
187 cfa37a7b 2004-04-10 devnull is substituted.
190 cfa37a7b 2004-04-10 devnull is missing,
192 cfa37a7b 2004-04-10 devnull is substituted.
194 cfa37a7b 2004-04-10 devnull .IB a1 ; a2
196 cfa37a7b 2004-04-10 devnull .IB a1 , a2\f1,
197 cfa37a7b 2004-04-10 devnull but with
199 cfa37a7b 2004-04-10 devnull evaluated at the end of, and dot set to,
200 cfa37a7b 2004-04-10 devnull .IR a1 .
203 cfa37a7b 2004-04-10 devnull The operators
207 cfa37a7b 2004-04-10 devnull are high precedence, while
211 cfa37a7b 2004-04-10 devnull are low precedence.
217 cfa37a7b 2004-04-10 devnull forms, if
219 cfa37a7b 2004-04-10 devnull is a line or character address with a missing
220 cfa37a7b 2004-04-10 devnull number, the number defaults to 1.
223 cfa37a7b 2004-04-10 devnull is missing,
225 cfa37a7b 2004-04-10 devnull is substituted.
230 cfa37a7b 2004-04-10 devnull are present and distinguishable,
232 cfa37a7b 2004-04-10 devnull may be elided.
234 cfa37a7b 2004-04-10 devnull may be a regular
235 cfa37a7b 2004-04-10 devnull expression; if it is delimited by
236 cfa37a7b 2004-04-10 devnull .LR ? 's,
237 cfa37a7b 2004-04-10 devnull the effect of the
241 cfa37a7b 2004-04-10 devnull is reversed.
243 cfa37a7b 2004-04-10 devnull It is an error for a compound address to represent a malformed substring.
244 cfa37a7b 2004-04-10 devnull Some useful idioms:
245 cfa37a7b 2004-04-10 devnull .IB a1 +-
246 cfa37a7b 2004-04-10 devnull \%(\f2a1\fB-+\f1)
247 cfa37a7b 2004-04-10 devnull selects the line containing
248 cfa37a7b 2004-04-10 devnull the end (beginning) of a1.
249 cfa37a7b 2004-04-10 devnull .BI 0/ regexp /
250 cfa37a7b 2004-04-10 devnull locates the first match of the expression in the file.
251 cfa37a7b 2004-04-10 devnull (The form
253 cfa37a7b 2004-04-10 devnull sets dot unnecessarily.)
254 cfa37a7b 2004-04-10 devnull .BI ./ regexp ///
255 cfa37a7b 2004-04-10 devnull finds the second following occurrence of the expression,
257 cfa37a7b 2004-04-10 devnull .BI .,/ regexp /
258 cfa37a7b 2004-04-10 devnull extends dot.
259 cfa37a7b 2004-04-10 devnull .SS Commands
260 cfa37a7b 2004-04-10 devnull In the following, text demarcated by slashes represents text delimited
261 cfa37a7b 2004-04-10 devnull by any printable
262 cfa37a7b 2004-04-10 devnull character except alphanumerics.
263 cfa37a7b 2004-04-10 devnull Any number of
264 cfa37a7b 2004-04-10 devnull trailing delimiters may be elided, with multiple elisions then representing
265 cfa37a7b 2004-04-10 devnull null strings, but the first delimiter must always
266 cfa37a7b 2004-04-10 devnull be present.
267 cfa37a7b 2004-04-10 devnull In any delimited text,
268 cfa37a7b 2004-04-10 devnull newline may not appear literally;
270 cfa37a7b 2004-04-10 devnull may be typed for newline; and
272 cfa37a7b 2004-04-10 devnull quotes the delimiter, here
274 cfa37a7b 2004-04-10 devnull Backslash is otherwise interpreted literally, except in
276 cfa37a7b 2004-04-10 devnull commands.
278 cfa37a7b 2004-04-10 devnull Most commands may be prefixed by an address to indicate their range
279 cfa37a7b 2004-04-10 devnull of operation.
280 cfa37a7b 2004-04-10 devnull Those that may not are marked with a
283 cfa37a7b 2004-04-10 devnull If a command takes
284 cfa37a7b 2004-04-10 devnull an address and none is supplied, dot is used.
285 cfa37a7b 2004-04-10 devnull The sole exception is
288 cfa37a7b 2004-04-10 devnull command, which defaults to
289 cfa37a7b 2004-04-10 devnull .BR 0,$ .
290 cfa37a7b 2004-04-10 devnull In the description, `range' is used
291 cfa37a7b 2004-04-10 devnull to represent whatever address is supplied.
292 cfa37a7b 2004-04-10 devnull Many commands set the
293 cfa37a7b 2004-04-10 devnull value of dot as a side effect.
294 cfa37a7b 2004-04-10 devnull If so, it is always set to the `result'
295 cfa37a7b 2004-04-10 devnull of the change: the empty string for a deletion, the new text for an
296 cfa37a7b 2004-04-10 devnull insertion, etc. (but see the
300 cfa37a7b 2004-04-10 devnull commands).
302 cfa37a7b 2004-04-10 devnull .ne 1.2i
303 cfa37a7b 2004-04-10 devnull .SS Text commands
306 cfa37a7b 2004-04-10 devnull .BI a/ text /
312 cfa37a7b 2004-04-10 devnull .I lines of text
315 cfa37a7b 2004-04-10 devnull Insert the text into the file after the range.
316 cfa37a7b 2004-04-10 devnull Set dot.
328 cfa37a7b 2004-04-10 devnull replaces the text, while
331 cfa37a7b 2004-04-10 devnull .I before
332 cfa37a7b 2004-04-10 devnull the range.
335 cfa37a7b 2004-04-10 devnull Delete the text in the range.
336 cfa37a7b 2004-04-10 devnull Set dot.
338 cfa37a7b 2004-04-10 devnull .BI s/ regexp / text /
339 cfa37a7b 2004-04-10 devnull Substitute
341 cfa37a7b 2004-04-10 devnull for the first match to the regular expression in the range.
342 cfa37a7b 2004-04-10 devnull Set dot to the modified range.
345 cfa37a7b 2004-04-10 devnull the character
347 cfa37a7b 2004-04-10 devnull stands for the string
348 cfa37a7b 2004-04-10 devnull that matched the expression.
349 cfa37a7b 2004-04-10 devnull Backslash behaves as usual unless followed by
350 cfa37a7b 2004-04-10 devnull a digit:
351 cfa37a7b 2004-04-10 devnull .BI \e d
352 cfa37a7b 2004-04-10 devnull stands for the string that matched the
353 cfa37a7b 2004-04-10 devnull subexpression begun by the
354 cfa37a7b 2004-04-10 devnull .IR d -th
355 cfa37a7b 2004-04-10 devnull left parenthesis.
358 cfa37a7b 2004-04-10 devnull is followed immediately by a
362 cfa37a7b 2004-04-10 devnull .BR s2/x/y/ ,
364 cfa37a7b 2004-04-10 devnull .IR n -th
365 cfa37a7b 2004-04-10 devnull match in the range is substituted.
367 cfa37a7b 2004-04-10 devnull command is followed by a
370 cfa37a7b 2004-04-10 devnull .BR s/x/y/g ,
371 cfa37a7b 2004-04-10 devnull all matches in the range
372 cfa37a7b 2004-04-10 devnull are substituted.
374 cfa37a7b 2004-04-10 devnull .BI m " a1
378 cfa37a7b 2004-04-10 devnull .BI t " a1
380 cfa37a7b 2004-04-10 devnull .RB ( m )
382 cfa37a7b 2004-04-10 devnull .RB ( t )
383 cfa37a7b 2004-04-10 devnull the range to after
384 cfa37a7b 2004-04-10 devnull .IR a1 .
385 cfa37a7b 2004-04-10 devnull Set dot.
386 cfa37a7b 2004-04-10 devnull .SS Display commands
390 cfa37a7b 2004-04-10 devnull Print the text in the range.
391 cfa37a7b 2004-04-10 devnull Set dot.
394 cfa37a7b 2004-04-10 devnull Print the line address and character address of the range.
397 cfa37a7b 2004-04-10 devnull Print just the character address of the range.
399 cfa37a7b 2004-04-10 devnull .SS File commands
402 cfa37a7b 2004-04-10 devnull .BI \*ab " file-list
403 cfa37a7b 2004-04-10 devnull Set the current file to the first file named in the list
406 cfa37a7b 2004-04-10 devnull also has in its menu.
407 cfa37a7b 2004-04-10 devnull The list may be expressed
408 cfa37a7b 2004-04-10 devnull .BI < "Plan 9 command"
409 cfa37a7b 2004-04-10 devnull in which case the file names are taken as words (in the shell sense)
410 cfa37a7b 2004-04-10 devnull generated by the Plan 9 command.
412 cfa37a7b 2004-04-10 devnull .BI \*aB " file-list
415 cfa37a7b 2004-04-10 devnull except that file names not in the menu are entered there,
416 cfa37a7b 2004-04-10 devnull and all file names in the list are examined.
419 cfa37a7b 2004-04-10 devnull Print a menu of files.
420 cfa37a7b 2004-04-10 devnull The format is:
423 cfa37a7b 2004-04-10 devnull .BR ' " or blank
424 cfa37a7b 2004-04-10 devnull indicating the file is modified or clean,
426 cfa37a7b 2004-04-10 devnull .BR - " or \&" +
427 cfa37a7b 2004-04-10 devnull indicating the file is unread or has been read
428 cfa37a7b 2004-04-10 devnull (in the terminal,
430 cfa37a7b 2004-04-10 devnull means more than one window is open),
432 cfa37a7b 2004-04-10 devnull .BR . " or blank
433 cfa37a7b 2004-04-10 devnull indicating the current file,
435 cfa37a7b 2004-04-10 devnull a blank,
437 cfa37a7b 2004-04-10 devnull and the file name.
440 cfa37a7b 2004-04-10 devnull .BI \*aD " file-list
441 cfa37a7b 2004-04-10 devnull Delete the named files from the menu.
442 cfa37a7b 2004-04-10 devnull If no files are named, the current file is deleted.
443 cfa37a7b 2004-04-10 devnull It is an error to
445 cfa37a7b 2004-04-10 devnull a modified file, but a subsequent
447 cfa37a7b 2004-04-10 devnull will delete such a file.
449 cfa37a7b 2004-04-10 devnull .SS I/O Commands
452 cfa37a7b 2004-04-10 devnull .BI \*ae " filename
453 cfa37a7b 2004-04-10 devnull Replace the file by the contents of the named external file.
454 cfa37a7b 2004-04-10 devnull Set dot to the beginning of the file.
456 cfa37a7b 2004-04-10 devnull .BI r " filename
457 cfa37a7b 2004-04-10 devnull Replace the text in the range by the contents of the named external file.
458 cfa37a7b 2004-04-10 devnull Set dot.
460 cfa37a7b 2004-04-10 devnull .BI w " filename
461 cfa37a7b 2004-04-10 devnull Write the range (default
462 cfa37a7b 2004-04-10 devnull .BR 0,$ )
463 cfa37a7b 2004-04-10 devnull to the named external file.
465 cfa37a7b 2004-04-10 devnull .BI \*af " filename
466 cfa37a7b 2004-04-10 devnull Set the file name and print the resulting menu entry.
468 cfa37a7b 2004-04-10 devnull If the file name is absent from any of these, the current file name is used.
470 cfa37a7b 2004-04-10 devnull always sets the file name;
474 cfa37a7b 2004-04-10 devnull do so if the file has no name.
476 cfa37a7b 2004-04-10 devnull .BI < " Plan 9-command
477 cfa37a7b 2004-04-10 devnull Replace the range by the standard output of the
478 cfa37a7b 2004-04-10 devnull Plan 9 command.
480 cfa37a7b 2004-04-10 devnull .BI > " Plan 9-command
481 cfa37a7b 2004-04-10 devnull Send the range to the standard input of the
482 cfa37a7b 2004-04-10 devnull Plan 9 command.
484 cfa37a7b 2004-04-10 devnull .BI | " Plan 9-command
485 cfa37a7b 2004-04-10 devnull Send the range to the standard input, and replace it by
486 cfa37a7b 2004-04-10 devnull the standard output, of the
487 cfa37a7b 2004-04-10 devnull Plan 9 command.
489 cfa37a7b 2004-04-10 devnull .BI \*a! " Plan 9-command
491 cfa37a7b 2004-04-10 devnull Plan 9 command.
493 cfa37a7b 2004-04-10 devnull .BI \*acd " directory
494 cfa37a7b 2004-04-10 devnull Change working directory.
495 cfa37a7b 2004-04-10 devnull If no directory is specified,
496 cfa37a7b 2004-04-10 devnull .B $home
497 cfa37a7b 2004-04-10 devnull is used.
500 cfa37a7b 2004-04-10 devnull In any of
507 cfa37a7b 2004-04-10 devnull .I Plan 9 command
508 cfa37a7b 2004-04-10 devnull is omitted the last
509 cfa37a7b 2004-04-10 devnull .I Plan 9 command
510 cfa37a7b 2004-04-10 devnull (of any type) is substituted.
514 cfa37a7b 2004-04-10 devnull .I downloaded
515 cfa37a7b 2004-04-10 devnull (using the mouse and raster display, i.e. not using option
516 cfa37a7b 2004-04-10 devnull .BR -d ),
518 cfa37a7b 2004-04-10 devnull sets standard input to
519 cfa37a7b 2004-04-10 devnull .BR /dev/null ,
520 cfa37a7b 2004-04-10 devnull and otherwise
521 cfa37a7b 2004-04-10 devnull unassigned output
522 cfa37a7b 2004-04-10 devnull .RB ( stdout
527 cfa37a7b 2004-04-10 devnull .B stderr
528 cfa37a7b 2004-04-10 devnull for all) is placed in
529 cfa37a7b 2004-04-10 devnull .B /tmp/sam.err
530 cfa37a7b 2004-04-10 devnull and the first few lines are printed.
531 cfa37a7b 2004-04-10 devnull .SS Loops and Conditionals
534 cfa37a7b 2004-04-10 devnull .BI x/ regexp / " command
535 cfa37a7b 2004-04-10 devnull For each match of the regular expression in the range, run the command
536 cfa37a7b 2004-04-10 devnull with dot set to the match.
537 cfa37a7b 2004-04-10 devnull Set dot to the last match.
538 cfa37a7b 2004-04-10 devnull If the regular
539 cfa37a7b 2004-04-10 devnull expression and its slashes are omitted,
540 cfa37a7b 2004-04-10 devnull .L /.*\en/
541 cfa37a7b 2004-04-10 devnull is assumed.
542 cfa37a7b 2004-04-10 devnull Null string matches potentially occur before every character
543 cfa37a7b 2004-04-10 devnull of the range and at the end of the range.
545 cfa37a7b 2004-04-10 devnull .BI y/ regexp / " command
548 cfa37a7b 2004-04-10 devnull but run the command for each substring that lies before, between,
549 cfa37a7b 2004-04-10 devnull or after
550 cfa37a7b 2004-04-10 devnull the matches that would be generated by
552 cfa37a7b 2004-04-10 devnull There is no default regular expression.
553 cfa37a7b 2004-04-10 devnull Null substrings potentially occur before every character
554 cfa37a7b 2004-04-10 devnull in the range.
556 cfa37a7b 2004-04-10 devnull .BI \*aX/ regexp / " command
557 cfa37a7b 2004-04-10 devnull For each file whose menu entry matches the regular expression,
558 cfa37a7b 2004-04-10 devnull make that the current file and
559 cfa37a7b 2004-04-10 devnull run the command.
560 cfa37a7b 2004-04-10 devnull If the expression is omitted, the command is run
561 cfa37a7b 2004-04-10 devnull in every file.
563 cfa37a7b 2004-04-10 devnull .BI \*aY/ regexp / " command
566 cfa37a7b 2004-04-10 devnull but for files that do not match the regular expression,
567 cfa37a7b 2004-04-10 devnull and the expression is required.
569 cfa37a7b 2004-04-10 devnull .BI g/ regexp / " command
573 cfa37a7b 2004-04-10 devnull .BI v/ regexp / " command
574 cfa37a7b 2004-04-10 devnull If the range contains
575 cfa37a7b 2004-04-10 devnull .RB ( g )
576 cfa37a7b 2004-04-10 devnull or does not contain
577 cfa37a7b 2004-04-10 devnull .RB ( v )
578 cfa37a7b 2004-04-10 devnull a match for the expression,
579 cfa37a7b 2004-04-10 devnull set dot to the range and run the command.
581 cfa37a7b 2004-04-10 devnull These may be nested arbitrarily deeply, but only one instance of either
585 cfa37a7b 2004-04-10 devnull may appear in a \%single command.
586 cfa37a7b 2004-04-10 devnull An empty command in an
590 cfa37a7b 2004-04-10 devnull defaults to
592 cfa37a7b 2004-04-10 devnull an empty command in
596 cfa37a7b 2004-04-10 devnull defaults to
601 cfa37a7b 2004-04-10 devnull do not have defaults.
603 cfa37a7b 2004-04-10 devnull .SS Miscellany
604 cfa37a7b 2004-04-10 devnull .TF (empty)
607 cfa37a7b 2004-04-10 devnull Set the current file's mark to the range. Does not set dot.
611 cfa37a7b 2004-04-10 devnull It is an error to quit with modified files, but a second
613 cfa37a7b 2004-04-10 devnull will succeed.
615 cfa37a7b 2004-04-10 devnull .BI \*au " n
616 cfa37a7b 2004-04-10 devnull Undo the last
618 cfa37a7b 2004-04-10 devnull (default 1)
619 cfa37a7b 2004-04-10 devnull top-level commands that changed the contents or name of the
620 cfa37a7b 2004-04-10 devnull current file, and any other file whose most recent change was simultaneous
621 cfa37a7b 2004-04-10 devnull with the current file's change.
622 cfa37a7b 2004-04-10 devnull Successive
623 cfa37a7b 2004-04-10 devnull .BR u 's
624 cfa37a7b 2004-04-10 devnull move further back in time.
625 cfa37a7b 2004-04-10 devnull The only commands for which u is ineffective are
626 cfa37a7b 2004-04-10 devnull .BR cd ,
634 cfa37a7b 2004-04-10 devnull is negative,
636 cfa37a7b 2004-04-10 devnull `redoes,' undoing the undo, going forwards in time again.
639 cfa37a7b 2004-04-10 devnull If the range is explicit, set dot to the range.
642 cfa37a7b 2004-04-10 devnull is downloaded, the resulting dot is selected on the screen;
643 cfa37a7b 2004-04-10 devnull otherwise it is printed.
644 cfa37a7b 2004-04-10 devnull If no address is specified (the
645 cfa37a7b 2004-04-10 devnull command is a newline) dot is extended in either direction to
646 cfa37a7b 2004-04-10 devnull line boundaries and printed.
647 cfa37a7b 2004-04-10 devnull If dot is thereby unchanged, it is set to
649 cfa37a7b 2004-04-10 devnull and printed.
651 cfa37a7b 2004-04-10 devnull .SS Grouping and multiple changes
652 cfa37a7b 2004-04-10 devnull Commands may be grouped by enclosing them in braces
653 cfa37a7b 2004-04-10 devnull .BR {} .
654 cfa37a7b 2004-04-10 devnull Commands within the braces must appear on separate lines (no backslashes are
655 cfa37a7b 2004-04-10 devnull required between commands).
656 cfa37a7b 2004-04-10 devnull Semantically, an opening brace is like a command:
657 cfa37a7b 2004-04-10 devnull it takes an (optional) address and sets dot for each sub-command.
658 cfa37a7b 2004-04-10 devnull Commands within the braces are executed sequentially, but changes made
659 cfa37a7b 2004-04-10 devnull by one command are not visible to other commands (see the next
660 cfa37a7b 2004-04-10 devnull paragraph).
661 cfa37a7b 2004-04-10 devnull Braces may be nested arbitrarily.
663 cfa37a7b 2004-04-10 devnull When a command makes a number of changes to a file, as in
664 cfa37a7b 2004-04-10 devnull .BR x/re/c/text/ ,
665 cfa37a7b 2004-04-10 devnull the addresses of all changes to the file are computed in the original file.
666 cfa37a7b 2004-04-10 devnull If the changes are in sequence,
667 cfa37a7b 2004-04-10 devnull they are applied to the file.
668 cfa37a7b 2004-04-10 devnull Successive insertions at the same address are catenated into a single
669 cfa37a7b 2004-04-10 devnull insertion composed of the several insertions in the order applied.
670 cfa37a7b 2004-04-10 devnull .SS The terminal
671 cfa37a7b 2004-04-10 devnull What follows refers to behavior of
673 cfa37a7b 2004-04-10 devnull when downloaded, that is, when
674 cfa37a7b 2004-04-10 devnull operating as a display editor on a raster display.
675 cfa37a7b 2004-04-10 devnull This is the default
676 cfa37a7b 2004-04-10 devnull behavior; invoking
678 cfa37a7b 2004-04-10 devnull with the
680 cfa37a7b 2004-04-10 devnull (no download) option provides access
681 cfa37a7b 2004-04-10 devnull to the command language only.
683 cfa37a7b 2004-04-10 devnull Each file may have zero or more windows open.
684 cfa37a7b 2004-04-10 devnull Each window is equivalent
685 cfa37a7b 2004-04-10 devnull and is updated simultaneously with changes in other windows on the same file.
686 cfa37a7b 2004-04-10 devnull Each window has an independent value of dot, indicated by a highlighted
687 cfa37a7b 2004-04-10 devnull substring on the display.
688 cfa37a7b 2004-04-10 devnull Dot may be in a region not within
689 cfa37a7b 2004-04-10 devnull the window.
690 cfa37a7b 2004-04-10 devnull There is usually a `current window',
691 cfa37a7b 2004-04-10 devnull marked with a dark border, to which typed text and editing
692 cfa37a7b 2004-04-10 devnull commands apply.
693 cfa37a7b 2004-04-10 devnull Text may be typed and edited as in
694 cfa37a7b 2004-04-10 devnull .IR rio (1);
695 cfa37a7b 2004-04-10 devnull also the escape key (ESC) selects (sets dot to) text typed
696 cfa37a7b 2004-04-10 devnull since the last mouse button hit.
698 cfa37a7b 2004-04-10 devnull The button 3 menu controls window operations.
699 cfa37a7b 2004-04-10 devnull The top of the menu
700 cfa37a7b 2004-04-10 devnull provides the following operators, each of which uses one or
702 cfa37a7b 2004-04-10 devnull .IR rio -like
703 cfa37a7b 2004-04-10 devnull cursors to prompt for selection of a window or sweeping
704 cfa37a7b 2004-04-10 devnull of a rectangle.
705 cfa37a7b 2004-04-10 devnull `Sweeping' a null rectangle gets a large window, disjoint
706 cfa37a7b 2004-04-10 devnull from the command window or the whole screen, depending on
707 cfa37a7b 2004-04-10 devnull where the null rectangle is.
708 cfa37a7b 2004-04-10 devnull .TF resize
711 cfa37a7b 2004-04-10 devnull Create a new, empty file.
713 cfa37a7b 2004-04-10 devnull .B zerox
714 cfa37a7b 2004-04-10 devnull Create a copy of an existing window.
716 cfa37a7b 2004-04-10 devnull .B resize
718 cfa37a7b 2004-04-10 devnull .IR rio .
720 cfa37a7b 2004-04-10 devnull .B close
721 cfa37a7b 2004-04-10 devnull Delete the window.
722 cfa37a7b 2004-04-10 devnull In the last window of a file,
723 cfa37a7b 2004-04-10 devnull .B close
724 cfa37a7b 2004-04-10 devnull is equivalent to a
726 cfa37a7b 2004-04-10 devnull for the file.
728 cfa37a7b 2004-04-10 devnull .B write
729 cfa37a7b 2004-04-10 devnull Equivalent to a
731 cfa37a7b 2004-04-10 devnull for the file.
734 cfa37a7b 2004-04-10 devnull Below these operators is a list of available files, starting with
735 cfa37a7b 2004-04-10 devnull .BR ~~sam~~ ,
736 cfa37a7b 2004-04-10 devnull the command window.
737 cfa37a7b 2004-04-10 devnull Selecting a file from the list makes the most recently
738 cfa37a7b 2004-04-10 devnull used window on that file current, unless it is already current, in which
739 cfa37a7b 2004-04-10 devnull case selections cycle through the open windows.
740 cfa37a7b 2004-04-10 devnull If no windows are open
741 cfa37a7b 2004-04-10 devnull on the file, the user is prompted to open one.
742 cfa37a7b 2004-04-10 devnull Files other than
743 cfa37a7b 2004-04-10 devnull .B ~~sam~~
744 cfa37a7b 2004-04-10 devnull are marked with one of the characters
746 cfa37a7b 2004-04-10 devnull according as zero, one, or more windows
747 cfa37a7b 2004-04-10 devnull are open on the file.
748 cfa37a7b 2004-04-10 devnull A further mark
750 cfa37a7b 2004-04-10 devnull appears on the file in the current window and
751 cfa37a7b 2004-04-10 devnull a single quote,
753 cfa37a7b 2004-04-10 devnull on a file modified since last write.
755 cfa37a7b 2004-04-10 devnull The command window, created automatically when
757 cfa37a7b 2004-04-10 devnull starts, is an ordinary window except that text typed to it
758 cfa37a7b 2004-04-10 devnull is interpreted as commands for the editor rather than passive text,
759 cfa37a7b 2004-04-10 devnull and text printed by editor commands appears in it.
760 cfa37a7b 2004-04-10 devnull The behavior is like
761 cfa37a7b 2004-04-10 devnull .IR rio ,
762 cfa37a7b 2004-04-10 devnull with an `output point' that separates commands being typed from
763 cfa37a7b 2004-04-10 devnull previous output.
764 cfa37a7b 2004-04-10 devnull Commands typed in the command window apply to the
765 cfa37a7b 2004-04-10 devnull current open file\(emthe file in the most recently
766 cfa37a7b 2004-04-10 devnull current window.
767 cfa37a7b 2004-04-10 devnull .SS Manipulating text
768 cfa37a7b 2004-04-10 devnull Button 1 changes selection, much like
769 cfa37a7b 2004-04-10 devnull .IR rio .
770 cfa37a7b 2004-04-10 devnull Pointing to a non-current window with button 1 makes it current;
771 cfa37a7b 2004-04-10 devnull within the current window, button 1 selects text, thus setting dot.
772 cfa37a7b 2004-04-10 devnull Double-clicking selects text to the boundaries of words, lines,
773 cfa37a7b 2004-04-10 devnull quoted strings or bracketed strings, depending on the text at the click.
775 cfa37a7b 2004-04-10 devnull Button 2 provides a menu of editing commands:
776 cfa37a7b 2004-04-10 devnull .TF /regexp
779 cfa37a7b 2004-04-10 devnull Delete dot and save the deleted text in the snarf buffer.
781 cfa37a7b 2004-04-10 devnull .B paste
782 cfa37a7b 2004-04-10 devnull Replace the text in dot by the contents of the snarf buffer.
784 cfa37a7b 2004-04-10 devnull .B snarf
785 cfa37a7b 2004-04-10 devnull Save the text in dot in the snarf buffer.
787 cfa37a7b 2004-04-10 devnull .B plumb
788 cfa37a7b 2004-04-10 devnull Send the text in the selection as a plumb
789 cfa37a7b 2004-04-10 devnull message. If the selection is empty,
790 cfa37a7b 2004-04-10 devnull the white-space-delimited block of text is sent as a plumb message
792 cfa37a7b 2004-04-10 devnull .B click
793 cfa37a7b 2004-04-10 devnull attribute defining where the selection lies (see
794 cfa37a7b 2004-04-10 devnull .IR plumb (6)).
797 cfa37a7b 2004-04-10 devnull Search forward for the next occurrence of the literal text in dot.
798 cfa37a7b 2004-04-10 devnull If dot is the null string, the text in the snarf buffer is
800 cfa37a7b 2004-04-10 devnull The snarf buffer is unaffected.
802 cfa37a7b 2004-04-10 devnull .B <rio>
803 cfa37a7b 2004-04-10 devnull Exchange snarf buffers with
804 cfa37a7b 2004-04-10 devnull .IR rio .
806 cfa37a7b 2004-04-10 devnull .BI / regexp
807 cfa37a7b 2004-04-10 devnull Search forward for the next match of the last regular expression
808 cfa37a7b 2004-04-10 devnull typed in a command.
809 cfa37a7b 2004-04-10 devnull (Not in command window.)
812 cfa37a7b 2004-04-10 devnull Send the text in dot, or the snarf buffer if
813 cfa37a7b 2004-04-10 devnull dot is the null string, as if it were typed to the command window.
814 cfa37a7b 2004-04-10 devnull Saves the sent text in the snarf buffer.
815 cfa37a7b 2004-04-10 devnull (Command window only.)
817 cfa37a7b 2004-04-10 devnull .SS External communication
819 cfa37a7b 2004-04-10 devnull listens to the
821 cfa37a7b 2004-04-10 devnull plumb port.
822 cfa37a7b 2004-04-10 devnull If plumbing is not active,
823 cfa37a7b 2004-04-10 devnull on invocation
825 cfa37a7b 2004-04-10 devnull creates a named pipe
826 cfa37a7b 2004-04-10 devnull .BI /srv/sam. user
827 cfa37a7b 2004-04-10 devnull which acts as an additional source of commands. Characters written to
828 cfa37a7b 2004-04-10 devnull the named pipe are treated as if they had been typed in the command window.
831 cfa37a7b 2004-04-10 devnull is a shell-level command that causes an instance of
833 cfa37a7b 2004-04-10 devnull running on the same terminal to load the named
834 cfa37a7b 2004-04-10 devnull .IR files .
836 cfa37a7b 2004-04-10 devnull uses either plumbing or the named pipe, whichever service is available.
837 cfa37a7b 2004-04-10 devnull If plumbing is not enabled,
838 cfa37a7b 2004-04-10 devnull the option allows a line number to be specified for
839 cfa37a7b 2004-04-10 devnull the initial position to display in the last named file
840 cfa37a7b 2004-04-10 devnull (plumbing provides a more general mechanism for this ability).
841 cfa37a7b 2004-04-10 devnull .SS Abnormal termination
844 cfa37a7b 2004-04-10 devnull terminates other than by a
846 cfa37a7b 2004-04-10 devnull command (by hangup, deleting its window, etc.), modified
847 cfa37a7b 2004-04-10 devnull files are saved in an
848 cfa37a7b 2004-04-10 devnull executable file,
849 cfa37a7b 2004-04-10 devnull .BR $home/sam.save .
850 cfa37a7b 2004-04-10 devnull This program, when executed, asks whether to write
851 cfa37a7b 2004-04-10 devnull each file back to a external file.
852 cfa37a7b 2004-04-10 devnull The answer
854 cfa37a7b 2004-04-10 devnull causes writing; anything else skips the file.
855 cfa37a7b 2004-04-10 devnull .SH FILES
856 b5fdffee 2004-04-19 devnull .TF /usr/local/plan9/src/cmd/samterm
858 cfa37a7b 2004-04-10 devnull .B $home/sam.save
860 cfa37a7b 2004-04-10 devnull .B $home/sam.err
862 b5fdffee 2004-04-19 devnull .B /usr/local/plan9/bin/samsave
863 cfa37a7b 2004-04-10 devnull the program called to unpack
864 cfa37a7b 2004-04-10 devnull .BR $home/sam.save .
865 cfa37a7b 2004-04-10 devnull .SH SOURCE
866 b5fdffee 2004-04-19 devnull .TF /usr/local/plan9/src/cmd/samterm
868 b5fdffee 2004-04-19 devnull .B /usr/local/plan9/src/cmd/sam
869 cfa37a7b 2004-04-10 devnull source for
873 b5fdffee 2004-04-19 devnull .B /usr/local/plan9/src/cmd/samterm
874 cfa37a7b 2004-04-10 devnull source for the separate terminal part
876 b5fdffee 2004-04-19 devnull .B /usr/local/plan9/bin/B
877 cfa37a7b 2004-04-10 devnull .SH SEE ALSO
878 cfa37a7b 2004-04-10 devnull .IR ed (1),
879 cfa37a7b 2004-04-10 devnull .IR sed (1),
880 cfa37a7b 2004-04-10 devnull .IR grep (1),
881 cfa37a7b 2004-04-10 devnull .IR rio (1),
882 cfa37a7b 2004-04-10 devnull .IR regexp (6).
884 cfa37a7b 2004-04-10 devnull Rob Pike,
885 cfa37a7b 2004-04-10 devnull ``The text editor sam''.