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