BSD 1 development
[unix-history] / exrefm / exrefm7.n
CommitLineData
2fd0a8e1
BJ
1.if !\n(xx .so tmac.e
2.LC
3.nf
4( \fB.\fR , \fB.\fR ) \fBnumber\fR \fIcount\fR \fIflags\fR
5.fi
6.HP
7The
8.I number
9command prints each specified line preceded by its buffer line
10number.
11The current line is left at the last line printed.
12.LC
13.nf
14( \fB.\fR ) \fBopen\fR \fIflags\fR
15.br
16( \fB.\fR ) \fBopen\fR /\fIpat\|\fR/ \fIflags\fR
17.HP
18The
19.I open
20command enters intraline editing mode at each addressed line.
21If
22.I pat
23is given,
24then the cursor will be placed initially at the beginning of the
25string matched by the pattern.\u\s-2\(dg\s0\d
26.FS
27\(dg The
28.I pat
29may be delimited only by `/' characters;
30the forms `\e/' and `\e&/' are also not allowed here.
31.FE
32Further lines containing
33.I pat
34may be opened using the
35.I next
36`n' operation without leaving open.
37The current line is left at the last line opened.
38See the
39.I open
40and
41.I visual
42mode description below for more details.
43.LC
44.nf
45\fBpreserve\fR
46.fi
47.HP
48The current editor buffer is saved as though the editor had just crashed.
49This command is for use only in emergencies when a
50.I write
51command has resulted in an error and you don't know how to save your work.
52After a
53.I preserve
54you should seek help immediately.
55.LC
56.nf
57( \fB.\fR , \fB.\fR )\|\fBprint\fR \fIcount\fR \fIflags\fR
58.fi
59.HP
60The
61.I print
62command prints the specified lines
63with non-printing characters normally escaped as `?'.
64The current line is left at the last line printed.
65.LC
66.nf
67( \fB.\fR )\|\fBput\fR
68.fi
69.HP
70The lines removed from the editing buffer by the last command which had the
71ability to change the buffer are restored after the addressed line.
72.I Put
73can be used, e.g., after a
74.I change
75command to retrieve the lines changed away when you decide that you want
76both these and the lines you replaced them with.
77A
78.I delete
79command and a
80.I put
81command effect a
82.I move .
83Note that
84.I put
85is very similar to its
86.I open
87and
88.I visual
89mode counterpart.
90.LC
91.nf
92\fBquit\fR \fI!\fR
93.fi
94.HP
95The
96.I quit
97command causes
98.EX
99to exit.
100No automatic write of the editor buffer to a file is performed.
101However,
102.EX
103issues a warning message if the file has changed
104since the last write command was issued and it
105offers a second chance to
106.I write .
107.Ex
108will also complain if there are more files in the argument
109list.
110The variant form suppresses these complaints.
111.LC
112.nf
113( \fB.\fR ) \fBread\fR \fIfilename\fR
114.fi
115.HP
116The
117.I read
118command places a copy of the text of the given file in the
119editing buffer after the specified line.
120If no
121.I filename
122is given the current file name is used.
123The current file name is not changed unless there is none in which
124case
125.I filename
126becomes the current name.
127The sensibility restrictions for the
128.I edit
129command apply here also.
130If the file buffer is empty and there is no current name then
131.I ex
132treats this as an
133.I edit
134command.
135.IP
136Address `0' is legal for this command and causes the file to be read at
137the beginning of the buffer.
138Statistics are given as for the
139.I edit
140command when the
141.I read
142successfully terminates.
143After a
144.I read
145the current line is the last line read.
146.LC
147.nf
148\fBrecover \fIfile\fR
149.fi
150.HP
151The command
152.I recover
153may be used to retrieve the contents of the editor buffer after a system
154crash,
155editor crash,
156or a
157.I preserve
158command.
159A
160.I recover
161also occurs implicitly when the
162.B \-r
163option is specified on the command line.
164A file name should be given to
165.I recover
166unless the file of the current name is to be recovered.
167Thus a name is always required on the command line.
168A
169.I recover
170results in the removal of the saved buffer.
171The recovered buffer contents should be checked for sensibility
172and then saved.
173It is not possible to recover from errors occurring during a
174.I recover .
175.LC
176.nf
177\fBreset\fR
178.fi
179.HP
180The
181.I reset
182command restores the default settings of all numeric and
183Boolean valued options.
184.LC
185.nf
186\fBset\fR \fIparameter\fR
187.fi
188.HP
189The
190.I set
191command may be used to interrogate and to give new values to options.
192With no arguments it prints those options whose values have been
193changed from their defaults;
194with parameter
195.I all
196it prints all of the option values
197.IP
198By giving an option name followed by a `?'
199the current value of a single option may be interrogated.
200The `?' is unnecessary unless the option is Boolean valued.
201Boolean options are given values either by the form
202`set option' to set them on or
203`set nooption' to set them off;
204string and numeric options are assigned via the form
205`set option=value'.
206More than one parameter may be given to
207.I set \|;
208they are interpreted left-to-right.
209.IP
210It is also possible to interrogate the current values of the
211current and alternate file names, and the previous
212.SM UNIX
213shell escape command by supplying the parameter `%', `\(ga', or `!'
214respectively.
215.LC
216.nf
217\fBshell\fR
218.fi
219.HP
220A new
221.I shell
222is created.
223This shell is
224.I interactive ,
225like a login shell.
226When it terminates, editing resumes.
227.LC
228.nf
229\fBsource\fR \fIfile\fR
230.fi
231.HP
232The
233.I source
234command causes
235.I ex
236to read commands from the specified file.
237.I Source
238commands may be nested.
239.LC
240.nf
241( \fB.\fR , \fB.\fR ) \fBsubstitute\fR /\fIpat\fR\|/\fIrepl\fR\|/ \fIoptions\fR \fIcount\fR \fIflags\fR
242.fi
243.HP
244On each specified line, the first instance of pattern
245.I pat
246is replaced by replacement pattern
247.I repl .
248If the
249.I global
250indicator option character `g'
251appears, then all instances are substituted;
252if the
253.I confirm
254indication character `c' appears,
255then before each substitution the line to be substituted
256is typed with the string to be substituted marked
257with `\(ua' characters.
258By typing an `y' one can cause the substitution to be performed,
259otherwise no change takes place.
260After a substitute the current line is the last line substituted.
261.IP
262See the regular expression description for an explanation of metasequences
263available in
264.I repl .
265In addition to these sequences, lines may be split by substituting
266new-line characters into them.
267The newline in
268.I repl
269must be escaped by preceding it with a `\e'.
270(If the
271.I substitute
272is within a
273.I global ,
274then two escaping `\e' characters will be needed.)
275.LC
276.nf
277\fBsync\fR
278.fi
279.HP
280The
281.I sync
282command causes the contents of the editor temporary file to be
283synchronized to reflect the current state of editing.
284.I Sync
285commands are done automatically whenever there is a difference of
28615 lines or more between the in-core buffer and the temporary.
287They are as useful as
288.I write
289commands,
290and much faster,
291for those who are worried about losing work due to an editor or system crash.
292.LC
293.nf
294( \fB.\fR , \fB.\fR ) \fBtabulate\fR \fI!\fR \fIcount\fR \fIflags\fR
295.fi
296.HP
297The
298.I tabulate
299command causes leading white space to be converted to
300tabs on the specified lines.
301The variant causes this tabulation to occur throughout each line.
302The current line is left at the last line where a change occurred.
303.LC
304.nf
305( \fB.\fR , \fB.\fR ) \fBtranscribe\fR \fIaddr\fR
306.fi
307.HP
308The
309.I transcribe
310command is a synonym for
311.I copy .
312.LC
313.nf
314\fBundo \fI!\fI
315.fi
316.HP
317The
318.I undo
319command reverses the changes made in the buffer by the last
320buffer editing command.
321Note that
322.I global
323commands are considered a single command for the purpose of
324.I undo
325(as are
326.I open
327and
328.I visual.)
329Also, the commands
330.I write
331and
332.I edit
333which interact with the
334.UX
335file system cannot be undone.
336.I Undo
337is its own inverse.
338After an
339.I undo
340the current line is the first line restored
341or the line before the first line deleted if no lines were restored.
342For commands with more global effect,
343such as
344.I global
345and
346.I visual
347the current line regains it pre-command value after an
348.I undo.
349.I Undo
350always marks the previous value of the current line `\fB.\fR'
351as `\'\''.
352.LC
353.nf
354( 1 , $ ) \fBv\fR /\fIpat\fR\|/ \fIcmds\fR
355.fi
356.HP
357The
358.I v
359command is a synonym for the
360.I global
361command variant `global!'.
362.LC
363.nf
364\fBversion\fR
365.fi
366.HP
367The
368.I version
369command prints the current version number of the editor
370as well as the date the binary was created.
371.LC
372.nf
373( \fB.\fR ) \fBvisual\fR \fItype\fR \fIflags\fR
374.fi
375.HP
376The
377.I visual
378command enters \fIvisual\fR mode at the specified line.
379.I Type
380is optional and may be `+', `\-' , `\(ua' (`^') or `\fB.\fR'
381as in the
382.I z
383command to specify the placement of the specified line on the screen.
384By default, if
385.I type
386is omitted, the specified line is placed as the first on the screen.
387After a
388.I visual ,
389the current line is the last line the cursor was on when it ended.
390See the section describing
391.I visual
392and
393.I open
394for more details.
395.LC
396.nf
397( 1 , $ ) \fBwrite\fR \fI!\fR \fIfile\fR
398.br
399( 1 , $ ) \fBwrite\fR \fI!\fR >> \fIfile\fR
400.fi
401.HP
402The
403.I write
404command places data from the file buffer back into the file system.
405The first form of the command will write to a file only if it is
406the current file and is
407.I edited ,
408if the file does not exist,
409or if the file is actually a teletype,
410.B /dev/tty
411or
412.B /dev/null .
413If the file does not exist it is created.
414The current file name is changed only if there is no current file
415name.
416The current line is unchanged by this command, and feedback is given
417as to the number of lines and characters written as for the
418.I edit
419command.
420The second form is used to write the buffer contents at the end of
421an existing file.
422For both forms,
423the variant suppresses the file existence and type checks.
424.IP
425If an error occurs while writing the current and
426.I edited
427file,
428.I ex
429considers that there has been ``No write since last change''
430even if the buffer had not previously been modified.
431.LC
432.nf
433( \fB.\fR , \fB.\fR ) \fBxpand\fR \fIcount\fR \fIflags\fR
434.fi
435.HP
436The
437.I xpand
438command is a synonym for
439.I expand .
440.LC
441.nf
442( \fB.\fR , \fB.\fR )\|\fByank\fR \fIcount\fR
443.fi
444.HP
445The
446.I yank
447command causes the contents of the addressed lines to define the text
448to be placed in the buffer by a succeeding
449.I put
450command.
451The addressed lines are not affected.
452A
453.I yank
454and a
455.I put
456can be used instead of a
457.I copy
458command.
459.LC
460.nf
461( \fB.\fR ) \fBz\fR \fItype\fR \fIcount\fR
462.fi
463.HP
464The
465.I z
466command gives access to windows of text.
467The default number of logical lines in a window
468is given by the numeric
469.I window
470option
471or may be given explicitly by the
472.I count
473after the command.
474The various types and their meanings are:
475.TS
476center;
477c l.
478\fB\&.\fR window around the current line
479\- window ending at the current line
480+ window starting after the current line
481omitted window starting at the current line
482\(ua or ^ window before this window
483.TE
484In addition, the form
485\fIz\fR=
486displays a window of text with the current line in the center
487delimited by lines of `\-' characters.
488For all commands forms except
489\fIz\fR=
490the current line is left at the last line printed;
491for
492.I z=
493`\fB.\fR' addresses the bracketed line.
494.IP
495The characters `+', `^' and `\-' may be repeated for
496cumulative effect.
497On a \s-2CRT\s0 the screen is cleared before display begins unless a
498count which is less than the screen size is given.
499.LC
500.nf
501\fB!\fIcommand\fR\fR
502.fi
503.HP
504The remainder of the line after the `!' character is sent to a shell
505to be executed.
506The current line is unchanged by this command.
507Within the text of
508.I command
509the characters
510`%' and `\`' are expanded as in filenames and the character
511`!' is replaced with the text of the previous command.
512Thus, in particular,
513`!!' repeats the last such shell escape.
514If any such expansion is performed, the expanded line will be echoed.
515.IP
516If there has been ``No write'' of the buffer contents since the last
517change to the editing buffer, then a diagnostic will be produced
518before the command is executed as a warning.
519A single `!' is printed when the command completes.
520.LC
521.nf
522( $ ) \fB=\fR
523.fi
524.HP
525The `=' command prints the line number of the
526addressed line.
527The current line is unchanged.
528.LC
529.nf
530( \fB.\fR , \fB.\fR ) \fB>\fR \fIcount\fR \fIflags\fR
531.br
532( \fB.\fR , \fB.\fR ) \fB<\fR \fIcount\fR \fIflags\fR
533.fi
534.HP
535The `>' right shift and `<' left shift
536commands perform intelligent shifting on the specified lines.
537The quantity of shift is determined
538by the
539.I shiftwidth
540option and the repetition of the specification character.
541Thus `>>' causes the current line to be right shifted
542two tab stops.
543Only white space is shifted; no non-white space characters are
544discarded in a left-shift.\u\s-2\(dg\s0\d
545.FS
546\(dg White space characters are blank and tab.
547.FE
548The current line becomes the last line which changed due to the
549shifting.
550.LC
551.nf
552\s-2EOF\s0
553.fi
554.HP
555If
556.EX
557receives an end-of-file (control-d)
558from a terminal input,
559it interprets this as being a request for a scroll through the file
560and sends the next
561.I scroll
562logical lines of text,
563normally a half
564.I window .
565.LC
566.nf
567( \fB.\fR+1 ) \s-2NL\s0
568.br
569( \fB.\fR+1 ) |
570.fi
571.HP
572An address alone causes the addressed line to be printed.
573A blank line alone is thus useful for stepping through text.
574.LC
575.nf
576( \fB.\fR , \fB.\fR ) \fB:\fR \fIcount\fR \fIflags\fR
577.fi
578.HP
579The
580.I colon
581command is used to override the options
582.I number
583and
584.I list
585so as to print a line without these features while
586the options remain set.
587.LC
588.nf
589( \fB.\fR , \fB.\fR ) \fB&\fR \fIoptions\fR \fIcount\fR \fIflags\fR
590.fi
591.HP
592The
593`&'
594command repeats the previous
595.I substitute
596command.
597.LC
598.nf
599( \fB.\fR , \fB.\fR ) \fB\s+2~\s0\fR \fIoptions\fR \fIcount\fR \fIflags\fR
600.fi
601.HP
602The
603`\s+2~\s0'
604command replaces the previous regular expression with the previous
605replacement pattern from a substitution.
606.bp