BSD 2 development
[unix-history] / doc / ex / ex.rm
CommitLineData
47d38f87
BJ
1.de ZP
2.nr pd \\n()P
3.nr )P 0
4.if \\n(.$=0 .IP
5.if \\n(.$=1 .IP "\\$1"
6.if \\n(.$>=2 .IP "\\$1" "\\$2"
7.nr )P \\n(pd
8.rm pd
9..
10.de LC
11.br
12.sp .1i
13.ne 4
14.LP
15.ta 4.0i
16..
17.bd S B 3
18.RP
19.TL
20Ex Reference Manual
21.br
22Version 2.0 \- April, 1979
23.AU
24William Joy*
25.AI
26Computer Science Division
27Department of Electrical Engineering and Computer Science
28University of California, Berkeley
29Berkeley, Ca. 94720
30.AB
31.I Ex
32a line oriented text editor, which supports both command and display
33oriented editing.
34This reference manual describes the command oriented part of
35.I ex;
36the display editing features of
37.I ex
38are described in
39.I "An Introduction to Display Editing with Vi."
40Other documents about the editor include the introduction
41.I "Edit: A tutorial",
42the
43.I "Ex/edit Command Summary",
44and a
45.I "Vi Quick Reference"
46card.
47.AE
48.NH 1
49Starting ex
50.PP
51.FS
52* The financial support of an \s-2IBM\s0 Graduate Fellowship and the National
53Science Foundation under grants MCS74-07644-A03 and MCS78-07291 is gratefully
54acknowledged.
55.FE
56Each instance of the editor has a set of options,
57which can be set to tailor it to your liking.
58The command
59.I edit
60invokes a version of
61.I ex
62designed for more casual or beginning
63users by changing the default settings of some of these options.
64To simplify the description which follows we
65assume the default settings of the options.
66.PP
67When invoked,
68.I ex
69determines the terminal type from the \s-2TERM\s0 variable in the environment.
70If there is a file
71.I \&.exrc
72in your \s-2HOME\s0 directory
73.I ex
74reads commands from that file, simulating a
75.I source
76command.
77Options setting commands placed in
78.I \&.exrc
79will be executed before each editor session.
80.PP
81A command to enter
82.I ex
83has the following prototype:\(dg
84.FS
85\(dg Brackets `[' `]' surround optional parameters here.
86.FE
87.DS
88\fBex\fR [ \fB\-\fR ] [ \fB\-v\fR ] [ \fB\-t\fR \fItag\fR ] [ \fB\-r\fR ] [ \fB+\fIlineno\fR ] name ...
89.DE
90The most common case edits a single file with no options, i.e.:
91.DS
92\fBex\fR name
93.DE
94The
95.B \-
96command line option
97option suppresses all interactive-user feedback
98and is useful in processing editor scripts in command files.
99The
100.B \-v
101option is equivalent to using
102.I vi
103rather than
104.I ex.
105The
106.B \-t
107option is equivalent to an initial
108.I tag
109command, editing the file containing the
110.I tag
111and positioning the editor at its definition.
112The
113.B \-r
114option is used in recovering after an editor or system crash,
115retrieving the last saved version of the named file or,
116if no file is specified,
117typing a list of saved files.
118.I Name
119arguments indicate files to be edited.
120An argument of the form
121\fB+\fIlineno\fR
122indicates that the editor should begin at the specified line in the first
123file rather than at the last line.
124.NH 1
125File manipulation
126.NH 2
127Current file
128.PP
129.I Ex
130is normally editing the contents of a single file,
131whose name is recorded in the
132.I current
133file name.
134.I Ex
135performs all editing actions in a buffer
136(actually a temporary file)
137into which the text of the file is initially read.
138Changes made to the buffer have no effect on the file being
139edited unless and until the buffer contents are written out to the
140file with a
141.I write
142command.
143After the buffer contents are written,
144the previous contents of the written file are no longer accessible.
145When a file is edited,
146its name becomes the current file name,
147and its contents are read into the buffer.
148.PP
149The current file is almost always considered to be
150.I edited.
151This means that the contents of the buffer are logically
152connected with the current file name,
153so that writing the current buffer contents onto that file,
154even if it exists,
155is a reasonable action.
156If the current file is not
157.I edited
158then
159.I ex
160will not normally write on it if it already exists.*
161.FS
162* The
163.I file
164command will say ``[Not edited]'' if the current file is not considered
165edited.
166.FE
167.NH 2
168Alternate file
169.PP
170Each time a new value is given to the current file name,
171the previous current file name is saved as the
172.I alternate
173file name.
174Similarly if a file is mentioned but does not become the current file,
175it is saved as the alternate file name.
176.NH 2
177Filename expansion
178.PP
179Filenames within the editor may be specified using the normal
180shell expansion conventions.
181In addition,
182the character `%' in filenames is replaced by the
183.I current
184file name and the character
185`#' by the
186.I alternate
187file name.\(dg
188.FS
189\(dg This makes it easy to deal alternately with
190two files and eliminates the need for retyping the
191name supplied on an
192.I edit
193command after a
194.I "No write since last change"
195diagnostic is received.
196.FE
197.NH 2
198Multiple files and named buffers
199.PP
200If more than one file is given on the command line,
201then the first file is edited as described above.
202The remaining arguments are placed with the first file in the
203.I "argument list."
204The current argument list may be displayed with the
205.I args
206command.
207The next file in the argument list may be edited with the
208.I next
209command.
210The argument list may also be respecified by specifying
211a list of names to the
212.I next
213command.
214These names are expanded,
215the resulting list of names becomes the new argument list,
216and
217.I ex
218edits the first file on the list.
219.PP
220For saving blocks of text while editing, and especially when editing
221more than one file,
222.I ex
223has a group of named buffers.
224These are similar to the normal buffer, except that only a limited number
225of operations are available on them.
226The buffers have names
227.I a
228through
229.I z.\(dd
230.FS
231\(dd It is also possible to refer to
232.I A
233through
234.I Z;
235the upper case buffers are the same as the lower but commands
236append to named buffers rather than replacing
237if upper case names are used.
238.FE
239.NH 1
240Exceptional Conditions
241.NH 2
242Errors and interrupts
243.PP
244When errors occur
245.I ex
246(optionally) rings the terminal bell and, in any case, prints an error
247diagnostic. If the primary input is from a file, editor processing
248will terminate. If an interrupt signal is received,
249.I ex
250prints ``Interrupt'' and returns to its command level. If the primary
251input is a file, then
252.I ex
253will exit when this occurs.
254.NH 2
255Recovering from hangups and crashes
256.PP
257If a hangup signal is received and the buffer has been modified since
258it was last written out, or if the system crashes, either the editor
259(in the first case) or the system (after it reboots in the second) will
260attempt to preserve the buffer. The next time you log in you should be
261able to recover the work you were doing, losing at most a few lines of
262changes from the last point before the hangup or editor crash. To
263recover a file you can use the
264.B \-r
265option. If you were editing the file
266.I resume,
267then you should change
268to the directory where you were when the crash occurred, giving the command
269.DS
270\fBex \-r\fI resume\fR
271.DE
272After checking that the retrieved file is indeed ok, you can
273.I write
274it over the previous contents of that file.
275.PP
276You will normally get mail from the system telling you when a file has
277been saved after a crash. The command
278.DS
279\fBex\fR \-\fBr\fR
280.DE
281will print a list of the files which have been saved for you.
282.NH 1
283Editing modes
284.PP
285.I Ex
286has five distinct modes. The primary mode is
287.I command
288mode. Commands are entered in command mode when a `:' prompt is
289present, and are executed each time a complete line is sent. In
290.I "text input"
291mode
292.I ex
293gathers input lines and places them in the file. The
294.I append,
295.I insert,
296and
297.I change
298commands use text input mode.
299No prompt is printed when you are in text input mode.
300This mode is left by typing a `.' alone at the beginning of a line, and
301.I command
302mode resumes.
303.PP
304The last three modes are
305.I open
306and
307.I visual
308modes, entered by the commands of the same name, and, within open and
309visual modes
310.I "text insertion"
311mode.
312.I Open
313and
314.I visual
315modes allow local editing operations to be performed on the text in the
316file. The
317.I open
318command displays one line at a time on any terminal while
319.I visual
320works on \s-2CRT\s0 terminals with random positioning cursors, using the
321screen as a (single) window for file editing changes.
322These modes are described (only) in
323.I "An Introduction to Display Editing with Vi."
324.NH
325Command structure
326.PP
327Most command names are English words,
328and initial prefixes of the words are acceptable abbreviations.
329The ambiguity of abbreviations is resolved in favor of the more commonly
330used commands.*
331.FS
332* As an example, the command
333.I substitute
334can be abbreviated `s'
335while the shortest available abbreviation for the
336.I set
337command is `se'.
338.FE
339.NH 2
340Command parameters
341.PP
342Most commands accept prefix addresses specifying the lines in the file
343upon which they are to have effect.
344The forms of these addresses will be discussed below.
345A number of commands also may take a trailing
346.I count
347specifying the number of lines to be involved in the command.\(dg
348.FS
349\(dg Counts are rounded down if necessary.
350.FE
351Thus the command ``10p'' will print the tenth line in the buffer while
352``delete 5'' will delete five lines from the buffer,
353starting with the current line.
354.PP
355Some commands take other information or parameters,
356this information always being given after the command name.\(dd
357.FS
358\(dd Examples would be option names in a
359.I set
360command i.e. ``set number'',
361a file name in an
362.I edit
363command,
364a regular expression in a
365.I substitute
366command,
367or a target address for a
368.I copy
369command, i.e. ``1,5 copy 25''.
370.FE
371.NH 2
372Command variants
373.PP
374A number of commands have two distinct variants.
375The variant form of the command is invoked by placing an
376`!' immediately after the command name.
377Some of the default variants may be controlled by options;
378in this case, the `!' serves to toggle the default.
379.NH 2
380Flags after commands
381.PP
382The characters `#', `p' and `l' may be placed after many commands.*
383.FS
384*
385A `p' or `l' must be preceded by a blank or tab
386except in the single special case `dp'.
387.FE
388In this case, the command abbreviated by these characters
389is executed after the command completes.
390Since
391.I ex
392normally prints the new current line after each change, `p' is rarely necessary.
393Any number of `+' or `\-' characters may also be given with these flags.
394If they appear, the specified offset is applied to the current line
395value before the printing command is executed.
396.NH 2
397Multiple commands per line
398.PP
399More than one command may be placed on a line by separating each pair
400of commands by a `|' character.
401However the
402.I global
403commands,
404and the shell escape `!'
405must be the last command on a line, as they are not terminated by a `|'.
406.NH 2
407Reporting large changes
408.PP
409Most commands which change the contents of the editor buffer give
410feedback if the scope of the change exceeds a threshold given by the
411.I report
412option.
413This feedback helps to detect undesirably large changes so that they may
414be quickly and easily reversed with an
415.I undo.
416After commands with more global effect such as
417.I global
418or
419.I visual,
420you will be informed if the net change in the number of lines
421in the buffer during this command exceeds this threshold.
422.NH 1
423Command addressing
424.NH 2
425Addressing primitives
426.IP \fB.\fR 20
427The current line.
428Most commands leave the current line as the last line which they affect.
429The default address for most commands is the current line,
430thus `\fB.\fR' is rarely used alone as an address.
431.IP \fIn\fR 20
432The \fIn\fRth line in the editor's buffer, lines being numbered
433sequentially from 1.
434.IP \fB$\fR 20
435The last line in the buffer.
436.IP \fI+n\fR\ \fI\-n\fR 20
437An offset relative to the current buffer line.\(dg
438.FS
439\(dg
440The forms `.+2' `++;2' and `++' are all equivalent;
441if the current line is line 100 they all address line 102.
442.FE
443.IP \fB/\fIpat\fR\fB/\fR\ \fB?\fIpat\fR\fB?\fR 20
444Scan forward and backward respectively for a line containing \fIpat\fR, a
445regular expression (as defined below). The scans normally wrap around the end
446of the buffer.
447If all that is desired is to print the next line containing \fIpat\fR, then
448the trailing \fB/\fR or \fB?\fR may be omitted.
449If \fIpat\fR is omitted or explicitly empty, then the last
450regular expression specified is located.\(dd
451.FS
452\(dd The forms \fB\e/\fR and \fB\e?\fR scan
453using the last regular expression used in a scan; after a substitute
454\fB//\fR and \fB??\fR would scan using the substitute's regular expression.
455.FE
456.IP \fB\(aa\(aa\fR\ \fB\(aa\fIx\fR 20
457Before each non-relative motion of the current line `\fB.\fR',
458the previous current line is marked with a tag, subsequently referred to as
459`\(aa\(aa'.
460This makes it easy to refer or return to this previous context.
461Marks may also be established by the
462.I mark
463command, using single lower case letters
464.I x
465and the marked lines referred to as
466`\(aa\fIx\fR'.
467.NH 2
468Combining addressing primitives
469.PP
470Addresses to commands consist of a series of addressing primitives,
471separated by `,' or `;'.
472Such address lists are evaluated left-to-right.
473When addresses are separated by `;' the current line `\fB.\fR'
474is set to the value of the previous addressing expression
475before the next address is interpreted.
476If more addresses are given than the command requires,
477then all but the last one or two are ignored.
478If the command takes two addresses, the first addressed line must
479precede the second in the buffer.\(dg
480.FS
481\(dg Null address specifications are permitted in a list of addresses,
482the default in this case is the current line `.';
483thus `,100' is equivalent to `\fB.\fR,100'.
484It is an error to give a prefix address to a command which expects none.
485.FE
486.NH 1
487Command descriptions
488.PP
489The following form is a prototype for all
490.I ex
491commands:
492.DS
493\fIaddress\fR \fBcommand\fR \fI! parameters count flags\fR
494.DE
495All parts are optional; the degenerate case is the empty command which prints
496the next line in the file.
497.PP
498In the following command descriptions, the
499default addresses are shown in parentheses,
500which are
501.I not,
502however,
503part of the command.
504.LC
505( \fB.\fR ) \fBappend\fR abbr: \fBa\fR
506.br
507\fItext\fR
508.br
509\&\fB.\fR
510.ZP
511Reads the input text and places it after the specified line.
512After the command, `\fB.\fR'
513addresses the last line input or the
514specified line if no lines were input.
515If address `0' is given,
516text is placed at the beginning of the buffer.
517.LC
518\fBa!\fR
519.br
520\fItext\fR
521.br
522\&\fB.\fR
523.ZP
524The variant flag to
525.I append
526toggles the setting for the
527.I autoindent
528option during the input of
529.I text.
530.LC
531\fBargs\fR
532.ZP
533The members of the argument list are printed, with the current argument
534delimited by `[' and `]'.
535...PP
536..\fBcd\fR \fIdirectory\fR
537...ZP
538..The
539...I cd
540..command is a synonym for
541...I chdir.
542.LC
543( \fB.\fR , \fB.\fR ) \fBchange\fR \fIcount\fR abbr: \fBc\fR
544.br
545\fItext\fR
546.br
547\&\fB.\fR
548.ZP
549Replaces the specified lines with the input \fItext\fR.
550The current line becomes the last line input;
551if no lines were input it is left as for a
552\fIdelete\fR.
553.LC
554\fBc!\fR
555.br
556\fItext\fR
557.br
558\&\fB.\fR
559.ZP
560The variant toggles
561.I autoindent
562during the
563.I change.
564...LC
565..\fBchdir\fR \fIdirectory\fR
566...ZP
567..The specified \fIdirectory\fR becomes the current directory.
568..If no directory is specified, the current value of the
569...I home
570..option is used as the target directory.
571..After a
572...I chdir
573..the current file is not considered to have been
574..edited so that write restrictions on pre-existing files apply.
575.LC
576( \fB.\fR , \fB.\fR )\|\fBcopy\fR \fIaddr\fR \fIflags\fR abbr: \fBco\fR
577.ZP
578A
579.I copy
580of the specified lines is placed after
581.I addr,
582which may be `0'.
583The current line
584`\fB.\fR'
585addresses the last line of the copy.
586The command
587.I t
588is a synonym for
589.I copy.
590.LC
591( \fB.\fR , \fB.\fR )\|\fBdelete\fR \fIbuffer\fR \fIcount\fR \fIflags\fR abbr: \fBd\fR
592.ZP
593Removes the specified lines from the buffer.
594The line after the last line deleted becomes the current line;
595if the lines deleted were originally at the end,
596the new last line becomes the current line.
597If a named
598.I buffer
599is specified by giving a letter,
600then the specified lines are saved in that buffer,
601or appended to it if an upper case letter is used.
602.LC
603\fBedit\fR \fIfile\fR abbr: \fBe\fR
604.br
605\fBex\fR \fIfile\fR
606.ZP
607Used to begin an editing session on a new file.
608The editor
609first checks to see if the buffer has been modified since the last
610.I write
611command was issued.
612If it has been,
613a warning is issued and the
614command is aborted.
615The
616command otherwise deletes the entire contents of the editor buffer,
617makes the named file the current file and prints the new filename.
618After insuring that this file is sensible\(dg
619.FS
620\(dg I.e., that it is not a binary file such as a directory,
621a block or character special file other than
622.I /dev/tty,
623a terminal,
624or a binary or executable file
625(as indicated by the first word).
626.FE
627the editor reads the file into its buffer.
628.IP
629If the read of the file completes without error,
630the number of lines and characters read is typed.
631If there were any non-\s-2ASCII\s0 characters
632in the file they are stripped of their non-\s-2ASCII\s0
633high bits,
634and any null characters in the file are discarded.
635If none of these errors occurred, the file is considered
636.I edited.
637If the last line of the input file is missing the trailing
638newline character, it will be supplied and a complaint will be issued.
639This command leaves the current line `\fB.\fR' at the last line read.\(dd
640.FS
641\(dd If executed from within
642.I open
643or
644.I visual,
645the current line is initially the first line of the file.
646.FE
647.LC
648\fBe!\fR \fIfile\fR
649.ZP
650The variant form suppresses the complaint about modifications having
651been made and not written from the editor buffer, thus
652discarding all changes which have been made before editing the new file.
653.LC
654\fBe\fR \fB+\fIn\fR \fIfile\fR
655.ZP
656Causes the editor to begin at line
657.I n
658rather than at the last line.
659.LC
660\fBfile\fR abbr: \fBf\fR
661.ZP
662Prints the current file name,
663whether it has been `[Modified]' since the last
664.I write
665command,
666the current line,
667and the number of lines in the buffer.*
668.FS
669* In the rare case that the current file is `[Not edited]' this is
670noted also; in this case you have to use the form \fBw!\fR to write to
671the file, since the editor is not sure that a \fBwrite\fR will not
672destroy a file unrelated to the current contents of the buffer.
673.FE
674.LC
675\fBfile\fR \fIfile\fR
676.ZP
677The current file name is changed to
678.I file
679which is considered
680`[Not edited]'.
681.LC
682( 1 , $ ) \fBglobal\fR /\fIpat\|\fR/ \fIcmds\fR abbr: \fBg\fR
683.ZP
684First marks each line among those specified which matches
685the given regular expression.
686Then the given command list is executed with `\fB.\fR' initially
687set to each marked line.
688.IP
689The command list consists of the remaining commands on the current
690input line and may continue to multiple lines by ending all but the
691last such line with a `\e'.
692.I Append,
693.I insert,
694and
695.I change
696commands and associated input are permitted;
697the `\fB.\fR' terminating input may be omitted if it would be on the
698last line of the command list.
699.I Open
700and
701.I visual
702commands are permitted in the command list and take input from the terminal.
703.IP
704The
705.I global
706command itself may not appear in
707.I cmds.
708The
709.I undo
710command is also not permitted there,
711as
712.I undo
713instead can be used to reverse the entire
714.I global
715command.
716The options
717.I autoprint
718and
719.I autoindent
720are inhibited during a
721.I global,
722and the value of the
723.I report
724option is temporarily infinite,
725in deference to a \fIreport\fR for the entire global.
726Finally, the context mark `\'\'' is set to the value of
727`.' before the global command begins and is not changed during a global
728command,
729except perhaps by an
730.I open
731or
732.I visual
733within the
734.I global.
735.LC
736\fBg!\fR \fB/\fIpat\fB/\fR \fIcmds\fR abbr: \fBv\fR
737.IP
738The variant form of \fIglobal\fR runs \fIcmds\fR at each line not matching
739\fIpat\fR.
740...LC
741..\fBhelp\fR \fItopic\fR
742...ZP
743..The
744...I help
745..command accepts keywords related to the editor and,
746..if there is information in its data base about that
747...I topic
748..supplies the information.
749..A list of topics can be had by
750...I help\ index.
751.LC
752( \fB.\fR )\|\fBinsert\fR abbr: \fBi\fR
753.br
754\fItext\fR
755.br
756\&\fB.\fR
757.ZP
758Places the given text before the specified line.
759The current line is left at the last line input;
760if there were none input it is left at the line before the addressed line.
761This command differs from
762.I append
763only in the placement of text.
764.KS
765.LC
766\fBi!\fR
767.br
768\fItext\fR
769.br
770\&\fB.\fR
771.ZP
772The variant toggles
773.I autoindent
774during the
775.I insert.
776.KE
777.LC
778( \fB.\fR , \fB.\fR+1 ) \fBjoin\fR \fIcount\fR \fIflags\fR abbr: \fBj\fR
779.ZP
780Places the text from a specified range of lines
781together on one line.
782White space is adjusted at each junction to provide at least
783one blank character, two if there was a `\fB.\fR' at the end of the line,
784or none if the first following character is a `)'.
785If there is already white space at the end of the line,
786then the white space at the start of the next line will be discarded.
787.LC
788\fBj!\fR
789.ZP
790The variant causes a simpler
791.I join
792with no white space processing; the characters in the lines are simply
793concatenated.
794.LC
795( \fB.\fR ) \fBk\fR \fIx\fR
796.ZP
797The
798.I k
799command is a synonym for
800.I mark.
801It does not require a blank or tab before the following letter.
802.LC
803( \fB.\fR , \fB.\fR ) \fBlist\fR \fIcount\fR \fIflags\fR
804.ZP
805Prints the specified lines in a more unambiguous way:
806tabs are printed as `^I'
807and the end of each line is marked with a trailing `$'.
808The current line is left at the last line printed.
809.LC
810( \fB.\fR ) \fBmark\fR \fIx\fR
811.ZP
812Gives the specified line mark
813.I x,
814a single lower case letter.
815The
816.I x
817must be preceded by a blank or a tab.
818The addressing form `\'x' then addresses this line.
819The current line is not affected by this command.
820.LC
821( \fB.\fR , \fB.\fR ) \fBmove\fR \fIaddr\fR abbr: \fBm\fR
822.ZP
823The
824.I move
825command repositions the specified lines to be after
826.I addr .
827The first of the moved lines becomes the current line.
828.LC
829\fBnext\fR abbr: \fBn\fR
830.ZP
831The next file from the command line argument list is edited.
832.LC
833\fBn!\fR
834.ZP
835The variant suppresses warnings about the modifications to the buffer not
836having been written out, discarding (irretrievably) any changes which may
837have been made.
838.LC
839\fBn\fR \fIfilelist\fR
840.ZP
841The specified
842.I filelist
843is expanded and the resulting list replaces the
844current argument list;
845the first file in the new list is then edited.
846.LC
847( \fB.\fR , \fB.\fR ) \fBnumber\fR \fIcount\fR \fIflags\fR abbr: \fB#\fRf or \fBnu\fR
848.ZP
849Prints each specified line preceded by its buffer line
850number.
851The current line is left at the last line printed.
852.KS
853.LC
854( \fB.\fR ) \fBopen\fR \fIflags\fR abbr: \fBo\fR
855.br
856( \fB.\fR ) \fBopen\fR /\fIpat\|\fR/ \fIflags\fR
857.ZP
858Enters intraline editing \fIopen\fR mode at each addressed line.
859If
860.I pat
861is given,
862then the cursor will be placed initially at the beginning of the
863string matched by the pattern.
864See
865.I "An Introduction to Display Editing with Vi"
866for more details.
867.KE
868.LC
869\fBpreserve\fR
870.ZP
871The current editor buffer is saved as though the system had just crashed.
872This command is for use only in emergencies when a
873.I write
874command has resulted in an error and you don't know how to save your work.
875After a
876.I preserve
877you should seek help.
878.LC
879( \fB.\fR , \fB.\fR )\|\fBprint\fR \fIcount\fR abbr: \fBp\fR
880.ZP
881Prints the specified lines
882with non-printing characters printed as control characters `^\fIx\fR\|';
883delete (octal 177) is represented as `^?'.
884The current line is left at the last line printed.
885.LC
886( \fB.\fR )\|\fBput\fR \fIbuffer\fR abbr: \fBpu\fR
887.ZP
888Puts back
889previously
890.I deleted
891or
892.I yanked
893lines.
894Normally used with
895.I delete
896to effect movement of lines,
897or with
898.I yank
899to effect duplication of lines.
900If no
901.I buffer
902is specified, then the last
903.I deleted
904or
905.I yanked
906text is restored.*
907.FS
908* But no modifying commands may intervene between the
909.I delete
910or
911.I yank
912and the
913.I put,
914nor may lines be moved between files without using a named buffer.
915.FE
916By using a named buffer, text may be restored that was saved there at any
917previous time.
918.LC
919\fBquit\fR abbr: \fBq\fR
920.ZP
921Causes
922.I ex
923to terminate.
924No automatic write of the editor buffer to a file is performed.
925However,
926.I ex
927issues a warning message if the file has changed
928since the last
929.I write
930command was issued, and does not
931.I quit.\(dg
932.FS
933\(dg \fIEx\fR
934will also issue a diagnostic if there are more files in the argument
935list.
936.FE
937Normally, you will wish to save your changes, and you
938should give a \fIwrite\fR command;
939if you wish to discard them, use the \fBq!\fR command variant.
940.LC
941\fBq!\fR
942.ZP
943Quits from the editor, discarding changes to the buffer without complaint.\(dg
944.LC
945( \fB.\fR ) \fBread\fR \fIfile\fR abbr: \fBr\fR
946.ZP
947Places a copy of the text of the given file in the
948editing buffer after the specified line.
949If no
950.I file
951is given the current file name is used.
952The current file name is not changed unless there is none in which
953case
954.I file
955becomes the current name.
956The sensibility restrictions for the
957.I edit
958command apply here also.
959If the file buffer is empty and there is no current name then
960.I ex
961treats this as an
962.I edit
963command.
964.IP
965Address `0' is legal for this command and causes the file to be read at
966the beginning of the buffer.
967Statistics are given as for the
968.I edit
969command when the
970.I read
971successfully terminates.
972After a
973.I read
974the current line is the last line read.\(dd
975.FS
976\(dd Within
977.I open
978and
979.I visual
980the current line is set to the first line read rather than the last.
981.FE
982.LC
983( \fB.\fR ) \fBread\fR \fB!\fR\fIcommand\fR
984.ZP
985Reads the output of the command
986.I command
987into the buffer after the specified line.
988This is not a variant form of the command, rather a read
989specifying a
990.I command
991rather than a
992.I filename;
993a blank or tab before the \fB!\fR is mandatory.
994.LC
995\fBrecover \fIfile\fR
996.ZP
997Recovers
998.I file
999from the system save area.
1000Used after a accidental hangup of the phone**
1001.FS
1002** The system saves a copy of the file you were editing only if you
1003have made changes to the file.
1004.FE
1005or a system crash** or
1006.I preserve
1007command.
1008Except when you use
1009.I preserve
1010you will be notified by mail when a file is saved.
1011.LC
1012\fBrewind\fR abbr: \fBrew\fR
1013.ZP
1014The argument list is rewound, and the first file in the list is edited.
1015.LC
1016\fBrew!\fR
1017.ZP
1018Rewinds the argument list discarding any changes made to the current buffer.
1019.LC
1020\fBset\fR \fIparameter\fR
1021.ZP
1022With no arguments, prints those options whose values have been
1023changed from their defaults;
1024with parameter
1025.I all
1026it prints all of the option values.
1027.IP
1028Giving an option name followed by a `?'
1029causes the current value of that option to be printed.
1030The `?' is unnecessary unless the option is Boolean valued.
1031Boolean options are given values either by the form
1032`set \fIoption\fR' to turn them on or
1033`set no\fIoption\fR' to turn them off;
1034string and numeric options are assigned via the form
1035`set \fIoption\fR=value'.
1036.IP
1037More than one parameter may be given to
1038.I set \|;
1039they are interpreted left-to-right.
1040.LC
1041\fBshell\fR abbr: \fBsh\fR
1042.IP
1043A new shell is created.
1044When it terminates, editing resumes.
1045.LC
1046\fBsource\fR \fIfile\fR abbr: \fBso\fR
1047.IP
1048Reads and executes commands from the specified file.
1049.I Source
1050commands may be nested.
1051.LC
1052( \fB.\fR , \fB.\fR ) \fBsubstitute\fR /\fIpat\fR\|/\fIrepl\fR\|/ \fIoptions\fR \fIcount\fR \fIflags\fR addr: \fBs\fR
1053.IP
1054On each specified line, the first instance of pattern
1055.I pat
1056is replaced by replacement pattern
1057.I repl.
1058If the
1059.I global
1060indicator option character `g'
1061appears, then all instances are substituted;
1062if the
1063.I confirm
1064indication character `c' appears,
1065then before each substitution the line to be substituted
1066is typed with the string to be substituted marked
1067with `\(ua' characters.
1068By typing an `y' one can cause the substitution to be performed,
1069any other input causes no change to take place.
1070After a
1071.I substitute
1072the current line is the last line substituted.
1073.IP
1074Lines may be split by substituting
1075new-line characters into them.
1076The newline in
1077.I repl
1078must be escaped by preceding it with a `\e'.\(dg
1079.FS
1080\(dg If the
1081.I substitute
1082is within a
1083.I global,
1084then two escaping `\e' characters will be needed.)
1085.FE
1086Other metacharacters available in
1087.I pat
1088and
1089.I repl
1090are described below.
1091.LC
1092( \fB.\fR , \fB.\fR ) \fBt\fR \fIaddr\fR \fIflags\fR
1093.ZP
1094The
1095.I t
1096command is a synonym for
1097.I copy .
1098.LC
1099\fBta\fR \fItag\fR
1100.ZP
1101The focus of editing switches to the location of
1102.I tag,
1103switching to a different line in the current file where it is defined,
1104or if necessary to another file.\(dd
1105.FS
1106\(dd If you have modified the current file before giving a
1107.I tag
1108command, you must write it out; giving another
1109.I tag
1110command, specifying no
1111.I tag
1112will reuse the previous tag.
1113.FE
1114.IP
1115The tags file is normally created by a program such as
1116.I ctags,
1117and consists of a number of lines with three fields separated by blanks
1118or tabs. The first field gives the name of the tag,
1119the second the name of the file where the tag resides, and the third
1120gives an addressing form which can be used by the editor to find the tag;
1121this field is usually a contextual scan using `/\fIpat\fR/' to be immune
1122to minor changes in the file.
1123.LC
1124\fBundo\fR abbr: \fBu\fR
1125.ZP
1126Reverses the changes made in the buffer by the last
1127buffer editing command.
1128Note that
1129.I global
1130commands are considered a single command for the purpose of
1131.I undo
1132(as are
1133.I open
1134and
1135.I visual.)
1136Also, the commands
1137.I write
1138and
1139.I edit
1140which interact with the
1141file system cannot be undone.
1142.I Undo
1143is its own inverse.
1144.IP
1145.I Undo
1146always marks the previous value of the current line `\fB.\fR'
1147as `\'\''.
1148After an
1149.I undo
1150the current line is the first line restored
1151or the line before the first line deleted if no lines were restored.
1152For commands with more global effect
1153such as
1154.I global
1155and
1156.I visual
1157the current line regains it pre-command value after an
1158.I undo.
1159.LC
1160( 1 , $ ) \fBv\fR /\fIpat\fR\|/ \fIcmds\fR
1161.ZP
1162A synonym for the
1163.I global
1164command variant \fBg!\fR, running the specified \fIcmds\fR on each
1165line which does not match \fIpat\fR.
1166.LC
1167\fBversion\fR abbr: \fBve\fR
1168.ZP
1169Prints the current version number of the editor
1170as well as the date the binary was created.
1171.LC
1172( \fB.\fR ) \fBvisual\fR \fItype\fR \fIcount\fR \fIflags\fR abbr: \fBvi\fR
1173.ZP
1174Enters visual mode at the specified line.
1175.I Type
1176is optional and may be `\-' , `\(ua' or `\fB.\fR'
1177as in the
1178.I z
1179command to specify the placement of the specified line on the screen.
1180By default, if
1181.I type
1182is omitted, the specified line is placed as the first on the screen.
1183A
1184.I count
1185specifies an initial window size; the default is the value of the option
1186.I window.
1187See the document
1188.I "An Introduction to Display Editing with Vi"
1189for more details.
1190.LC
1191( 1 , $ ) \fBwrite\fR \fIfile\fR abbr: \fBw\fR
1192.ZP
1193Writes changes made back to \fIfile\fR, printing the number of lines and
1194characters written.
1195Normally \fIfile\fR is omitted and the text goes back where it came from.
1196If a \fIfile\fR is specified, then text will be written to that file.*
1197.FS
1198* The editor writes to a file only if it is
1199the current file and is
1200.I edited ,
1201if the file does not exist,
1202or if the file is actually a teletype,
1203.I /dev/tty,
1204.I /dev/null.
1205Otherwise, you must give the variant form \fBw!\fR to force the write.
1206.FE
1207If the file does not exist it is created.
1208The current file name is changed only if there is no current file
1209name; the current line is never changed.
1210.IP
1211If an error occurs while writing the current and
1212.I edited
1213file, the editor
1214considers that there has been ``No write since last change''
1215even if the buffer had not previously been modified.
1216.LC
1217( 1 , $ ) \fBwrite>>\fR \fIfile\fR abbr: \fBw>>\fR
1218.ZP
1219Writes the buffer contents at the end of
1220an existing file.
1221.IP
1222.LC
1223\fBw!\fR \fIname\fR
1224.ZP
1225Overrides the checking of the normal \fIwrite\fR command,
1226and will write to any file which the system permits.
1227.LC
1228( 1 , $ ) \fBw\fR \fB!\fR\fIcommand\fR
1229.ZP
1230Writes the specified lines into
1231.I command.
1232Note the difference between \fBw!\fR which overrides checks and
1233\fBw\ \ !\fR which writes to a command.
1234.LC
1235\fBwq\fR \fIname\fR
1236.ZP
1237Like a \fIwrite\fR and then a \fIquit\fR command.
1238.LC
1239\fBwq!\fR \fIname\fR
1240.ZP
1241The variant overrides checking on the sensibility of the
1242.I write
1243command, as \fBw!\fR does.
1244.LC
1245( \fB.\fR , \fB.\fR )\|\fByank\fR \fIbuffer\fR \fIcount\fR abbr: \fBya\fR
1246.ZP
1247Places the specified lines in the named
1248.I buffer,
1249for later retrieval via
1250.I put.
1251If no buffer name is specified, the lines go to a more volatile place;
1252see the \fIput\fR command description.
1253.LC
1254( \fB.\fR ) \fBz\fR \fItype\fR \fIcount\fR
1255.ZP
1256Prints a window of text with the specified line at the top.
1257If \fItype\fR is `\-' the line is placed at the bottom; a `\fB.\fR' causes
1258the line to be placed in the center.*
1259A count gives the number of lines to be displayed rather than
1260the number specified by the \fIwindow\fR option.
1261On a \s-2CRT\s0 the screen is cleared before display begins unless a
1262count which is less than the screen size is given.
1263The current line is left at the last line printed.
1264.FS
1265* Forms `z=' and `z\(ua' also exist; `z=' places the current line in the
1266center, surrounds it with lines of `\-' characters and leaves the current
1267line at this line. The form `z\(ua' prints the window before `z\-'
1268would. The characters `+', `\(ua' and `\-' may be repeated for cumulative
1269effect.
1270.FE
1271.LC
1272\fB!\fR \fIcommand\fR\fR
1273.ZP
1274The remainder of the line after the `!' character is sent to a shell
1275to be executed.
1276Within the text of
1277.I command
1278the characters
1279`%' and `#' are expanded as in filenames and the character
1280`!' is replaced with the text of the previous command.
1281Thus, in particular,
1282`!!' repeats the last such shell escape.
1283If any such expansion is performed, the expanded line will be echoed.
1284The current line is unchanged by this command.
1285.IP
1286If there has been ``[No\ write]'' of the buffer contents since the last
1287change to the editing buffer, then a diagnostic will be printed
1288before the command is executed as a warning.
1289A single `!' is printed when the command completes.
1290.LC
1291( \fIaddr\fR , \fIaddr\fR ) \fB!\fR \fIcommand\fR\fR
1292.ZP
1293Takes the specified address range and supplies it as
1294standard input to
1295.I command;
1296the resulting output then replaces the input lines.
1297.LC
1298( $ ) \fB=\fR
1299.ZP
1300Prints the line number of the
1301addressed line.
1302The current line is unchanged.
1303.KS
1304.LC
1305( \fB.\fR , \fB.\fR ) \fB>\fR \fIcount\fR \fIflags\fR
1306.br
1307( \fB.\fR , \fB.\fR ) \fB<\fR \fIcount\fR \fIflags\fR
1308.IP
1309Perform intelligent shifting on the specified lines;
1310\fB<\fR shifts left and \fB>\fR shift right.
1311The quantity of shift is determined by the
1312.I shiftwidth
1313option and the repetition of the specification character.
1314Only white space (blanks and tabs) is shifted;
1315no non-white characters are discarded in a left-shift.
1316The current line becomes the last line which changed due to the
1317shifting.
1318.KE
1319.LC
1320\fB^D\fR
1321.ZP
1322An end-of-file from a terminal input scrolls through the file.
1323The
1324.I scroll
1325option specifies the size of the scroll, normally a half screen of text.
1326.LC
1327( \fB.\fR+1 )
1328.br
1329( \fB.\fR+1 ) |
1330.ZP
1331An address alone causes the addressed line to be printed.
1332A blank line prints the next line in the file.
1333.LC
1334( \fB.\fR , \fB.\fR ) \fB&\fR \fIoptions\fR \fIcount\fR \fIflags\fR
1335.ZP
1336Repeats the previous
1337.I substitute
1338command.
1339.LC
1340( \fB.\fR , \fB.\fR ) \fB\s+2~\s0\fR \fIoptions\fR \fIcount\fR \fIflags\fR
1341.ZP
1342Replaces the previous regular expression with the previous
1343replacement pattern from a substitution.
1344.NH 1
1345Regular expressions and substitute replacement patterns
1346.NH 2
1347Regular expressions
1348.PP
1349A regular expression specifies a set of strings of characters.
1350A member of this set of strings is said to be
1351.I matched
1352by the regular expression.
1353.I Ex
1354remembers two previous regular expressions:
1355the previous regular expression used in a
1356.I substitute
1357command
1358and the previous regular expression used elsewhere
1359(referred to as the previous \fIscanning\fR regular expression.)
1360The previous regular expression
1361can always be referred to by a null \fIre\fR, e.g. `//' or `??'.
1362.NH 2
1363Magic and nomagic
1364.PP
1365The regular expressions allowed by
1366.I ex
1367are constructed in one of two ways depending on the setting of
1368the
1369.I magic
1370option.
1371The
1372.I ex
1373default setting of
1374.I magic
1375gives quick access to a powerful set of regular expression
1376metacharacters.
1377The disadvantage of
1378.I magic
1379is that the user must remember that these metacharacters are
1380.I magic
1381and precede them with the character `\e'
1382to use them as ``ordinary'' characters.
1383With
1384.I nomagic,
1385the default for
1386.I edit
1387and
1388.I vi,
1389regular expressions are much simpler,
1390there being only two metacharacters.
1391The power of the other metacharacters is still available by preceding
1392the (now) ordinary character with a `\e'.
1393Note that `\e' is thus always a metacharacter.
1394.PP
1395The remainder of the discussion of regular expressions assumes
1396that
1397that the setting of this option is
1398.I magic.\(dg
1399.FS
1400\(dg To discern what is true with
1401.I nomagic
1402it suffices to remember that the only
1403special characters in this case will be `\(ua' at the beginning
1404of a regular expression,
1405`$' at the end of a regular expression,
1406and `\e'.
1407With
1408.I nomagic
1409the characters `\s+2~\s0' and `&' also lose their special meanings
1410related to the replacement pattern of a substitute.
1411.FE
1412.NH 2
1413Basic regular expression summary
1414.PP
1415The following basic constructs are used to construct
1416.I magic
1417mode regular expressions.
1418.IP \fIchar\fR 15
1419An ordinary character matches itself.
1420The characters `\(ua' at the beginning of a line,
1421`$' at the end of line,
1422`*' as any character other than the first,
1423`.', `\e', `[', and `\s+2~\s0' are not ordinary characters and
1424must be escaped (preceded) by `\e' to be treated as such.
1425.IP \fB\(ua\fR
1426At the beginning of a pattern
1427forces the match to succeed only at the beginning of a line.
1428.IP \fB$\fR
1429At the end of a regular expression forces the match to
1430succeed only at the end of the line.
1431.IP \&\fB.\fR
1432Matches any single character except
1433the new-line character.
1434.IP \fB\e<\fR
1435Forces the match
1436to occur only at the beginning of a ``variable'' or ``word'';
1437that is, either at the beginning of a line, or just before
1438a letter, digit, or underline and after a character not one of
1439these.
1440.IP \fB\e>\fR
1441Similar to `\e<', but matching the end of a ``variable''
1442or ``word'', i.e. either the end of the line or before character
1443which is neither a letter, nor a digit, nor the underline character.
1444.IP \fB[\fIstring\fR]\fR
1445Matches any (single) character in the class defined by
1446.I string.
1447Most characters in
1448.I string
1449define themselves.
1450A pair of characters separated by `\-' in
1451.I string
1452defines the set of characters collating between the specified lower and upper
1453bounds, thus `[a\-z]' as a regular expression matches
1454any (single) lower-case letter.
1455If the first character of
1456.I string
1457is an `\(ua' then the construct
1458matches those characters which it otherwise would not;
1459thus `[\(uaa\-z]' matches anything but a lower-case letter (and of course a
1460newline).
1461To place any of the characters
1462`\(ua', `[', or `\-' in
1463.I string
1464you must escape them with a preceding `\e'.
1465.NH 2
1466Combining regular expression primitives
1467.PP
1468The concatenation of two regular expressions matches the leftmost and
1469then longest string
1470which can be divided with the first piece matching the first regular
1471expression and the second piece matching the second.
1472Any of the (single character matching) regular expressions mentioned
1473above may be followed by the character `*' to form a regular expression
1474which matches any number of adjacent occurrences (including 0) of characters
1475matched by the regular expression it follows.
1476.PP
1477The character `\s+2~\s0' may be used in a regular expression,
1478and matches the text which defined the replacement part
1479of the last
1480.I substitute
1481command.
1482A regular expression may be enclosed between the sequences
1483`\e(' and `\e)' with side effects in the
1484.I substitute
1485replacement patterns.
1486.NH 2
1487Substitute replacement patterns
1488.PP
1489The basic metacharacters for the replacement pattern are
1490`&' and `~'; these are
1491given as `\e&' and `\e~' when
1492.I nomagic
1493is set.
1494Each instance of `&' is replaced by the characters
1495which the regular expression matched.
1496The metacharacter `~' stands, in the replacement pattern,
1497for the defining text of the previous replacement pattern.
1498.PP
1499Other metasequences possible in the replacement pattern
1500are always introduced by the escaping character `\e'.
1501The sequence `\e\fIn\fR' is replaced by the text matched
1502by the \fIn\fR-th regular subexpression enclosed between
1503`\e(' and `\e)'.\(dg
1504.FS
1505\(dg When nested, parenthesized subexpressions are present,
1506\fIn\fR is determined by counting occurrences of `\e(' starting from the left.
1507.FE
1508The sequences `\eu' and `\el' cause the immediately following character in
1509the replacement to be converted to upper- or lower-case respectively
1510if this character is a letter.
1511The sequences `\eU' and `\eL' turn such conversion on, either until
1512`\eE' or `\ee' is encountered, or until the end of the replacement pattern.
1513.NH 1
1514Option descriptions
1515.PP
1516.LC
1517\fBautoindent\fR, \fBai\fR default: noai
1518.ZP
1519Can be used to ease the preparation of structured program text.
1520At the beginning of each
1521.I append ,
1522.I change
1523or
1524.I insert
1525command
1526or when a new line is
1527.I opened
1528or created by an
1529.I append ,
1530.I change ,
1531.I insert ,
1532or
1533.I substitute
1534operation within
1535.I open
1536or
1537.I visual
1538mode,
1539.I ex
1540looks at the line being appended after,
1541the first line changed
1542or the line inserted before and calculates the amount of white space
1543at the start of the line.
1544It then aligns the cursor at the level of indentation so determined.
1545.IP
1546If the user then types lines of text in,
1547they will continue to be justified at the displayed indenting level.
1548If more white space is typed at the beginning of a line,
1549the following line will start aligned with the first non-white character
1550of the previous line.
1551To back the cursor up to the preceding tab stop one can hit
1552\fB^D\fR.
1553The tab stops going backwards are defined at multiples of the
1554.I shiftwidth
1555option.
1556You
1557.I cannot
1558backspace over the indent,
1559except by sending an end-of-file with a \fB^D\fR.
1560.IP
1561Specially processed in this mode is a line with no characters added
1562to it, which turns into a completely blank line (the white
1563space provided for the
1564.I autoindent
1565is discarded.)
1566Also specially processed in this mode are lines beginning with
1567an `\(ua' and immediately followed by a \fB^D\fR.
1568This causes the input to be repositioned at the beginning of the line,
1569but retaining the previous indent for the next line.
1570Similarly, a `0' followed by a \fB^D\fR
1571repositions at the beginning but without
1572retaining the previous indent.
1573.IP
1574.I Autoindent
1575doesn't happen in
1576.I global
1577commands or when the input is not a terminal.
1578.LC
1579\fBautoprint\fR, \fBap\fR default: ap
1580.ZP
1581Causes the current line to be printed after each
1582.I delete ,
1583.I copy ,
1584.I join ,
1585.I move ,
1586.I substitute ,
1587.I t ,
1588.I undo
1589or
1590shift command.
1591This has the same effect as supplying a trailing `p'
1592to each such command.
1593.I Autoprint
1594is suppressed in globals,
1595and only applies to the last of many commands on a line.
1596.LC
1597\fBbeautify\fR, \fBbf\fR default: nobeautify
1598.ZP
1599Causes all control characters except tab, newline and form-feed
1600to be discarded from the input.
1601A complaint is registered the first time a
1602backspace character is discarded.
1603.I Beautify
1604does not apply to command input.
1605.LC
1606\fBdirectory\fR, \fBdir\fR default: dir=/tmp
1607.ZP
1608Specifies the directory in which
1609.I ex
1610places its buffer file.
1611If this directory in not
1612writable, then the editor will exit abruptly when it fails to be
1613able to create its buffer there.
1614.LC
1615\fBerrorbells\fR, \fBeb\fR default: eb
1616.ZP
1617Error messages are preceded by a bell.*
1618.FS
1619* Bell ringing in
1620.I open
1621and
1622.I visual
1623on errors is not suppressed by setting
1624.I noeb.
1625.FE
1626If possible the editor always places the error message in a standout mode of the
1627terminal (such as inverse video) instead of ringing the bell.
1628.LC
1629\fBignorecase\fR, \fBic\fR default: noic
1630.ZP
1631All upper case characters in the text are mapped to lower case in regular
1632expression matching.
1633In addition, all upper case characters in regular expressions are mapped
1634to lower case except in character class specifications.
1635.LC
1636\fBlisp\fR default: nolisp
1637.ZP
1638\fIAutoindent\fR indents appropriately for
1639.I lisp
1640code, and the \fB( ) { } [[\fR and \fB]]\fR commands in
1641.I open
1642and
1643.I visual
1644are modified to have meaning for \fIlisp\fR.
1645.LC
1646\fBlist\fR default: nolist
1647.ZP
1648All printed lines will be displayed (more) unambiguously,
1649showing tabs and end-of-lines as in the
1650.I list
1651command.
1652.LC
1653\fBmagic\fR default: magic for \fIex\fR\(dg
1654.FS
1655\(dg \fINomagic\fR for \fIedit\fR and \fIvi\fR.
1656.FE
1657.ZP
1658If
1659.I nomagic
1660is set, the number of regular expression metacharacters is greatly reduced,
1661with only `\(ua' and `$' having special effects.
1662In addition the metacharacters
1663`~'
1664and
1665`&'
1666of the replacement pattern are treated as normal characters.
1667All the normal metacharacters may be made
1668.I magic
1669when
1670.I nomagic
1671is set by preceding them with a `\e'.
1672.LC
1673\fBnumber, nu\fR default: nonumber
1674.ZP
1675Causes all output lines to be printed with their
1676line numbers.
1677In addition each input line will be prompted for by supplying the line number
1678it will have.
1679.LC
1680\fBopen\fR default: open
1681.ZP
1682If \fInoopen\fR, the commands
1683.I open
1684and
1685.I visual
1686are not permitted.
1687This is set for
1688.I edit
1689to prevent confusion resulting from accidental entry to
1690open or visual mode.
1691.LC
1692\fBoptimize, opt\fR default: optimize
1693.ZP
1694Throughput of text is expedited by setting the terminal
1695to not do automatic carriage returns
1696when printing more than one (logical) line of output.
1697greatly speeding output on terminals without addressable
1698cursors when text with leading white space is printed.
1699.LC
1700\fBparagraphs,\ para\fR default: para=IPLPPPQPbp
1701.ZP
1702Specifies the paragraphs for the \fB{\fR and \fB}\fR operations in
1703.I open
1704and
1705.I visual.
1706The pairs of characters in the option's value are the names
1707of the macros which start paragraphs.
1708.LC
1709\fBprompt\fR default: prompt
1710.ZP
1711Command mode input is prompted for with a `:'.
1712.LC
1713\fBreport\fR default: report=5\(dg
1714.FS
1715\(dg 2 for \fIedit\fR.
1716.FE
1717.ZP
1718Specifies a threshold for feedback from commands.
1719Any command which modifies more than the specified number of lines
1720will provide feedback as to the scope of its changes.
1721For commands such as
1722.I global ,
1723.I open ,
1724.I undo ,
1725and
1726.I visual
1727which have potentially more far reaching scope,
1728the net change in the number of lines in the buffer is
1729presented at the end of the command, subject to this same threshold.
1730Thus notification is suppressed during a
1731.I global
1732command on the individual commands performed.
1733.LC
1734\fBscroll\fR default: scroll=12
1735.ZP
1736Determines the number of logical lines scrolled when an end-of-file
1737is received from a terminal input.
1738.LC
1739\fBsections\fR default: sections=SHNH
1740.ZP
1741Specifies the section macros for the \fB[[\fR and \fB]]\fR operations
1742in
1743.I open
1744and
1745.I visual.
1746The pairs of characters in the options's value are the names
1747of the macros which start paragraphs.
1748.LC
1749\fBshell\fR, \fBsh\fR default: sh=/bin/sh
1750.ZP
1751Gives the path name of the shell forked for
1752the shell escape command `!', and by the
1753.I shell
1754command.
1755.LC
1756\fBshiftwidth\fR, \fBsw\fR default: sw=8
1757.ZP
1758Gives the width a software tab stop,
1759used in reverse tabbing with \fB^D\fR when using
1760.I autoindent
1761to append text,
1762and by the shift commands.
1763.LC
1764\fBshowmatch, sm\fR default: nosm
1765.ZP
1766In
1767.I open
1768and
1769.I visual
1770mode, when a \fB)\fR or \fB}\fR is typed, move the cursor to the matching
1771\fB(\fR or \fB{\fR for one second if this matching character is on the
1772screen. Extremely useful with
1773.I lisp.
1774.LC
1775\fBslowopen, slow\fR terminal dependent
1776.ZP
1777Affects the display algorithm used in
1778.I visual
1779mode, holding off display updating during input of new text to improve
1780throughput when the terminal in use is both slow and unintelligent.
1781See
1782.I "An Introduction to Display Editing with Vi"
1783for more details.
1784.LC
1785\fBtabstop,\ ts\fR default: ts=8
1786.ZP
1787The editor expands tabs in the input file to be on
1788.I tabstop
1789boundaries for the purposes of display.
1790.LC
1791\fBterm\fR from environment
1792.ZP
1793The terminal type of the output device.
1794.LC
1795\fBterse\fR default: noterse
1796.ZP
1797Shorter error diagnostics are produced for the experienced user.
1798.LC
1799\fBwarn\fR default: warn
1800.ZP
1801Warn if there has been `[No write since last change]' before a `!'
1802command escape.
1803.LC
1804\fBwindow\fR default: window=23
1805.ZP
1806The number of lines in a text window for the
1807.I z
1808and
1809.I visual
1810commands.
1811.LC
1812\fBwrapscap\fR, \fBws\fR default: ws
1813.ZP
1814Searches using the regular expressions in addressing
1815will wrap around past the end of the file.
1816.LC
1817\fBwrapmargin\fR, \fBwm\fR default: wm=0
1818.ZP
1819Defines a margin for automatic wrapover of text during input in
1820.I open
1821and
1822.I visual
1823modes. See
1824.I "An Introduction to Text Editing with Vi"
1825for details.
1826.LC
1827\fBwriteany\fR, \fBwa\fR default: nowa
1828.IP
1829Inhibit the checks normally made before
1830.I write
1831commands, allowing a write to any file which the system protection
1832mechanism will allow.
1833.NH 1
1834Limitations
1835.PP
1836This editor uses a temporary file as a workspace
1837and each line in the buffer is represented by an in-core pointer to the
1838image of that line on the disk.
1839The editor does
1840.I not
1841reclaim space in this temporary file used by lines which are
1842deleted or changed.
1843This means that files which are larger than 128K characters
1844may be difficult to edit, and that
1845systematic changes on large numbers of lines may
1846run the editor out of temporary file space.
1847.PP
1848If the editor runs out of temporary space you can write the file
1849and then use an
1850.I edit
1851command to read it back in.
1852This will reclaim the lost space.
1853A better solution is to split the file into smaller pieces or to use a stream
1854editor such as
1855.I sed
1856on the file.
1857.PP
1858Other editor limits that the user is likely to encounter are as follows:
1859512 characters per line,
1860256 characters per global command list,
186164 characters per file name,
1862128 characters in the previous inserted and deleted text in
1863.I open
1864or
1865.I visual,
1866100 characters in a shell escape command,
186730 characters in a string valued option,
186830 characters in a tag name,
1869and
1870256K characters in the temporary file.
1871The limit on the number of lines depends on the amount of core:
1872each line takes at least 1 word, and to effect
1873.I undo
1874occasionally up to 2.