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]
22 cfa37a7b 2004-04-10 devnull .SH DESCRIPTION
24 cfa37a7b 2004-04-10 devnull is a multi-file editor.
25 cfa37a7b 2004-04-10 devnull It modifies a local copy of an external file.
26 cfa37a7b 2004-04-10 devnull The copy is here called a
27 cfa37a7b 2004-04-10 devnull .IR file .
28 cfa37a7b 2004-04-10 devnull The files are listed in a menu available through mouse button 3
32 cfa37a7b 2004-04-10 devnull Each file has an associated name, usually the name of the
33 cfa37a7b 2004-04-10 devnull external file from which it was read, and a `modified' bit that indicates whether
34 cfa37a7b 2004-04-10 devnull the editor's file agrees with the external file.
35 cfa37a7b 2004-04-10 devnull The external file is not read into
36 cfa37a7b 2004-04-10 devnull the editor's file until it first becomes the current file\(emthat to
37 cfa37a7b 2004-04-10 devnull which editing commands apply\(emwhereupon its menu entry is printed.
38 cfa37a7b 2004-04-10 devnull The options are
39 cfa37a7b 2004-04-10 devnull .TF -rmachine
42 cfa37a7b 2004-04-10 devnull Do not `download' the terminal part of
43 cfa37a7b 2004-04-10 devnull .IR sam .
44 cfa37a7b 2004-04-10 devnull Editing will be done with the command language only, as in
45 cfa37a7b 2004-04-10 devnull .IR ed (1).
47 cfa37a7b 2004-04-10 devnull .BI -r " machine
48 cfa37a7b 2004-04-10 devnull Run the host part remotely
49 cfa37a7b 2004-04-10 devnull on the specified machine, the terminal part locally.
51 cfa37a7b 2004-04-10 devnull .BI -s " path
52 cfa37a7b 2004-04-10 devnull Start the host part from the specified file on the remote host.
53 cfa37a7b 2004-04-10 devnull Only meaningful with the
57 cfa37a7b 2004-04-10 devnull .BI -t " path
58 cfa37a7b 2004-04-10 devnull Start the terminal part from the specified file. Useful
59 cfa37a7b 2004-04-10 devnull for debugging.
61 cfa37a7b 2004-04-10 devnull .SS Regular expressions
62 cfa37a7b 2004-04-10 devnull Regular expressions are as in
63 058b0118 2005-01-03 devnull .IR regexp (7)
64 cfa37a7b 2004-04-10 devnull with the addition of
66 cfa37a7b 2004-04-10 devnull to represent newlines.
67 cfa37a7b 2004-04-10 devnull A regular expression may never contain a literal newline character.
68 cfa37a7b 2004-04-10 devnull The empty
69 cfa37a7b 2004-04-10 devnull regular expression stands for the last complete expression encountered.
70 cfa37a7b 2004-04-10 devnull A regular expression in
72 cfa37a7b 2004-04-10 devnull matches the longest leftmost substring formally
73 cfa37a7b 2004-04-10 devnull matched by the expression.
74 cfa37a7b 2004-04-10 devnull Searching in the reverse direction is equivalent
75 cfa37a7b 2004-04-10 devnull to searching backwards with the catenation operations reversed in
76 cfa37a7b 2004-04-10 devnull the expression.
77 cfa37a7b 2004-04-10 devnull .SS Addresses
78 cfa37a7b 2004-04-10 devnull An address identifies a substring in a file.
79 cfa37a7b 2004-04-10 devnull In the following, `character
81 cfa37a7b 2004-04-10 devnull means the null string
82 cfa37a7b 2004-04-10 devnull after the
83 cfa37a7b 2004-04-10 devnull .IR n -th
84 cfa37a7b 2004-04-10 devnull character in the file, with 1 the
85 cfa37a7b 2004-04-10 devnull first character in the file.
88 cfa37a7b 2004-04-10 devnull means the
89 cfa37a7b 2004-04-10 devnull .IR n -th
91 cfa37a7b 2004-04-10 devnull starting at the beginning of the file, of the regular expression
92 cfa37a7b 2004-04-10 devnull .LR .*\en? .
93 cfa37a7b 2004-04-10 devnull All files always have a current substring, called dot,
94 cfa37a7b 2004-04-10 devnull that is the default address.
95 cfa37a7b 2004-04-10 devnull .SS Simple Addresses
99 cfa37a7b 2004-04-10 devnull The empty string after character
102 cfa37a7b 2004-04-10 devnull is the beginning of the file.
108 cfa37a7b 2004-04-10 devnull is the beginning of the file.
110 cfa37a7b 2004-04-10 devnull .BI / regexp /
113 cfa37a7b 2004-04-10 devnull .BI ? regexp ?
114 cfa37a7b 2004-04-10 devnull The substring that matches the regular expression,
115 cfa37a7b 2004-04-10 devnull found by looking toward the end
116 cfa37a7b 2004-04-10 devnull .RB ( / )
117 cfa37a7b 2004-04-10 devnull or beginning
118 cfa37a7b 2004-04-10 devnull .RB ( ? )
119 cfa37a7b 2004-04-10 devnull of the file,
120 cfa37a7b 2004-04-10 devnull and if necessary continuing the search from the other end to the
121 cfa37a7b 2004-04-10 devnull starting point of the search.
122 cfa37a7b 2004-04-10 devnull The matched substring may straddle
123 cfa37a7b 2004-04-10 devnull the starting point.
124 cfa37a7b 2004-04-10 devnull When entering a pattern containing a literal question mark
125 cfa37a7b 2004-04-10 devnull for a backward search, the question mark should be
126 cfa37a7b 2004-04-10 devnull specified as a member of a class.
130 cfa37a7b 2004-04-10 devnull The string before the first full line.
131 cfa37a7b 2004-04-10 devnull This is not necessarily
132 cfa37a7b 2004-04-10 devnull the null string; see
139 cfa37a7b 2004-04-10 devnull The null string at the end of the file.
145 cfa37a7b 2004-04-10 devnull The mark in the file (see the
147 cfa37a7b 2004-04-10 devnull command below).
149 cfa37a7b 2004-04-10 devnull \fB"\f2regexp\fB"\f1\f1
150 cfa37a7b 2004-04-10 devnull Preceding a simple address (default
151 cfa37a7b 2004-04-10 devnull .BR . ),
152 cfa37a7b 2004-04-10 devnull refers to the address evaluated in the unique file whose menu line
153 cfa37a7b 2004-04-10 devnull matches the regular expression.
155 cfa37a7b 2004-04-10 devnull .SS Compound Addresses
156 cfa37a7b 2004-04-10 devnull In the following,
160 cfa37a7b 2004-04-10 devnull are addresses.
161 cfa37a7b 2004-04-10 devnull .TF a1+a2
163 cfa37a7b 2004-04-10 devnull .IB a1 + a2
164 cfa37a7b 2004-04-10 devnull The address
166 cfa37a7b 2004-04-10 devnull evaluated starting at the end of
167 cfa37a7b 2004-04-10 devnull .IR a1 .
169 cfa37a7b 2004-04-10 devnull .IB a1 - a2
170 cfa37a7b 2004-04-10 devnull The address
172 cfa37a7b 2004-04-10 devnull evaluated looking in the reverse direction
173 cfa37a7b 2004-04-10 devnull starting at the beginning of
174 cfa37a7b 2004-04-10 devnull .IR a1 .
176 cfa37a7b 2004-04-10 devnull .IB a1 , a2
177 cfa37a7b 2004-04-10 devnull The substring from the beginning of
179 cfa37a7b 2004-04-10 devnull to the end of
180 cfa37a7b 2004-04-10 devnull .IR a2 .
183 cfa37a7b 2004-04-10 devnull is missing,
185 cfa37a7b 2004-04-10 devnull is substituted.
188 cfa37a7b 2004-04-10 devnull is missing,
190 cfa37a7b 2004-04-10 devnull is substituted.
192 cfa37a7b 2004-04-10 devnull .IB a1 ; a2
194 cfa37a7b 2004-04-10 devnull .IB a1 , a2\f1,
195 cfa37a7b 2004-04-10 devnull but with
197 cfa37a7b 2004-04-10 devnull evaluated at the end of, and dot set to,
198 cfa37a7b 2004-04-10 devnull .IR a1 .
201 cfa37a7b 2004-04-10 devnull The operators
205 cfa37a7b 2004-04-10 devnull are high precedence, while
209 cfa37a7b 2004-04-10 devnull are low precedence.
215 cfa37a7b 2004-04-10 devnull forms, if
217 cfa37a7b 2004-04-10 devnull is a line or character address with a missing
218 cfa37a7b 2004-04-10 devnull number, the number defaults to 1.
221 cfa37a7b 2004-04-10 devnull is missing,
223 cfa37a7b 2004-04-10 devnull is substituted.
228 cfa37a7b 2004-04-10 devnull are present and distinguishable,
230 cfa37a7b 2004-04-10 devnull may be elided.
232 cfa37a7b 2004-04-10 devnull may be a regular
233 cfa37a7b 2004-04-10 devnull expression; if it is delimited by
234 cfa37a7b 2004-04-10 devnull .LR ? 's,
235 cfa37a7b 2004-04-10 devnull the effect of the
239 cfa37a7b 2004-04-10 devnull is reversed.
241 cfa37a7b 2004-04-10 devnull It is an error for a compound address to represent a malformed substring.
242 cfa37a7b 2004-04-10 devnull Some useful idioms:
243 cfa37a7b 2004-04-10 devnull .IB a1 +-
244 cfa37a7b 2004-04-10 devnull \%(\f2a1\fB-+\f1)
245 cfa37a7b 2004-04-10 devnull selects the line containing
246 cfa37a7b 2004-04-10 devnull the end (beginning) of a1.
247 cfa37a7b 2004-04-10 devnull .BI 0/ regexp /
248 cfa37a7b 2004-04-10 devnull locates the first match of the expression in the file.
249 cfa37a7b 2004-04-10 devnull (The form
251 cfa37a7b 2004-04-10 devnull sets dot unnecessarily.)
252 cfa37a7b 2004-04-10 devnull .BI ./ regexp ///
253 cfa37a7b 2004-04-10 devnull finds the second following occurrence of the expression,
255 cfa37a7b 2004-04-10 devnull .BI .,/ regexp /
256 cfa37a7b 2004-04-10 devnull extends dot.
257 cfa37a7b 2004-04-10 devnull .SS Commands
258 cfa37a7b 2004-04-10 devnull In the following, text demarcated by slashes represents text delimited
259 cfa37a7b 2004-04-10 devnull by any printable
260 cfa37a7b 2004-04-10 devnull character except alphanumerics.
261 cfa37a7b 2004-04-10 devnull Any number of
262 cfa37a7b 2004-04-10 devnull trailing delimiters may be elided, with multiple elisions then representing
263 cfa37a7b 2004-04-10 devnull null strings, but the first delimiter must always
264 cfa37a7b 2004-04-10 devnull be present.
265 cfa37a7b 2004-04-10 devnull In any delimited text,
266 cfa37a7b 2004-04-10 devnull newline may not appear literally;
268 cfa37a7b 2004-04-10 devnull may be typed for newline; and
270 cfa37a7b 2004-04-10 devnull quotes the delimiter, here
272 cfa37a7b 2004-04-10 devnull Backslash is otherwise interpreted literally, except in
274 cfa37a7b 2004-04-10 devnull commands.
276 cfa37a7b 2004-04-10 devnull Most commands may be prefixed by an address to indicate their range
277 cfa37a7b 2004-04-10 devnull of operation.
278 cfa37a7b 2004-04-10 devnull Those that may not are marked with a
281 cfa37a7b 2004-04-10 devnull If a command takes
282 cfa37a7b 2004-04-10 devnull an address and none is supplied, dot is used.
283 cfa37a7b 2004-04-10 devnull The sole exception is
286 cfa37a7b 2004-04-10 devnull command, which defaults to
287 cfa37a7b 2004-04-10 devnull .BR 0,$ .
288 cfa37a7b 2004-04-10 devnull In the description, `range' is used
289 cfa37a7b 2004-04-10 devnull to represent whatever address is supplied.
290 cfa37a7b 2004-04-10 devnull Many commands set the
291 cfa37a7b 2004-04-10 devnull value of dot as a side effect.
292 cfa37a7b 2004-04-10 devnull If so, it is always set to the `result'
293 cfa37a7b 2004-04-10 devnull of the change: the empty string for a deletion, the new text for an
294 cfa37a7b 2004-04-10 devnull insertion, etc. (but see the
298 cfa37a7b 2004-04-10 devnull commands).
300 cfa37a7b 2004-04-10 devnull .ne 1.2i
301 cfa37a7b 2004-04-10 devnull .SS Text commands
304 cfa37a7b 2004-04-10 devnull .BI a/ text /
310 cfa37a7b 2004-04-10 devnull .I lines of text
313 cfa37a7b 2004-04-10 devnull Insert the text into the file after the range.
314 cfa37a7b 2004-04-10 devnull Set dot.
326 cfa37a7b 2004-04-10 devnull replaces the text, while
329 cfa37a7b 2004-04-10 devnull .I before
330 cfa37a7b 2004-04-10 devnull the range.
333 cfa37a7b 2004-04-10 devnull Delete the text in the range.
334 cfa37a7b 2004-04-10 devnull Set dot.
336 cfa37a7b 2004-04-10 devnull .BI s/ regexp / text /
337 cfa37a7b 2004-04-10 devnull Substitute
339 cfa37a7b 2004-04-10 devnull for the first match to the regular expression in the range.
340 cfa37a7b 2004-04-10 devnull Set dot to the modified range.
343 cfa37a7b 2004-04-10 devnull the character
345 cfa37a7b 2004-04-10 devnull stands for the string
346 cfa37a7b 2004-04-10 devnull that matched the expression.
347 cfa37a7b 2004-04-10 devnull Backslash behaves as usual unless followed by
348 cfa37a7b 2004-04-10 devnull a digit:
349 cfa37a7b 2004-04-10 devnull .BI \e d
350 cfa37a7b 2004-04-10 devnull stands for the string that matched the
351 cfa37a7b 2004-04-10 devnull subexpression begun by the
352 cfa37a7b 2004-04-10 devnull .IR d -th
353 cfa37a7b 2004-04-10 devnull left parenthesis.
356 cfa37a7b 2004-04-10 devnull is followed immediately by a
360 cfa37a7b 2004-04-10 devnull .BR s2/x/y/ ,
362 cfa37a7b 2004-04-10 devnull .IR n -th
363 cfa37a7b 2004-04-10 devnull match in the range is substituted.
365 cfa37a7b 2004-04-10 devnull command is followed by a
368 cfa37a7b 2004-04-10 devnull .BR s/x/y/g ,
369 cfa37a7b 2004-04-10 devnull all matches in the range
370 cfa37a7b 2004-04-10 devnull are substituted.
372 cfa37a7b 2004-04-10 devnull .BI m " a1
376 cfa37a7b 2004-04-10 devnull .BI t " a1
378 cfa37a7b 2004-04-10 devnull .RB ( m )
380 cfa37a7b 2004-04-10 devnull .RB ( t )
381 cfa37a7b 2004-04-10 devnull the range to after
382 cfa37a7b 2004-04-10 devnull .IR a1 .
383 cfa37a7b 2004-04-10 devnull Set dot.
384 cfa37a7b 2004-04-10 devnull .SS Display commands
388 cfa37a7b 2004-04-10 devnull Print the text in the range.
389 cfa37a7b 2004-04-10 devnull Set dot.
392 cfa37a7b 2004-04-10 devnull Print the line address and character address of the range.
395 cfa37a7b 2004-04-10 devnull Print just the character address of the range.
397 cfa37a7b 2004-04-10 devnull .SS File commands
400 cfa37a7b 2004-04-10 devnull .BI \*ab " file-list
401 cfa37a7b 2004-04-10 devnull Set the current file to the first file named in the list
404 cfa37a7b 2004-04-10 devnull also has in its menu.
405 cfa37a7b 2004-04-10 devnull The list may be expressed
406 cfa37a7b 2004-04-10 devnull .BI < "Plan 9 command"
407 cfa37a7b 2004-04-10 devnull in which case the file names are taken as words (in the shell sense)
408 cfa37a7b 2004-04-10 devnull generated by the Plan 9 command.
410 cfa37a7b 2004-04-10 devnull .BI \*aB " file-list
413 cfa37a7b 2004-04-10 devnull except that file names not in the menu are entered there,
414 cfa37a7b 2004-04-10 devnull and all file names in the list are examined.
417 cfa37a7b 2004-04-10 devnull Print a menu of files.
418 cfa37a7b 2004-04-10 devnull The format is:
421 cfa37a7b 2004-04-10 devnull .BR ' " or blank
422 cfa37a7b 2004-04-10 devnull indicating the file is modified or clean,
424 cfa37a7b 2004-04-10 devnull .BR - " or \&" +
425 cfa37a7b 2004-04-10 devnull indicating the file is unread or has been read
426 cfa37a7b 2004-04-10 devnull (in the terminal,
428 cfa37a7b 2004-04-10 devnull means more than one window is open),
430 cfa37a7b 2004-04-10 devnull .BR . " or blank
431 cfa37a7b 2004-04-10 devnull indicating the current file,
433 cfa37a7b 2004-04-10 devnull a blank,
435 cfa37a7b 2004-04-10 devnull and the file name.
438 cfa37a7b 2004-04-10 devnull .BI \*aD " file-list
439 cfa37a7b 2004-04-10 devnull Delete the named files from the menu.
440 cfa37a7b 2004-04-10 devnull If no files are named, the current file is deleted.
441 cfa37a7b 2004-04-10 devnull It is an error to
443 cfa37a7b 2004-04-10 devnull a modified file, but a subsequent
445 cfa37a7b 2004-04-10 devnull will delete such a file.
447 cfa37a7b 2004-04-10 devnull .SS I/O Commands
450 cfa37a7b 2004-04-10 devnull .BI \*ae " filename
451 cfa37a7b 2004-04-10 devnull Replace the file by the contents of the named external file.
452 cfa37a7b 2004-04-10 devnull Set dot to the beginning of the file.
454 cfa37a7b 2004-04-10 devnull .BI r " filename
455 cfa37a7b 2004-04-10 devnull Replace the text in the range by the contents of the named external file.
456 cfa37a7b 2004-04-10 devnull Set dot.
458 cfa37a7b 2004-04-10 devnull .BI w " filename
459 cfa37a7b 2004-04-10 devnull Write the range (default
460 cfa37a7b 2004-04-10 devnull .BR 0,$ )
461 cfa37a7b 2004-04-10 devnull to the named external file.
463 cfa37a7b 2004-04-10 devnull .BI \*af " filename
464 cfa37a7b 2004-04-10 devnull Set the file name and print the resulting menu entry.
466 cfa37a7b 2004-04-10 devnull If the file name is absent from any of these, the current file name is used.
468 cfa37a7b 2004-04-10 devnull always sets the file name;
472 cfa37a7b 2004-04-10 devnull do so if the file has no name.
474 cfa37a7b 2004-04-10 devnull .BI < " Plan 9-command
475 cfa37a7b 2004-04-10 devnull Replace the range by the standard output of the
476 cfa37a7b 2004-04-10 devnull Plan 9 command.
478 cfa37a7b 2004-04-10 devnull .BI > " Plan 9-command
479 cfa37a7b 2004-04-10 devnull Send the range to the standard input of the
480 cfa37a7b 2004-04-10 devnull Plan 9 command.
482 cfa37a7b 2004-04-10 devnull .BI | " Plan 9-command
483 cfa37a7b 2004-04-10 devnull Send the range to the standard input, and replace it by
484 cfa37a7b 2004-04-10 devnull the standard output, of the
485 cfa37a7b 2004-04-10 devnull Plan 9 command.
487 cfa37a7b 2004-04-10 devnull .BI \*a! " Plan 9-command
489 cfa37a7b 2004-04-10 devnull Plan 9 command.
491 cfa37a7b 2004-04-10 devnull .BI \*acd " directory
492 cfa37a7b 2004-04-10 devnull Change working directory.
493 cfa37a7b 2004-04-10 devnull If no directory is specified,
494 cfa37a7b 2004-04-10 devnull .B $home
495 cfa37a7b 2004-04-10 devnull is used.
498 cfa37a7b 2004-04-10 devnull In any of
505 cfa37a7b 2004-04-10 devnull .I Plan 9 command
506 cfa37a7b 2004-04-10 devnull is omitted the last
507 cfa37a7b 2004-04-10 devnull .I Plan 9 command
508 cfa37a7b 2004-04-10 devnull (of any type) is substituted.
512 cfa37a7b 2004-04-10 devnull .I downloaded
513 cfa37a7b 2004-04-10 devnull (using the mouse and raster display, i.e. not using option
514 cfa37a7b 2004-04-10 devnull .BR -d ),
516 cfa37a7b 2004-04-10 devnull sets standard input to
517 cfa37a7b 2004-04-10 devnull .BR /dev/null ,
518 cfa37a7b 2004-04-10 devnull and otherwise
519 cfa37a7b 2004-04-10 devnull unassigned output
520 cfa37a7b 2004-04-10 devnull .RB ( stdout
525 cfa37a7b 2004-04-10 devnull .B stderr
526 cfa37a7b 2004-04-10 devnull for all) is placed in
527 cfa37a7b 2004-04-10 devnull .B /tmp/sam.err
528 cfa37a7b 2004-04-10 devnull and the first few lines are printed.
529 cfa37a7b 2004-04-10 devnull .SS Loops and Conditionals
532 cfa37a7b 2004-04-10 devnull .BI x/ regexp / " command
533 cfa37a7b 2004-04-10 devnull For each match of the regular expression in the range, run the command
534 cfa37a7b 2004-04-10 devnull with dot set to the match.
535 cfa37a7b 2004-04-10 devnull Set dot to the last match.
536 cfa37a7b 2004-04-10 devnull If the regular
537 cfa37a7b 2004-04-10 devnull expression and its slashes are omitted,
538 cfa37a7b 2004-04-10 devnull .L /.*\en/
539 cfa37a7b 2004-04-10 devnull is assumed.
540 cfa37a7b 2004-04-10 devnull Null string matches potentially occur before every character
541 cfa37a7b 2004-04-10 devnull of the range and at the end of the range.
543 cfa37a7b 2004-04-10 devnull .BI y/ regexp / " command
546 cfa37a7b 2004-04-10 devnull but run the command for each substring that lies before, between,
547 cfa37a7b 2004-04-10 devnull or after
548 cfa37a7b 2004-04-10 devnull the matches that would be generated by
550 cfa37a7b 2004-04-10 devnull There is no default regular expression.
551 cfa37a7b 2004-04-10 devnull Null substrings potentially occur before every character
552 cfa37a7b 2004-04-10 devnull in the range.
554 cfa37a7b 2004-04-10 devnull .BI \*aX/ regexp / " command
555 cfa37a7b 2004-04-10 devnull For each file whose menu entry matches the regular expression,
556 cfa37a7b 2004-04-10 devnull make that the current file and
557 cfa37a7b 2004-04-10 devnull run the command.
558 cfa37a7b 2004-04-10 devnull If the expression is omitted, the command is run
559 cfa37a7b 2004-04-10 devnull in every file.
561 cfa37a7b 2004-04-10 devnull .BI \*aY/ regexp / " command
564 cfa37a7b 2004-04-10 devnull but for files that do not match the regular expression,
565 cfa37a7b 2004-04-10 devnull and the expression is required.
567 cfa37a7b 2004-04-10 devnull .BI g/ regexp / " command
571 cfa37a7b 2004-04-10 devnull .BI v/ regexp / " command
572 cfa37a7b 2004-04-10 devnull If the range contains
573 cfa37a7b 2004-04-10 devnull .RB ( g )
574 cfa37a7b 2004-04-10 devnull or does not contain
575 cfa37a7b 2004-04-10 devnull .RB ( v )
576 cfa37a7b 2004-04-10 devnull a match for the expression,
577 cfa37a7b 2004-04-10 devnull set dot to the range and run the command.
579 cfa37a7b 2004-04-10 devnull These may be nested arbitrarily deeply, but only one instance of either
583 cfa37a7b 2004-04-10 devnull may appear in a \%single command.
584 cfa37a7b 2004-04-10 devnull An empty command in an
588 cfa37a7b 2004-04-10 devnull defaults to
590 cfa37a7b 2004-04-10 devnull an empty command in
594 cfa37a7b 2004-04-10 devnull defaults to
599 cfa37a7b 2004-04-10 devnull do not have defaults.
601 cfa37a7b 2004-04-10 devnull .SS Miscellany
602 cfa37a7b 2004-04-10 devnull .TF (empty)
605 cfa37a7b 2004-04-10 devnull Set the current file's mark to the range. Does not set dot.
609 cfa37a7b 2004-04-10 devnull It is an error to quit with modified files, but a second
611 cfa37a7b 2004-04-10 devnull will succeed.
613 cfa37a7b 2004-04-10 devnull .BI \*au " n
614 cfa37a7b 2004-04-10 devnull Undo the last
616 cfa37a7b 2004-04-10 devnull (default 1)
617 cfa37a7b 2004-04-10 devnull top-level commands that changed the contents or name of the
618 cfa37a7b 2004-04-10 devnull current file, and any other file whose most recent change was simultaneous
619 cfa37a7b 2004-04-10 devnull with the current file's change.
620 cfa37a7b 2004-04-10 devnull Successive
621 cfa37a7b 2004-04-10 devnull .BR u 's
622 cfa37a7b 2004-04-10 devnull move further back in time.
623 cfa37a7b 2004-04-10 devnull The only commands for which u is ineffective are
624 cfa37a7b 2004-04-10 devnull .BR cd ,
632 cfa37a7b 2004-04-10 devnull is negative,
634 cfa37a7b 2004-04-10 devnull `redoes,' undoing the undo, going forwards in time again.
637 cfa37a7b 2004-04-10 devnull If the range is explicit, set dot to the range.
640 cfa37a7b 2004-04-10 devnull is downloaded, the resulting dot is selected on the screen;
641 cfa37a7b 2004-04-10 devnull otherwise it is printed.
642 cfa37a7b 2004-04-10 devnull If no address is specified (the
643 cfa37a7b 2004-04-10 devnull command is a newline) dot is extended in either direction to
644 cfa37a7b 2004-04-10 devnull line boundaries and printed.
645 cfa37a7b 2004-04-10 devnull If dot is thereby unchanged, it is set to
647 cfa37a7b 2004-04-10 devnull and printed.
649 cfa37a7b 2004-04-10 devnull .SS Grouping and multiple changes
650 cfa37a7b 2004-04-10 devnull Commands may be grouped by enclosing them in braces
651 cfa37a7b 2004-04-10 devnull .BR {} .
652 cfa37a7b 2004-04-10 devnull Commands within the braces must appear on separate lines (no backslashes are
653 cfa37a7b 2004-04-10 devnull required between commands).
654 cfa37a7b 2004-04-10 devnull Semantically, an opening brace is like a command:
655 cfa37a7b 2004-04-10 devnull it takes an (optional) address and sets dot for each sub-command.
656 cfa37a7b 2004-04-10 devnull Commands within the braces are executed sequentially, but changes made
657 cfa37a7b 2004-04-10 devnull by one command are not visible to other commands (see the next
658 cfa37a7b 2004-04-10 devnull paragraph).
659 cfa37a7b 2004-04-10 devnull Braces may be nested arbitrarily.
661 cfa37a7b 2004-04-10 devnull When a command makes a number of changes to a file, as in
662 cfa37a7b 2004-04-10 devnull .BR x/re/c/text/ ,
663 cfa37a7b 2004-04-10 devnull the addresses of all changes to the file are computed in the original file.
664 cfa37a7b 2004-04-10 devnull If the changes are in sequence,
665 cfa37a7b 2004-04-10 devnull they are applied to the file.
666 cfa37a7b 2004-04-10 devnull Successive insertions at the same address are catenated into a single
667 cfa37a7b 2004-04-10 devnull insertion composed of the several insertions in the order applied.
668 cfa37a7b 2004-04-10 devnull .SS The terminal
669 cfa37a7b 2004-04-10 devnull What follows refers to behavior of
671 cfa37a7b 2004-04-10 devnull when downloaded, that is, when
672 cfa37a7b 2004-04-10 devnull operating as a display editor on a raster display.
673 cfa37a7b 2004-04-10 devnull This is the default
674 cfa37a7b 2004-04-10 devnull behavior; invoking
676 cfa37a7b 2004-04-10 devnull with the
678 cfa37a7b 2004-04-10 devnull (no download) option provides access
679 cfa37a7b 2004-04-10 devnull to the command language only.
681 cfa37a7b 2004-04-10 devnull Each file may have zero or more windows open.
682 cfa37a7b 2004-04-10 devnull Each window is equivalent
683 cfa37a7b 2004-04-10 devnull and is updated simultaneously with changes in other windows on the same file.
684 cfa37a7b 2004-04-10 devnull Each window has an independent value of dot, indicated by a highlighted
685 cfa37a7b 2004-04-10 devnull substring on the display.
686 cfa37a7b 2004-04-10 devnull Dot may be in a region not within
687 cfa37a7b 2004-04-10 devnull the window.
688 cfa37a7b 2004-04-10 devnull There is usually a `current window',
689 cfa37a7b 2004-04-10 devnull marked with a dark border, to which typed text and editing
690 cfa37a7b 2004-04-10 devnull commands apply.
691 cfa37a7b 2004-04-10 devnull Text may be typed and edited as in
692 cfa37a7b 2004-04-10 devnull .IR rio (1);
693 cfa37a7b 2004-04-10 devnull also the escape key (ESC) selects (sets dot to) text typed
694 cfa37a7b 2004-04-10 devnull since the last mouse button hit.
696 cfa37a7b 2004-04-10 devnull The button 3 menu controls window operations.
697 cfa37a7b 2004-04-10 devnull The top of the menu
698 cfa37a7b 2004-04-10 devnull provides the following operators, each of which uses one or
700 cfa37a7b 2004-04-10 devnull .IR rio -like
701 cfa37a7b 2004-04-10 devnull cursors to prompt for selection of a window or sweeping
702 cfa37a7b 2004-04-10 devnull of a rectangle.
703 cfa37a7b 2004-04-10 devnull `Sweeping' a null rectangle gets a large window, disjoint
704 cfa37a7b 2004-04-10 devnull from the command window or the whole screen, depending on
705 cfa37a7b 2004-04-10 devnull where the null rectangle is.
706 cfa37a7b 2004-04-10 devnull .TF resize
709 cfa37a7b 2004-04-10 devnull Create a new, empty file.
711 cfa37a7b 2004-04-10 devnull .B zerox
712 cfa37a7b 2004-04-10 devnull Create a copy of an existing window.
714 cfa37a7b 2004-04-10 devnull .B resize
716 cfa37a7b 2004-04-10 devnull .IR rio .
718 cfa37a7b 2004-04-10 devnull .B close
719 cfa37a7b 2004-04-10 devnull Delete the window.
720 cfa37a7b 2004-04-10 devnull In the last window of a file,
721 cfa37a7b 2004-04-10 devnull .B close
722 cfa37a7b 2004-04-10 devnull is equivalent to a
724 cfa37a7b 2004-04-10 devnull for the file.
726 cfa37a7b 2004-04-10 devnull .B write
727 cfa37a7b 2004-04-10 devnull Equivalent to a
729 cfa37a7b 2004-04-10 devnull for the file.
732 cfa37a7b 2004-04-10 devnull Below these operators is a list of available files, starting with
733 cfa37a7b 2004-04-10 devnull .BR ~~sam~~ ,
734 cfa37a7b 2004-04-10 devnull the command window.
735 cfa37a7b 2004-04-10 devnull Selecting a file from the list makes the most recently
736 cfa37a7b 2004-04-10 devnull used window on that file current, unless it is already current, in which
737 cfa37a7b 2004-04-10 devnull case selections cycle through the open windows.
738 cfa37a7b 2004-04-10 devnull If no windows are open
739 cfa37a7b 2004-04-10 devnull on the file, the user is prompted to open one.
740 cfa37a7b 2004-04-10 devnull Files other than
741 cfa37a7b 2004-04-10 devnull .B ~~sam~~
742 cfa37a7b 2004-04-10 devnull are marked with one of the characters
744 cfa37a7b 2004-04-10 devnull according as zero, one, or more windows
745 cfa37a7b 2004-04-10 devnull are open on the file.
746 cfa37a7b 2004-04-10 devnull A further mark
748 cfa37a7b 2004-04-10 devnull appears on the file in the current window and
749 cfa37a7b 2004-04-10 devnull a single quote,
751 cfa37a7b 2004-04-10 devnull on a file modified since last write.
753 cfa37a7b 2004-04-10 devnull The command window, created automatically when
755 cfa37a7b 2004-04-10 devnull starts, is an ordinary window except that text typed to it
756 cfa37a7b 2004-04-10 devnull is interpreted as commands for the editor rather than passive text,
757 cfa37a7b 2004-04-10 devnull and text printed by editor commands appears in it.
758 cfa37a7b 2004-04-10 devnull The behavior is like
759 cfa37a7b 2004-04-10 devnull .IR rio ,
760 cfa37a7b 2004-04-10 devnull with an `output point' that separates commands being typed from
761 cfa37a7b 2004-04-10 devnull previous output.
762 cfa37a7b 2004-04-10 devnull Commands typed in the command window apply to the
763 cfa37a7b 2004-04-10 devnull current open file\(emthe file in the most recently
764 cfa37a7b 2004-04-10 devnull current window.
765 cfa37a7b 2004-04-10 devnull .SS Manipulating text
766 cfa37a7b 2004-04-10 devnull Button 1 changes selection, much like
767 cfa37a7b 2004-04-10 devnull .IR rio .
768 cfa37a7b 2004-04-10 devnull Pointing to a non-current window with button 1 makes it current;
769 cfa37a7b 2004-04-10 devnull within the current window, button 1 selects text, thus setting dot.
770 cfa37a7b 2004-04-10 devnull Double-clicking selects text to the boundaries of words, lines,
771 cfa37a7b 2004-04-10 devnull quoted strings or bracketed strings, depending on the text at the click.
773 cfa37a7b 2004-04-10 devnull Button 2 provides a menu of editing commands:
774 cfa37a7b 2004-04-10 devnull .TF /regexp
777 cfa37a7b 2004-04-10 devnull Delete dot and save the deleted text in the snarf buffer.
779 cfa37a7b 2004-04-10 devnull .B paste
780 cfa37a7b 2004-04-10 devnull Replace the text in dot by the contents of the snarf buffer.
782 cfa37a7b 2004-04-10 devnull .B snarf
783 cfa37a7b 2004-04-10 devnull Save the text in dot in the snarf buffer.
785 cfa37a7b 2004-04-10 devnull .B plumb
786 cfa37a7b 2004-04-10 devnull Send the text in the selection as a plumb
787 cfa37a7b 2004-04-10 devnull message. If the selection is empty,
788 cfa37a7b 2004-04-10 devnull the white-space-delimited block of text is sent as a plumb message
790 cfa37a7b 2004-04-10 devnull .B click
791 cfa37a7b 2004-04-10 devnull attribute defining where the selection lies (see
792 058b0118 2005-01-03 devnull .IR plumb (7)).
795 cfa37a7b 2004-04-10 devnull Search forward for the next occurrence of the literal text in dot.
796 cfa37a7b 2004-04-10 devnull If dot is the null string, the text in the snarf buffer is
798 cfa37a7b 2004-04-10 devnull The snarf buffer is unaffected.
800 cfa37a7b 2004-04-10 devnull .B <rio>
801 cfa37a7b 2004-04-10 devnull Exchange snarf buffers with
802 cfa37a7b 2004-04-10 devnull .IR rio .
804 cfa37a7b 2004-04-10 devnull .BI / regexp
805 cfa37a7b 2004-04-10 devnull Search forward for the next match of the last regular expression
806 cfa37a7b 2004-04-10 devnull typed in a command.
807 cfa37a7b 2004-04-10 devnull (Not in command window.)
810 cfa37a7b 2004-04-10 devnull Send the text in dot, or the snarf buffer if
811 cfa37a7b 2004-04-10 devnull dot is the null string, as if it were typed to the command window.
812 cfa37a7b 2004-04-10 devnull Saves the sent text in the snarf buffer.
813 cfa37a7b 2004-04-10 devnull (Command window only.)
815 cfa37a7b 2004-04-10 devnull .SS External communication
817 cfa37a7b 2004-04-10 devnull listens to the
819 cfa37a7b 2004-04-10 devnull plumb port.
820 cfa37a7b 2004-04-10 devnull If plumbing is not active,
821 cfa37a7b 2004-04-10 devnull on invocation
823 cfa37a7b 2004-04-10 devnull creates a named pipe
824 cfa37a7b 2004-04-10 devnull .BI /srv/sam. user
825 cfa37a7b 2004-04-10 devnull which acts as an additional source of commands. Characters written to
826 cfa37a7b 2004-04-10 devnull the named pipe are treated as if they had been typed in the command window.
829 cfa37a7b 2004-04-10 devnull is a shell-level command that causes an instance of
831 cfa37a7b 2004-04-10 devnull running on the same terminal to load the named
832 cfa37a7b 2004-04-10 devnull .IR files .
834 cfa37a7b 2004-04-10 devnull uses either plumbing or the named pipe, whichever service is available.
835 cfa37a7b 2004-04-10 devnull If plumbing is not enabled,
836 cfa37a7b 2004-04-10 devnull the option allows a line number to be specified for
837 cfa37a7b 2004-04-10 devnull the initial position to display in the last named file
838 cfa37a7b 2004-04-10 devnull (plumbing provides a more general mechanism for this ability).
841 058b0118 2005-01-03 devnull is a shell-level command that can be used as
842 058b0118 2005-01-03 devnull .B $EDITOR
843 058b0118 2005-01-03 devnull in a Unix environment.
848 058b0118 2005-01-03 devnull and then waits to exit until
850 058b0118 2005-01-03 devnull is changed, which is taken as a signal that
852 058b0118 2005-01-03 devnull is done being edited.
853 cfa37a7b 2004-04-10 devnull .SS Abnormal termination
856 cfa37a7b 2004-04-10 devnull terminates other than by a
858 cfa37a7b 2004-04-10 devnull command (by hangup, deleting its window, etc.), modified
859 cfa37a7b 2004-04-10 devnull files are saved in an
860 cfa37a7b 2004-04-10 devnull executable file,
861 cfa37a7b 2004-04-10 devnull .BR $home/sam.save .
862 cfa37a7b 2004-04-10 devnull This program, when executed, asks whether to write
863 cfa37a7b 2004-04-10 devnull each file back to a external file.
864 cfa37a7b 2004-04-10 devnull The answer
866 cfa37a7b 2004-04-10 devnull causes writing; anything else skips the file.
867 cfa37a7b 2004-04-10 devnull .SH FILES
868 b5fdffee 2004-04-19 devnull .TF /usr/local/plan9/src/cmd/samterm
870 cfa37a7b 2004-04-10 devnull .B $home/sam.save
872 cfa37a7b 2004-04-10 devnull .B $home/sam.err
874 b5fdffee 2004-04-19 devnull .B /usr/local/plan9/bin/samsave
875 cfa37a7b 2004-04-10 devnull the program called to unpack
876 cfa37a7b 2004-04-10 devnull .BR $home/sam.save .
877 cfa37a7b 2004-04-10 devnull .SH SOURCE
878 b5fdffee 2004-04-19 devnull .TF /usr/local/plan9/src/cmd/samterm
880 b5fdffee 2004-04-19 devnull .B /usr/local/plan9/src/cmd/sam
881 cfa37a7b 2004-04-10 devnull source for
885 b5fdffee 2004-04-19 devnull .B /usr/local/plan9/src/cmd/samterm
886 cfa37a7b 2004-04-10 devnull source for the separate terminal part
888 b5fdffee 2004-04-19 devnull .B /usr/local/plan9/bin/B
889 cfa37a7b 2004-04-10 devnull .SH SEE ALSO
890 cfa37a7b 2004-04-10 devnull .IR ed (1),
891 cfa37a7b 2004-04-10 devnull .IR sed (1),
892 cfa37a7b 2004-04-10 devnull .IR grep (1),
893 cfa37a7b 2004-04-10 devnull .IR rio (1),
894 058b0118 2005-01-03 devnull .IR regexp (7).
896 cfa37a7b 2004-04-10 devnull Rob Pike,
897 cfa37a7b 2004-04-10 devnull ``The text editor sam''.