distrib: run libtoolize
[nvi.git] / docs / exref / ex.rm
blobb6b7385ae1c4ddddab47d48941cf24efc93ba257
1 .\" Copyright (c) 1980, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" %sccs.include.redist.roff%
5 .\"
6 .\"     $Id: ex.rm,v 8.5 1996/08/18 11:36:16 bostic Exp $ (Berkeley) $Date: 1996/08/18 11:36:16 $
7 .\"
8 .nr LL 6.5i
9 .nr FL 6.5i
10 .EH 'USD:12-%''Ex Reference Manual'
11 .OH 'Ex Reference Manual''USD:12-%'
12 .nr )P 0
13 .de ZP
14 .nr pd \\n()P
15 .nr )P 0
16 .if \\n(.$=0 .IP
17 .if \\n(.$=1 .IP "\\$1"
18 .if \\n(.$>=2 .IP "\\$1" "\\$2"
19 .nr )P \\n(pd
20 .rm pd
22 .de LC
23 .br
24 .sp .1i
25 .ne 4
26 .LP
27 .ta 4.0i
29 .bd S B 3
30 .\".RP
31 .TL
32 Ex Reference Manual
33 .br
34 Version 3.7
35 .AU
36 William Joy
37 .AU
38 Mark Horton
39 .AI
40 Computer Science Division
41 Department of Electrical Engineering and Computer Science
42 University of California, Berkeley
43 Berkeley, Ca.  94720
44 .AB
45 .I Ex
46 a line oriented text editor, which supports both command and display
47 oriented editing.
48 This reference manual describes the command oriented part of
49 .I ex;
50 the display editing features of
51 .I ex
52 are described in
53 .I "An Introduction to Display Editing with Vi."
54 Other documents about the editor include the introduction
55 .I "Edit: A tutorial",
56 the
57 .I "Ex/edit Command Summary",
58 and a
59 .I "Vi Quick Reference"
60 card.
61 .AE
62 .NH 1
63 Starting ex
64 .PP
65 .FS
66 The financial support of an \s-2IBM\s0 Graduate Fellowship and the National
67 Science Foundation under grants MCS74-07644-A03 and MCS78-07291 is gratefully
68 acknowledged.
69 .FE
70 Each instance of the editor has a set of options,
71 which can be set to tailor it to your liking.
72 The command
73 .I edit
74 invokes a version of
75 .I ex
76 designed for more casual or beginning
77 users by changing the default settings of some of these options.
78 To simplify the description which follows we
79 assume the default settings of the options.
80 .PP
81 When invoked,
82 .I ex
83 determines the terminal type from the \s-2TERM\s0 variable in the environment.
84 It there is a \s-2TERMCAP\s0 variable in the environment, and the type
85 of the terminal described there matches the \s-2TERM\s0 variable,
86 then that description
87 is used.  Also if the \s-2TERMCAP\s0 variable contains a pathname (beginning
88 with a \fB/\fR) then the editor will seek the description of the terminal
89 in that file (rather than the default /etc/termcap).
90 If there is a variable \s-2EXINIT\s0 in the environment, then the editor
91 will execute the commands in that variable,
92 otherwise if there is a file
93 .I \&.exrc
94 in your \s-2HOME\s0 directory
95 .I ex
96 reads commands from that file, simulating a
97 .I source
98 command.
99 Option setting commands placed in
100 \s-2EXINIT\s0 or
101 .I \&.exrc
102 will be executed before each editor session.
104 A command to enter
105 .I ex
106 has the following prototype:\(dg
108 \(dg Brackets `[' `]' surround optional parameters here.
111 \fBex\fP [ \fB\-\fP ] [ \fB\-v\fP ] [ \fB\-t\fP \fItag\fP ] [ \fB\-r\fP ] [ \fB\-l\fP ] [ \fB\-w\fP\fIn\fP ] [ \fB\-x\fP ] [ \fB\-R\fP ] [ \fB+\fP\fIcommand\fP ] name ...
113 The most common case edits a single file with no options, i.e.:
115 \fBex\fR name
118 .B \-
119 command line option
120 option suppresses all interactive-user feedback
121 and is useful in processing editor scripts in command files.
123 .B \-v
124 option is equivalent to using
125 .I vi
126 rather than
127 .I ex.
129 .B \-t
130 option is equivalent to an initial
131 .I tag
132 command, editing the file containing the
133 .I tag
134 and positioning the editor at its definition.
136 .B \-r
137 option is used in recovering after an editor or system crash,
138 retrieving the last saved version of the named file or,
139 if no file is specified,
140 typing a list of saved files.
142 .B \-l
143 option sets up for editing \s-2LISP\s0, setting the
144 .I showmatch
146 .I lisp
147 options.
149 .B \-w
150 option sets the default window size to
151 .I n,
152 and is useful on dialups to start in small windows.
154 .B \-x
155 option causes
156 .I ex
157 to prompt for a
158 .I key ,
159 which is used to encrypt and decrypt the contents of the file,
160 which should already be encrypted using the same key,
162 .I crypt (1).
164 .B \-R
165 option sets the
166 .I readonly
167 option at the start.
168 .I Name
169 arguments indicate files to be edited.
170 An argument of the form
171 \fB+\fIcommand\fR
172 indicates that the editor should begin by executing the specified command.
174 .I command
175 is omitted, then it defaults to ``$'', positioning the editor at the last
176 line of the first file initially.  Other useful commands here are scanning
177 patterns of the form ``/pat'' or line numbers, e.g. ``+100'' starting
178 at line 100.
179 .NH 1
180 File manipulation
181 .NH 2
182 Current file
184 .I Ex
185 is normally editing the contents of a single file,
186 whose name is recorded in the
187 .I current
188 file name.
189 .I Ex
190 performs all editing actions in a buffer
191 (actually a temporary file)
192 into which the text of the file is initially read.
193 Changes made to the buffer have no effect on the file being
194 edited unless and until the buffer contents are written out to the
195 file with a
196 .I write
197 command.
198 After the buffer contents are written,
199 the previous contents of the written file are no longer accessible.
200 When a file is edited,
201 its name becomes the current file name,
202 and its contents are read into the buffer.
204 The current file is almost always considered to be
205 .I edited.
206 This means that the contents of the buffer are logically
207 connected with the current file name,
208 so that writing the current buffer contents onto that file,
209 even if it exists,
210 is a reasonable action.
211 If the current file is not 
212 .I edited
213 then
214 .I ex
215 will not normally write on it if it already exists.*
217 * The
218 .I file
219 command will say ``[Not edited]'' if the current file is not considered
220 edited.
222 .NH 2
223 Alternate file
225 Each time a new value is given to the current file name,
226 the previous current file name is saved as the
227 .I alternate
228 file name.
229 Similarly if a file is mentioned but does not become the current file,
230 it is saved as the alternate file name.
231 .NH 2
232 Filename expansion
234 Filenames within the editor may be specified using the normal
235 shell expansion conventions.
236 In addition,
237 the character `%' in filenames is replaced by the
238 .I current
239 file name and the character
240 `#' by the
241 .I alternate
242 file name.\(dg
244 \(dg This makes it easy to deal alternately with
245 two files and eliminates the need for retyping the
246 name supplied on an
247 .I edit
248 command after a 
249 .I "No write since last change"
250 diagnostic is received.
252 .NH 2
253 Multiple files and named buffers
255 If more than one file is given on the command line,
256 then the first file is edited as described above.
257 The remaining arguments are placed with the first file in the
258 .I "argument list."
259 The current argument list may be displayed with the
260 .I args
261 command.
262 The next file in the argument list may be edited with the
263 .I next
264 command.
265 The argument list may also be respecified by specifying
266 a list of names to the
267 .I next
268 command.
269 These names are expanded,
270 the resulting list of names becomes the new argument list,
272 .I ex
273 edits the first file on the list.
275 For saving blocks of text while editing, and especially when editing
276 more than one file,
277 .I ex
278 has a group of named buffers.
279 These are similar to the normal buffer, except that only a limited number
280 of operations are available on them.
281 The buffers have names
282 .I a
283 through
284 .I z.\(dd
286 \(dd It is also possible to refer to
287 .I A
288 through
289 .I Z;
290 the upper case buffers are the same as the lower but commands
291 append to named buffers rather than replacing
292 if upper case names are used.
294 .NH 2
295 Read only
297 It is possible to use
298 .I ex
300 .I "read only"
301 mode to look at files that you have no intention of modifying.
302 This mode protects you from accidently overwriting the file.
303 Read only mode is on when the
304 .I readonly
305 option is set.
306 It can be turned on with the
307 .B \-R
308 command line option,
309 by the
310 .I view
311 command line invocation,
312 or by setting the
313 .I readonly
314 option.
315 It can be cleared by setting
316 .I noreadonly .
317 It is possible to write, even while in read only mode, by indicating
318 that you really know what you are doing.
319 You can write to a different file, or can use the ! form of write,
320 even while in read only mode.
321 .NH 1
322 Exceptional Conditions
323 .NH 2
324 Errors and interrupts
326 When errors occur
327 .I ex
328 (optionally) rings the terminal bell and, in any case, prints an error
329 diagnostic.  If the primary input is from a file, editor processing
330 will terminate.  If an interrupt signal is received,
331 .I ex
332 prints ``Interrupt'' and returns to its command level.  If the primary
333 input is a file, then
334 .I ex
335 will exit when this occurs.
336 .NH 2
337 Recovering from hangups and crashes
339 If a hangup signal is received and the buffer has been modified since
340 it was last written out, or if the system crashes, either the editor
341 (in the first case) or the system (after it reboots in the second) will
342 attempt to preserve the buffer.  The next time you log in you should be
343 able to recover the work you were doing, losing at most a few lines of
344 changes from the last point before the hangup or editor crash.  To
345 recover a file you can use the
346 .B \-r
347 option.  If you were editing the file
348 .I resume,
349 then you should change
350 to the directory where you were when the crash occurred, giving the command
352 \fBex \-r\fP\fI resume\fP
354 After checking that the retrieved file is indeed ok, you can
355 .I write
356 it over the previous contents of that file.
358 You will normally get mail from the system telling you when a file has
359 been saved after a crash.  The command
361 \fBex\fP \-\fBr\fP
363 will print a list of the files which have been saved for you.
364 (In the case of a hangup,
365 the file will not appear in the list,
366 although it can be recovered.)
367 .NH 1
368 Editing modes
370 .I Ex
371 has five distinct modes.  The primary mode is
372 .I command
373 mode.  Commands are entered in command mode when a `:' prompt is
374 present, and are executed each time a complete line is sent.  In
375 .I "text input"
376 mode
377 .I ex
378 gathers input lines and places them in the file.  The
379 .I append,
380 .I insert,
382 .I change
383 commands use text input mode.
384 No prompt is printed when you are in text input mode.
385 This mode is left by typing a `.' alone at the beginning of a line, and
386 .I command
387 mode resumes.
389 The last three modes are
390 .I open
392 .I visual
393 modes, entered by the commands of the same name, and, within open and
394 visual modes
395 .I "text insertion"
396 mode.
397 .I Open
399 .I visual
400 modes allow local editing operations to be performed on the text in the
401 file.  The
402 .I open
403 command displays one line at a time on any terminal while
404 .I visual
405 works on \s-2CRT\s0 terminals with random positioning cursors, using the
406 screen as a (single) window for file editing changes.
407 These modes are described (only) in
408 .I "An Introduction to Display Editing with Vi."
409 .NH 
410 Command structure
412 Most command names are English words,
413 and initial prefixes of the words are acceptable abbreviations.
414 The ambiguity of abbreviations is resolved in favor of the more commonly
415 used commands.*
417 * As an example, the command 
418 .I substitute
419 can be abbreviated `s'
420 while the shortest available abbreviation for the 
421 .I set
422 command is `se'.
424 .NH 2
425 Command parameters
427 Most commands accept prefix addresses specifying the lines in the file
428 upon which they are to have effect.
429 The forms of these addresses will be discussed below.
430 A number of commands also may take a trailing
431 .I count
432 specifying the number of lines to be involved in the command.\(dg
434 \(dg Counts are rounded down if necessary.
436 Thus the command ``10p'' will print the tenth line in the buffer while
437 ``delete 5'' will delete five lines from the buffer,
438 starting with the current line.
440 Some commands take other information or parameters,
441 this information always being given after the command name.\(dd
443 \(dd Examples would be option names in a
444 .I set
445 command i.e. ``set number'',
446 a file name in an
447 .I edit
448 command,
449 a regular expression in a
450 .I substitute
451 command,
452 or a target address for a
453 .I copy
454 command, i.e. ``1,5 copy 25''.
456 .NH 2
457 Command variants
459 A number of commands have two distinct variants.
460 The variant form of the command is invoked by placing an
461 `!' immediately after the command name.
462 Some of the default variants may be controlled by options;
463 in this case, the `!' serves to toggle the default.
464 .NH 2
465 Flags after commands
467 The characters `#', `p' and `l' may be placed after many commands.**
470 A `p' or `l' must be preceded by a blank or tab
471 except in the single special case `dp'.
473 In this case, the command abbreviated by these characters
474 is executed after the command completes.
475 Since
476 .I ex
477 normally prints the new current line after each change, `p' is rarely necessary.
478 Any number of `+' or `\-' characters may also be given with these flags.
479 If they appear, the specified offset is applied to the current line
480 value before the printing command is executed.
481 .NH 2
482 Comments
484 It is possible to give editor commands which are ignored.
485 This is useful when making complex editor scripts
486 for which comments are desired.
487 The comment character is the double quote: ".
488 Any command line beginning with " is ignored.
489 Comments beginning with " may also be placed at the ends
490 of commands, except in cases where they could be confused as part
491 of text (shell escapes and the substitute and map commands).
492 .NH 2
493 Multiple commands per line
495 More than one command may be placed on a line by separating each pair
496 of commands by a `|' character.
497 However the
498 .I global
499 commands,
500 comments,
501 and the shell escape `!'
502 must be the last command on a line, as they are not terminated by a `|'.
503 .NH 2
504 Reporting large changes
506 Most commands which change the contents of the editor buffer give
507 feedback if the scope of the change exceeds a threshold given by the
508 .I report
509 option.
510 This feedback helps to detect undesirably large changes so that they may
511 be quickly and easily reversed with an
512 .I undo.
513 After commands with more global effect such as
514 .I global
516 .I visual,
517 you will be informed if the net change in the number of lines
518 in the buffer during this command exceeds this threshold.
519 .NH 1
520 Command addressing
521 .NH 2
522 Addressing primitives
523 .IP \fB.\fR 20
524 The current line.
525 Most commands leave the current line as the last line which they affect.
526 The default address for most commands is the current line,
527 thus `\fB.\fR' is rarely used alone as an address.
528 .IP \fIn\fR 20
529 The \fIn\fRth line in the editor's buffer, lines being numbered
530 sequentially from 1.
531 .IP \fB$\fR 20
532 The last line in the buffer.
533 .IP \fB%\fR 20
534 An abbreviation for ``1,$'', the entire buffer.
535 .IP \fI+n\fR\ \fI\-n\fR 20
536 An offset relative to the current buffer line.\(dg
538 \(dg
539 The forms `.+3' `+3' and `+++' are all equivalent;
540 if the current line is line 100 they all address line 103.
542 .IP \fB/\fIpat\fR\fB/\fR\ \fB?\fIpat\fR\fB?\fR 20
543 Scan forward and backward respectively for a line containing \fIpat\fR, a
544 regular expression (as defined below).  The scans normally wrap around the end
545 of the buffer.
546 If all that is desired is to print the next line containing \fIpat\fR, then
547 the trailing \fB/\fR or \fB?\fR may be omitted.
548 If \fIpat\fP is omitted or explicitly empty, then the last
549 regular expression specified is located.\(dd
551 \(dd The forms \fB\e/\fP and \fB\e?\fP scan
552 using the last regular expression used in a scan; after a substitute
553 \fB//\fP and \fB??\fP would scan using the substitute's regular expression.
555 .IP \fB\(aa\(aa\fP\ \fB\(aa\fP\fIx\fP 20
556 Before each non-relative motion of the current line `\fB.\fP',
557 the previous current line is marked with a tag, subsequently referred to as
558 `\(aa\(aa'.
559 This makes it easy to refer or return to this previous context.
560 Marks may also be established by the
561 .I mark
562 command, using single lower case letters
563 .I x
564 and the marked lines referred to as
565 `\(aa\fIx\fR'.
566 .NH 2
567 Combining addressing primitives
569 Addresses to commands consist of a series of addressing primitives,
570 separated by `,' or `;'.
571 Such address lists are evaluated left-to-right.
572 When addresses are separated by `;' the current line `\fB.\fR'
573 is set to the value of the previous addressing expression
574 before the next address is interpreted.
575 If more addresses are given than the command requires,
576 then all but the last one or two are ignored.
577 If the command takes two addresses, the first addressed line must
578 precede the second in the buffer.\(dg
580 \(dg Null address specifications are permitted in a list of addresses,
581 the default in this case is the current line `.';
582 thus `,100' is equivalent to `\fB.\fR,100'.
583 It is an error to give a prefix address to a command which expects none.
585 .NH 1
586 Command descriptions
588 The following form is a prototype for all
589 .I ex
590 commands:
592 \fIaddress\fR \fBcommand\fR \fI! parameters count flags\fR
594 All parts are optional; the degenerate case is the empty command which prints
595 the next line in the file.  For sanity with use from within
596 .I visual
597 mode,
598 .I ex
599 ignores a ``:'' preceding any command.
601 In the following command descriptions, the
602 default addresses are shown in parentheses,
603 which are
604 .I not,
605 however,
606 part of the command.
608 \fBabbreviate\fR \fIword rhs\fP abbr: \fBab\fP
610 Add the named abbreviation to the current list.
611 When in input mode in visual, if
612 .I word
613 is typed as a complete word, it will be changed to
614 .I rhs .
616 ( \fB.\fR ) \fBappend\fR        abbr: \fBa\fR
618 \fItext\fR
620 \&\fB.\fR
622 Reads the input text and places it after the specified line.
623 After the command, `\fB.\fR'
624 addresses the last line input or the
625 specified line if no lines were input.
626 If address `0' is given,
627 text is placed at the beginning of the buffer.
629 \fBa!\fR
631 \fItext\fR
633 \&\fB.\fR
635 The variant flag to
636 .I append
637 toggles the setting for the
638 .I autoindent
639 option during the input of
640 .I text.
642 \fBargs\fR
644 The members of the argument list are printed, with the current argument
645 delimited by `[' and `]'.
648 \fBcd\fR \fIdirectory\fR
651 .I cd
652 command is a synonym for
653 .I chdir.
656 ( \fB.\fP , \fB.\fP ) \fBchange\fP \fIcount\fP  abbr: \fBc\fP
658 \fItext\fP
660 \&\fB.\fP
662 Replaces the specified lines with the input \fItext\fP.
663 The current line becomes the last line input;
664 if no lines were input it is left as for a
665 \fIdelete\fP.
667 \fBc!\fP
669 \fItext\fP
671 \&\fB.\fP
673 The variant toggles
674 .I autoindent
675 during the
676 .I change.
679 \fBchdir\fR \fIdirectory\fR
681 The specified \fIdirectory\fR becomes the current directory.
682 If no directory is specified, the current value of the
683 .I home
684 option is used as the target directory.
685 After a
686 .I chdir
687 the current file is not considered to have been
688 edited so that write restrictions on pre-existing files apply.
691 ( \fB.\fP , \fB.\fP )\|\fBcopy\fP \fIaddr\fP \fIflags\fP        abbr: \fBco\fP
694 .I copy
695 of the specified lines is placed after
696 .I addr,
697 which may be `0'.
698 The current line
699 `\fB.\fR'
700 addresses the last line of the copy.
701 The command
702 .I t
703 is a synonym for
704 .I copy.
706 ( \fB.\fR , \fB.\fR )\|\fBdelete\fR \fIbuffer\fR \fIcount\fR \fIflags\fR        abbr: \fBd\fR
708 Removes the specified lines from the buffer.
709 The line after the last line deleted becomes the current line;
710 if the lines deleted were originally at the end,
711 the new last line becomes the current line.
712 If a named
713 .I buffer
714 is specified by giving a letter,
715 then the specified lines are saved in that buffer,
716 or appended to it if an upper case letter is used.
718 \fBedit\fR \fIfile\fR   abbr: \fBe\fR
720 \fBex\fR \fIfile\fR
722 Used to begin an editing session on a new file.
723 The editor
724 first checks to see if the buffer has been modified since the last
725 .I write
726 command was issued.
727 If it has been,
728 a warning is issued and the
729 command is aborted.
731 command otherwise deletes the entire contents of the editor buffer,
732 makes the named file the current file and prints the new filename.
733 After insuring that this file is sensible\(dg
735 \(dg I.e., that it is not a binary file such as a directory,
736 a block or character special file other than
737 .I /dev/tty,
738 a terminal,
739 or a binary or executable file
740 (as indicated by the first word).
742 the editor reads the file into its buffer.
744 If the read of the file completes without error,
745 the number of lines and characters read is typed.
746 If there were any non-\s-2ASCII\s0 characters
747 in the file they are stripped of their non-\s-2ASCII\s0
748 high bits,
749 and any null characters in the file are discarded.
750 If none of these errors occurred, the file is considered
751 .I edited.
752 If the last line of the input file is missing the trailing
753 newline character, it will be supplied and a complaint will be issued.
754 This command leaves the current line `\fB.\fR' at the last line read.\(dd
756 \(dd If executed from within
757 .I open
759 .I visual,
760 the current line is initially the first line of the file.
763 \fBe!\fR \fIfile\fR
765 The variant form suppresses the complaint about modifications having
766 been made and not written from the editor buffer, thus
767 discarding all changes which have been made before editing the new file.
769 \fBe\fR \fB+\fIn\fR \fIfile\fR
771 Causes the editor to begin at line
772 .I n
773 rather than at the last line;
774 \fIn\fR may also be an editor command containing no spaces, e.g.: ``+/pat''.
776 \fBfile\fR      abbr: \fBf\fR
778 Prints the current file name,
779 whether it has been `[Modified]' since the last
780 .I write 
781 command,
782 whether it is
783 .I "read only" ,
784 the current line,
785 the number of lines in the buffer,
786 and the percentage of the way through the buffer of the current line.*
788 * In the rare case that the current file is `[Not edited]' this is
789 noted also; in this case you have to use the form \fBw!\fR to write to
790 the file, since the editor is not sure that a \fBwrite\fR will not
791 destroy a file unrelated to the current contents of the buffer.
794 \fBfile\fR \fIfile\fR
796 The current file name is changed to
797 .I file
798 which is considered 
799 `[Not edited]'.
801 ( 1 , $ ) \fBglobal\fR /\fIpat\|\fR/ \fIcmds\fR abbr: \fBg\fR
803 First marks each line among those specified which matches
804 the given regular expression.
805 Then the given command list is executed with `\fB.\fR' initially
806 set to each marked line.
808 The command list consists of the remaining commands on the current
809 input line and may continue to multiple lines by ending all but the
810 last such line with a `\e'.
812 .I cmds
813 (and possibly the trailing \fB/\fR delimiter) is omitted, each line matching
814 .I pat
815 is printed.
816 .I Append,
817 .I insert,
819 .I change
820 commands and associated input are permitted;
821 the `\fB.\fR' terminating input may be omitted if it would be on the
822 last line of the command list.
823 .I Open
825 .I visual
826 commands are permitted in the command list and take input from the terminal.
829 .I global
830 command itself may not appear in
831 .I cmds.
833 .I undo
834 command is also not permitted there,
836 .I undo
837 instead can be used to reverse the entire
838 .I global
839 command.
840 The options
841 .I autoprint
843 .I autoindent
844 are inhibited during a
845 .I global,
846 (and possibly the trailing \fB/\fR delimiter) and the value of the
847 .I report
848 option is temporarily infinite,
849 in deference to a \fIreport\fR for the entire global.
850 Finally, the context mark `\'\'' is set to the value of
851 `.' before the global command begins and is not changed during a global
852 command,
853 except perhaps by an
854 .I open
856 .I visual
857 within the
858 .I global.
860 \fBg!\fR \fB/\fIpat\fB/\fR \fIcmds\fR   abbr: \fBv\fR
862 The variant form of \fIglobal\fR runs \fIcmds\fR at each line not matching
863 \fIpat\fR.
865 ( \fB.\fR )\|\fBinsert\fR       abbr: \fBi\fR
867 \fItext\fR
869 \&\fB.\fR
871 Places the given text before the specified line.
872 The current line is left at the last line input;
873 if there were none input it is left at the line before the addressed line.
874 This command differs from
875 .I append
876 only in the placement of text.
879 \fBi!\fR
881 \fItext\fR
883 \&\fB.\fR
885 The variant toggles
886 .I autoindent
887 during the
888 .I insert.
891 ( \fB.\fR , \fB.\fR+1 ) \fBjoin\fR \fIcount\fR \fIflags\fR      abbr: \fBj\fR
893 Places the text from a specified range of lines
894 together on one line.
895 White space is adjusted at each junction to provide at least
896 one blank character, two if there was a `\fB.\fR' at the end of the line,
897 or none if the first following character is a `)'.
898 If there is already white space at the end of the line,
899 then the white space at the start of the next line will be discarded.
901 \fBj!\fR
903 The variant causes a simpler
904 .I join
905 with no white space processing; the characters in the lines are simply
906 concatenated.
908 ( \fB.\fR ) \fBk\fR \fIx\fR
911 .I k
912 command is a synonym for
913 .I mark.
914 It does not require a blank or tab before the following letter.
916 ( \fB.\fR , \fB.\fR ) \fBlist\fR \fIcount\fR \fIflags\fR
918 Prints the specified lines in a more unambiguous way:
919 tabs are printed as `^I'
920 and the end of each line is marked with a trailing `$'.
921 The current line is left at the last line printed.
923 \fBmap\fR \fIlhs\fR \fIrhs\fR
926 .I map
927 command is used to define macros for use in
928 .I visual
929 mode.
930 .I Lhs
931 should be a single character, or the sequence ``#n'', for n a digit,
932 referring to function key \fIn\fR.  When this character or function key
933 is typed in
934 .I visual
935 mode, it will be as though the corresponding \fIrhs\fR had been typed.
936 On terminals without function keys, you can type ``#n''.
937 See section 6.9 of the ``Introduction to Display Editing with Vi''
938 for more details.
940 ( \fB.\fR ) \fBmark\fR \fIx\fR
942 Gives the specified line mark
943 .I x,
944 a single lower case letter.
946 .I x
947 must be preceded by a blank or a tab.
948 The addressing form `\'x' then addresses this line.
949 The current line is not affected by this command.
951 ( \fB.\fR , \fB.\fR ) \fBmove\fR \fIaddr\fR     abbr: \fBm\fR
954 .I move
955 command repositions the specified lines to be after
956 .I addr .
957 The first of the moved lines becomes the current line.
959 \fBnext\fR      abbr: \fBn\fR
961 The next file from the command line argument list is edited.
963 \fBn!\fR
965 The variant suppresses warnings about the modifications to the buffer not
966 having been written out, discarding (irretrievably) any changes which may
967 have been made.
969 \fBn\fR \fIfilelist\fR
971 \fBn\fR \fB+\fIcommand\fR \fIfilelist\fR
973 The specified
974 .I filelist
975 is expanded and the resulting list replaces the
976 current argument list;
977 the first file in the new list is then edited.
979 .I command
980 is given (it must contain no spaces), then it is executed after editing the first such file.
982 ( \fB.\fR , \fB.\fR ) \fBnumber\fR \fIcount\fR \fIflags\fR      abbr: \fB#\fR or \fBnu\fR
984 Prints each specified line preceded by its buffer line
985 number.
986 The current line is left at the last line printed.
989 ( \fB.\fR ) \fBopen\fR \fIflags\fR      abbr: \fBo\fR
991 ( \fB.\fR ) \fBopen\fR /\fIpat\|\fR/ \fIflags\fR
993 Enters intraline editing \fIopen\fR mode at each addressed line.
995 .I pat
996 is given,
997 then the cursor will be placed initially at the beginning of the
998 string matched by the pattern.
999 To exit this mode use Q.
1001 .I "An Introduction to Display Editing with Vi"
1002 for more details.
1005 \fBpreserve\fR
1007 The current editor buffer is saved as though the system had just crashed.
1008 This command is for use only in emergencies when a
1009 .I write
1010 command has resulted in an error and you don't know how to save your work.
1011 After a
1012 .I preserve
1013 you should seek help.
1015 ( \fB.\fR , \fB.\fR )\|\fBprint\fR \fIcount\fR  abbr: \fBp\fR or \fBP\fR
1017 Prints the specified lines
1018 with non-printing characters printed as control characters `^\fIx\fR\|';
1019 delete (octal 177) is represented as `^?'.
1020 The current line is left at the last line printed.
1022 ( \fB.\fR )\|\fBput\fR \fIbuffer\fR     abbr: \fBpu\fR
1024 Puts back
1025 previously
1026 .I deleted
1028 .I yanked
1029 lines.
1030 Normally used with
1031 .I delete
1032 to effect movement of lines,
1033 or with
1034 .I yank
1035 to effect duplication of lines.
1036 If no
1037 .I buffer
1038 is specified, then the last
1039 .I deleted
1041 .I yanked
1042 text is restored.*
1044 * But no modifying commands may intervene between the
1045 .I delete
1047 .I yank
1048 and the
1049 .I put,
1050 nor may lines be moved between files without using a named buffer.
1052 By using a named buffer, text may be restored that was saved there at any
1053 previous time.
1055 \fBquit\fR      abbr: \fBq\fR
1057 Causes 
1058 .I ex
1059 to terminate.
1060 No automatic write of the editor buffer to a file is performed.
1061 However,
1062 .I ex
1063 issues a warning message if the file has changed
1064 since the last
1065 .I write
1066 command was issued, and does not
1067 .I quit.\(dg
1069 \(dg \fIEx\fR
1070 will also issue a diagnostic if there are more files in the argument
1071 list.
1073 Normally, you will wish to save your changes, and you 
1074 should give a \fIwrite\fR command;
1075 if you wish to discard them, use the \fBq!\fR command variant.
1077 \fBq!\fR
1079 Quits from the editor, discarding changes to the buffer without complaint.
1081 ( \fB.\fR ) \fBread\fR \fIfile\fR       abbr: \fBr\fR
1083 Places a copy of the text of the given file in the
1084 editing buffer after the specified line.
1085 If no 
1086 .I file
1087 is given the current file name is used.
1088 The current file name is not changed unless there is none in which
1089 case
1090 .I file
1091 becomes the current name.
1092 The sensibility restrictions for the 
1093 .I edit
1094 command apply here also.
1095 If the file buffer is empty and there is no current name then
1096 .I ex
1097 treats this as an
1098 .I edit
1099 command.
1101 Address `0' is legal for this command and causes the file to be read at
1102 the beginning of the buffer.
1103 Statistics are given as for the 
1104 .I edit
1105 command when the 
1106 .I read
1107 successfully terminates.
1108 After a
1109 .I read
1110 the current line is the last line read.\(dd
1112 \(dd Within
1113 .I open
1115 .I visual
1116 the current line is set to the first line read rather than the last.
1119 ( \fB.\fR ) \fBread\fR  \fB!\fR\fIcommand\fR
1121 Reads the output of the command
1122 .I command
1123 into the buffer after the specified line.
1124 This is not a variant form of the command, rather a read
1125 specifying a
1126 .I command
1127 rather than a 
1128 .I filename;
1129 a blank or tab before the \fB!\fR is mandatory.
1131 \fBrecover \fIfile\fR
1133 Recovers
1134 .I file
1135 from the system save area.
1136 Used after a accidental hangup of the phone**
1138 ** The system saves a copy of the file you were editing only if you
1139 have made changes to the file.
1141 or a system crash** or
1142 .I preserve
1143 command.
1144 Except when you use
1145 .I preserve
1146 you will be notified by mail when a file is saved.
1148 \fBrewind\fR    abbr: \fBrew\fR
1150 The argument list is rewound, and the first file in the list is edited.
1152 \fBrew!\fR
1154 Rewinds the argument list discarding any changes made to the current buffer.
1156 \fBset\fR \fIparameter\fR
1158 With no arguments, prints those options whose values have been
1159 changed from their defaults;
1160 with parameter
1161 .I all
1162 it prints all of the option values.
1164 Giving an option name followed by a `?'
1165 causes the current value of that option to be printed.
1166 The `?' is unnecessary unless the option is Boolean valued.
1167 Boolean options are given values either by the form
1168 `set \fIoption\fR' to turn them on or
1169 `set no\fIoption\fR' to turn them off;
1170 string and numeric options are assigned via the form
1171 `set \fIoption\fR=value'.
1173 More than one parameter may be given to 
1174 .I set \|;
1175 they are interpreted left-to-right.
1177 \fBshell\fR     abbr: \fBsh\fR
1179 A new shell is created.
1180 When it terminates, editing resumes.
1182 \fBsource\fR \fIfile\fR abbr: \fBso\fR
1184 Reads and executes commands from the specified file.
1185 .I Source
1186 commands may be nested.
1188 ( \fB.\fR , \fB.\fR ) \fBsubstitute\fR /\fIpat\fR\|/\fIrepl\fR\|/ \fIoptions\fR \fIcount\fR \fIflags\fR abbr: \fBs\fR
1190 On each specified line, the first instance of pattern
1191 .I pat
1192 is replaced by replacement pattern
1193 .I repl.
1194 If the
1195 .I global
1196 indicator option character `g'
1197 appears, then all instances are substituted;
1198 if the
1199 .I confirm
1200 indication character `c' appears,
1201 then before each substitution the line to be substituted
1202 is typed with the string to be substituted marked
1203 with `\(ua' characters.
1204 By typing an `y' one can cause the substitution to be performed,
1205 any other input causes no change to take place.
1206 After a
1207 .I substitute
1208 the current line is the last line substituted.
1210 Lines may be split by substituting
1211 new-line characters into them.
1212 The newline in
1213 .I repl
1214 must be escaped by preceding it with a `\e'.
1215 Other metacharacters available in
1216 .I pat
1218 .I repl
1219 are described below.
1221 .B stop
1223 Suspends the editor, returning control to the top level shell.
1225 .I autowrite
1226 is set and there are unsaved changes,
1227 a write is done first unless the form
1228 .B stop !
1229 is used.
1230 This commands is only available where supported by the teletype driver
1231 and operating system.
1233 ( \fB.\fR , \fB.\fR ) \fBsubstitute\fR \fIoptions\fR \fIcount\fR \fIflags\fR    abbr: \fBs\fR
1236 .I pat
1238 .I repl
1239 are omitted, then the last substitution is repeated.
1240 This is a synonym for the
1241 .B &
1242 command.
1244 ( \fB.\fR , \fB.\fR ) \fBt\fR \fIaddr\fR \fIflags\fR
1247 .I t
1248 command is a synonym for 
1249 .I copy .
1251 \fBta\fR \fItag\fR
1253 The focus of editing switches to the location of
1254 .I tag,
1255 switching to a different line in the current file where it is defined,
1256 or if necessary to another file.\(dd
1258 \(dd If you have modified the current file before giving a
1259 .I tag
1260 command, you must write it out; giving another
1261 .I tag
1262 command, specifying no
1263 .I tag
1264 will reuse the previous tag.
1267 The tags file is normally created by a program such as
1268 .I ctags,
1269 and consists of a number of lines with three fields separated by blanks
1270 or tabs.  The first field gives the name of the tag,
1271 the second the name of the file where the tag resides, and the third
1272 gives an addressing form which can be used by the editor to find the tag;
1273 this field is usually a contextual scan using `/\fIpat\fR/' to be immune
1274 to minor changes in the file.  Such scans are always performed as if
1275 .I nomagic
1276 was set.
1278 The tag names in the tags file must be sorted alphabetically.
1280 \fBunabbreviate\fR \fIword\fP   abbr: \fBuna\fP
1282 Delete
1283 .I word
1284 from the list of abbreviations.
1286 \fBundo\fR      abbr: \fBu\fR
1288 Reverses the changes made in the buffer by the last
1289 buffer editing command.
1290 Note that
1291 .I global
1292 commands are considered a single command for the purpose of 
1293 .I undo
1294 (as are
1295 .I open
1297 .I visual.)
1298 Also, the commands
1299 .I write
1301 .I edit
1302 which interact with the
1303 file system cannot be undone.
1304 .I Undo
1305 is its own inverse.
1307 .I Undo
1308 always marks the previous value of the current line `\fB.\fR'
1309 as `\'\''.
1310 After an
1311 .I undo
1312 the current line is the first line restored
1313 or the line before the first line deleted if no lines were restored.
1314 For commands with more global effect
1315 such as
1316 .I global
1318 .I visual
1319 the current line regains it's pre-command value after an
1320 .I undo.
1322 \fBunmap\fR \fIlhs\fR
1324 The macro expansion associated by
1325 .I map
1327 .I lhs
1328 is removed.
1330 ( 1 , $ ) \fBv\fR /\fIpat\fR\|/ \fIcmds\fR
1332 A synonym for the
1333 .I global
1334 command variant \fBg!\fR, running the specified \fIcmds\fR on each
1335 line which does not match \fIpat\fR.
1337 \fBversion\fR   abbr: \fBve\fR
1339 Prints the current version number of the editor
1340 as well as the date the editor was last changed.
1342 ( \fB.\fR ) \fBvisual\fR \fItype\fR \fIcount\fR \fIflags\fR     abbr: \fBvi\fR
1344 Enters visual mode at the specified line.
1345 .I Type
1346 is optional and may be `\-' , `\(ua' or `\fB.\fR'
1347 as in the
1348 .I z
1349 command to specify the placement of the specified line on the screen.
1350 By default, if
1351 .I type
1352 is omitted, the specified line is placed as the first on the screen.
1354 .I count
1355 specifies an initial window size; the default is the value of the option
1356 .I window.
1357 See the document
1358 .I "An Introduction to Display Editing with Vi"
1359 for more details.
1360 To exit this mode, type Q.
1362 \fBvisual\fP file
1364 \fBvisual\fP +\fIn\fP file
1366 From visual mode,
1367 this command is the same as edit.
1369 ( 1 , $ ) \fBwrite\fR \fIfile\fR        abbr: \fBw\fR
1371 Writes changes made back to \fIfile\fR, printing the number of lines and
1372 characters written.
1373 Normally \fIfile\fR is omitted and the text goes back where it came from.
1374 If a \fIfile\fR is specified, then text will be written to that file.*
1376 * The editor writes to a file only if it is
1377 the current file and is
1378 .I edited ,
1379 if the file does not exist,
1380 or if the file is actually a teletype,
1381 .I /dev/tty,
1382 .I /dev/null.
1383 Otherwise, you must give the variant form \fBw!\fR to force the write.
1385 If the file does not exist it is created.
1386 The current file name is changed only if there is no current file
1387 name; the current line is never changed.
1389 If an error occurs while writing the current and
1390 .I edited
1391 file, the editor
1392 considers that there has been ``No write since last change''
1393 even if the buffer had not previously been modified.
1395 ( 1 , $ ) \fBwrite>>\fR \fIfile\fR      abbr: \fBw>>\fR
1397 Writes the buffer contents at the end of
1398 an existing file.
1401 \fBw!\fR \fIname\fR
1403 Overrides the checking of the normal \fIwrite\fR command,
1404 and will write to any file which the system permits.
1406 ( 1 , $ ) \fBw\fR  \fB!\fR\fIcommand\fR
1408 Writes the specified lines into 
1409 .I command.
1410 Note the difference between \fBw!\fR which overrides checks and
1411 \fBw\ \ !\fR which writes to a command.
1413 \fBwq\fR \fIname\fR
1415 Like a \fIwrite\fR and then a \fIquit\fR command.
1417 \fBwq!\fR \fIname\fR
1419 The variant overrides checking on the sensibility of the
1420 .I write
1421 command, as \fBw!\fR does.
1423 \fBxit\fP \fIname\fR
1425 If any changes have been made and not written, writes the buffer out.
1426 Then, in any case, quits.
1428 ( \fB.\fR , \fB.\fR )\|\fByank\fR \fIbuffer\fR \fIcount\fR      abbr: \fBya\fR
1430 Places the specified lines in the named
1431 .I buffer,
1432 for later retrieval via
1433 .I put.
1434 If no buffer name is specified, the lines go to a more volatile place;
1435 see the \fIput\fR command description.
1437 ( \fB.+1\fR ) \fBz\fR \fIcount\fR
1439 Print the next \fIcount\fR lines, default \fIwindow\fR.
1441 ( \fB.\fR ) \fBz\fR \fItype\fR \fIcount\fR
1443 Prints a window of text with the specified line at the top.
1444 If \fItype\fR is `\-' the line is placed at the bottom; a `\fB.\fR' causes
1445 the line to be placed in the center.*
1446 A count gives the number of lines to be displayed rather than
1447 double the number specified by the \fIscroll\fR option.
1448 On a \s-2CRT\s0 the screen is cleared before display begins unless a
1449 count which is less than the screen size is given.
1450 The current line is left at the last line printed.
1452 * Forms `z=' and `z\(ua' also exist; `z=' places the current line in the
1453 center, surrounds it with lines of `\-' characters and leaves the current
1454 line at this line.  The form `z\(ua' prints the window before `z\-'
1455 would.  The characters `+', `\(ua' and `\-' may be repeated for cumulative
1456 effect.
1457 On some v2 editors, no
1458 .I type
1459 may be given.
1462 \fB!\fR \fIcommand\fR\fR
1464 The remainder of the line after the `!' character is sent to a shell
1465 to be executed.
1466 Within the text of
1467 .I command
1468 the characters 
1469 `%' and `#' are expanded as in filenames and the character
1470 `!' is replaced with the text of the previous command.
1471 Thus, in particular,
1472 `!!' repeats the last such shell escape.
1473 If any such expansion is performed, the expanded line will be echoed.
1474 The current line is unchanged by this command.
1476 If there has been ``[No\ write]'' of the buffer contents since the last
1477 change to the editing buffer, then a diagnostic will be printed
1478 before the command is executed as a warning.
1479 A single `!' is printed when the command completes.
1481 ( \fIaddr\fR , \fIaddr\fR ) \fB!\fR \fIcommand\fR\fR
1483 Takes the specified address range and supplies it as
1484 standard input to
1485 .I command;
1486 the resulting output then replaces the input lines.
1488 ( $ ) \fB=\fR
1490 Prints the line number of the
1491 addressed line.
1492 The current line is unchanged.
1495 ( \fB.\fR , \fB.\fR ) \fB>\fR \fIcount\fR \fIflags\fR
1497 ( \fB.\fR , \fB.\fR ) \fB<\fR \fIcount\fR \fIflags\fR
1499 Perform intelligent shifting on the specified lines;
1500 \fB<\fR shifts left and \fB>\fR shift right.
1501 The quantity of shift is determined by the
1502 .I shiftwidth
1503 option and the repetition of the specification character.
1504 Only white space (blanks and tabs) is shifted;
1505 no non-white characters are discarded in a left-shift.
1506 The current line becomes the last line which changed due to the
1507 shifting.
1510 \fB^D\fR
1512 An end-of-file from a terminal input scrolls through the file.
1514 .I scroll
1515 option specifies the size of the scroll, normally a half screen of text.
1517 ( \fB.\fR+1 , \fB.\fR+1 )
1519 ( \fB.\fR+1 , \fB.\fR+1 ) |
1521 An address alone causes the addressed lines to be printed.
1522 A blank line prints the next line in the file.
1524 ( \fB.\fR , \fB.\fR ) \fB&\fR \fIoptions\fR \fIcount\fR \fIflags\fR
1526 Repeats the previous
1527 .I substitute
1528 command.
1530 ( \fB.\fR , \fB.\fR ) \fB\s+2~\s0\fR \fIoptions\fR \fIcount\fR \fIflags\fR
1532 Replaces the previous regular expression with the previous
1533 replacement pattern from a substitution.
1534 .NH 1
1535 Regular expressions and substitute replacement patterns
1536 .NH 2
1537 Regular expressions
1539 A regular expression specifies a set of strings of characters.
1540 A member of this set of strings is said to be
1541 .I matched
1542 by the regular expression.
1543 .I Ex
1544 remembers two previous regular expressions:
1545 the previous regular expression used in a
1546 .I substitute
1547 command
1548 and the previous regular expression used elsewhere
1549 (referred to as the previous \fIscanning\fR regular expression.)
1550 The previous regular expression
1551 can always be referred to by a null \fIre\fR, e.g. `//' or `??'.
1552 .NH 2
1553 Magic and nomagic
1555 The regular expressions allowed by
1556 .I ex 
1557 are constructed in one of two ways depending on the setting of
1559 .I magic
1560 option.
1562 .I ex
1564 .I vi
1565 default setting of
1566 .I magic
1567 gives quick access to a powerful set of regular expression
1568 metacharacters.
1569 The disadvantage of
1570 .I magic
1571 is that the user must remember that these metacharacters are
1572 .I magic
1573 and precede them with the character `\e'
1574 to use them as ``ordinary'' characters.
1575 With
1576 .I nomagic,
1577 the default for
1578 .I edit,
1579 regular expressions are much simpler,
1580 there being only two metacharacters.
1581 The power of the other metacharacters is still available by preceding
1582 the (now) ordinary character with a `\e'.
1583 Note that `\e' is thus always a metacharacter.
1585 The remainder of the discussion of regular expressions assumes
1586 that
1587 that the setting of this option is
1588 .I magic.\(dg
1590 \(dg To discern what is true with
1591 .I nomagic
1592 it suffices to remember that the only
1593 special characters in this case will be `\(ua' at the beginning
1594 of a regular expression,
1595 `$' at the end of a regular expression,
1596 and `\e'.
1597 With
1598 .I nomagic
1599 the characters `\s+2~\s0' and `&' also lose their special meanings
1600 related to the replacement pattern of a substitute.
1602 .NH 2
1603 Basic regular expression summary
1605 The following basic constructs are used to construct
1606 .I magic
1607 mode regular expressions.
1608 .IP \fIchar\fR 15
1609 An ordinary character matches itself.
1610 The characters `\(ua' at the beginning of a line,
1611 `$' at the end of line,
1612 `*' as any character other than the first,
1613 `.', `\e', `[', and `\s+2~\s0' are not ordinary characters and
1614 must be escaped (preceded) by `\e' to be treated as such.
1615 .IP \fB\(ua\fR
1616 At the beginning of a pattern
1617 forces the match to succeed only at the beginning of a line.
1618 .IP \fB$\fR
1619 At the end of a regular expression forces the match to
1620 succeed only at the end of the line.
1621 .IP \&\fB.\fR
1622 Matches any single character except
1623 the new-line character.
1624 .IP \fB\e<\fR
1625 Forces the match
1626 to occur only at the beginning of a ``variable'' or ``word'';
1627 that is, either at the beginning of a line, or just before
1628 a letter, digit, or underline and after a character not one of
1629 these.
1630 .IP \fB\e>\fR
1631 Similar to `\e<', but matching the end of a ``variable''
1632 or ``word'', i.e. either the end of the line or before character
1633 which is neither a letter, nor a digit, nor the underline character.
1634 .IP \fB[\fIstring\fR]\fR
1635 Matches any (single) character in the class defined by
1636 .I string.
1637 Most characters in
1638 .I string
1639 define themselves.
1640 A pair of characters separated by `\-' in
1641 .I string
1642 defines the set of characters collating between the specified lower and upper
1643 bounds, thus `[a\-z]' as a regular expression matches
1644 any (single) lower-case letter.
1645 If the first character of
1646 .I string
1647 is an `\(ua' then the construct
1648 matches those characters which it otherwise would not;
1649 thus `[\(uaa\-z]' matches anything but a lower-case letter (and of course a
1650 newline).
1651 To place any of the characters
1652 `\(ua', `[', or `\-' in
1653 .I string
1654 you must escape them with a preceding `\e'.
1655 .NH 2
1656 Combining regular expression primitives
1658 The concatenation of two regular expressions matches the leftmost and
1659 then longest string
1660 which can be divided with the first piece matching the first regular
1661 expression and the second piece matching the second.
1662 Any of the (single character matching) regular expressions mentioned
1663 above may be followed by the character `*' to form a regular expression
1664 which matches any number of adjacent occurrences (including 0) of characters
1665 matched by the regular expression it follows.
1667 The character `\s+2~\s0' may be used in a regular expression,
1668 and matches the text which defined the replacement part
1669 of the last
1670 .I substitute
1671 command.
1672 A regular expression may be enclosed between the sequences
1673 `\e(' and `\e)' with side effects in the
1674 .I substitute
1675 replacement patterns.
1676 .NH 2
1677 Substitute replacement patterns
1679 The basic metacharacters for the replacement pattern are
1680 `&' and `~'; these are
1681 given as `\e&' and `\e~' when
1682 .I nomagic
1683 is set.
1684 Each instance of `&' is replaced by the characters
1685 which the regular expression matched.
1686 The metacharacter `~' stands, in the replacement pattern,
1687 for the defining text of the previous replacement pattern.
1689 Other metasequences possible in the replacement pattern
1690 are always introduced by the escaping character `\e'.
1691 The sequence `\e\fIn\fR' is replaced by the text matched
1692 by the \fIn\fR-th regular subexpression enclosed between
1693 `\e(' and `\e)'.\(dg
1695 \(dg When nested, parenthesized subexpressions are present,
1696 \fIn\fR is determined by counting occurrences of `\e(' starting from the left.
1698 The sequences `\eu' and `\el' cause the immediately following character in
1699 the replacement to be converted to upper- or lower-case respectively
1700 if this character is a letter.
1701 The sequences `\eU' and `\eL' turn such conversion on, either until
1702 `\eE' or `\ee' is encountered, or until the end of the replacement pattern.
1703 .de LC
1705 .sp .1i
1706 .ne 4
1708 .ta 3i
1710 .NH 1
1711 Option descriptions
1714 \fBautoindent\fR, \fBai\fR      default: noai
1716 Can be used to ease the preparation of structured program text.
1717 At the beginning of each
1718 .I append ,
1719 .I change
1721 .I insert
1722 command
1723 or when a new line is
1724 .I opened
1725 or created by an
1726 .I append ,
1727 .I change ,
1728 .I insert ,
1730 .I substitute
1731 operation within
1732 .I open
1734 .I visual
1735 mode,
1736 .I ex
1737 looks at the line being appended after,
1738 the first line changed
1739 or the line inserted before and calculates the amount of white space
1740 at the start of the line.
1741 It then aligns the cursor at the level of indentation so determined.
1743 If the user then types lines of text in,
1744 they will continue to be justified at the displayed indenting level.
1745 If more white space is typed at the beginning of a line,
1746 the following line will start aligned with the first non-white character
1747 of the previous line.
1748 To back the cursor up to the preceding tab stop one can hit
1749 \fB^D\fR.
1750 The tab stops going backwards are defined at multiples of the
1751 .I shiftwidth
1752 option.
1754 .I cannot
1755 backspace over the indent,
1756 except by sending an end-of-file with a \fB^D\fR.
1758 Specially processed in this mode is a line with no characters added
1759 to it, which turns into a completely blank line (the white
1760 space provided for the
1761 .I autoindent
1762 is discarded.)
1763 Also specially processed in this mode are lines beginning with
1764 an `\(ua' and immediately followed by a \fB^D\fR.
1765 This causes the input to be repositioned at the beginning of the line,
1766 but retaining the previous indent for the next line.
1767 Similarly, a `0' followed by a \fB^D\fR
1768 repositions at the beginning but without
1769 retaining the previous indent.
1771 .I Autoindent
1772 doesn't happen in
1773 .I global
1774 commands or when the input is not a terminal.
1776 \fBautoprint\fR, \fBap\fR       default: ap
1778 Causes the current line to be printed after each
1779 .I delete ,
1780 .I copy ,
1781 .I join ,
1782 .I move ,
1783 .I substitute ,
1784 .I t ,
1785 .I undo
1787 shift command.
1788 This has the same effect as supplying a trailing `p'
1789 to each such command.
1790 .I Autoprint
1791 is suppressed in globals,
1792 and only applies to the last of many commands on a line.
1794 \fBautowrite\fR, \fBaw\fR       default: noaw
1796 Causes the contents of the buffer to be written to the current file
1797 if you have modified it and give a
1798 .I next,
1799 .I rewind,
1800 .I stop,
1801 .I tag,
1803 .I !
1804 command, or a \fB^\(ua\fR (switch files) or \fB^]\fR (tag goto) command
1806 .I visual.
1807 Note, that the
1808 .I edit
1810 .I ex
1811 commands do
1812 .B not
1813 autowrite.
1814 In each case, there is an equivalent way of switching when autowrite
1815 is set to avoid the
1816 .I autowrite
1817 (\fIedit\fR
1819 .I next ,
1820 .I rewind!
1821 for .I rewind ,
1822 .I stop!
1824 .I stop ,
1825 .I tag!
1827 .I tag ,
1828 .I shell
1830 .I ! ,
1832 \fB:e\ #\fR and a \fB:ta!\fR command from within
1833 .I visual).
1835 \fBbeautify\fR, \fBbf\fR        default: nobeautify
1837 Causes all control characters except tab, newline and form-feed
1838 to be discarded from the input.
1839 A complaint is registered the first time a
1840 backspace character is discarded.
1841 .I Beautify
1842 does not apply to command input.
1844 \fBdirectory\fR, \fBdir\fR      default: dir=/tmp
1846 Specifies the directory in which
1847 .I ex
1848 places its buffer file.
1849 If this directory in not
1850 writable, then the editor will exit abruptly when it fails to be
1851 able to create its buffer there.
1853 \fBedcompatible\fR      default: noedcompatible
1855 Causes the presence of absence of
1856 .B g
1858 .B c
1859 suffixes on substitute commands to be remembered, and to be toggled
1860 by repeating the suffices.  The suffix
1861 .B r
1862 makes the substitution be as in the
1863 .I ~
1864 command, instead of like
1865 .I &.
1867 \fBerrorbells\fR, \fBeb\fR      default: noeb
1869 Error messages are preceded by a bell.*
1871 * Bell ringing in
1872 .I open
1874 .I visual
1875 on errors is not suppressed by setting
1876 .I noeb.
1878 If possible the editor always places the error message in a standout mode of the
1879 terminal (such as inverse video) instead of ringing the bell.
1881 \fBhardtabs\fR, \fBht\fR        default: ht=8
1883 Gives the boundaries on which terminal hardware tabs are set (or
1884 on which the system expands tabs).
1886 \fBignorecase\fR, \fBic\fR      default: noic
1888 All upper case characters in the text are mapped to lower case in regular
1889 expression matching.
1890 In addition, all upper case characters in regular expressions are mapped
1891 to lower case except in character class specifications.
1893 \fBlisp\fR      default: nolisp
1895 \fIAutoindent\fR indents appropriately for
1896 .I lisp
1897 code, and the \fB( ) { } [[\fR and \fB]]\fR commands in
1898 .I open
1900 .I visual
1901 are modified to have meaning for \fIlisp\fR.
1903 \fBlist\fR      default: nolist
1905 All printed lines will be displayed (more) unambiguously,
1906 showing tabs and end-of-lines as in the
1907 .I list
1908 command.
1910 \fBmagic\fR     default: magic for \fIex\fR and \fIvi\fR\(dg
1912 \(dg \fINomagic\fR for \fIedit\fR.
1916 .I nomagic
1917 is set, the number of regular expression metacharacters is greatly reduced,
1918 with only `\(ua' and `$' having special effects.
1919 In addition the metacharacters
1923 of the replacement pattern are treated as normal characters.
1924 All the normal metacharacters may be made
1925 .I magic
1926 when
1927 .I nomagic
1928 is set by preceding them with a `\e'.
1930 \fBmesg\fR      default: mesg
1932 Causes write permission to be turned off to the terminal
1933 while you are in visual mode, if
1934 .I nomesg
1935 is set.
1937 \fBmodeline\fR  default: nomodeline
1940 .I modeline
1941 is set, then the first 5 lines and the last five lines of the file
1942 will be checked for ex command lines and the comands issued.
1943 To be recognized as a command line, the line must have the string
1944 .B ex:
1946 .B vi:
1947 preceeded by a tab or a space.  This string may be anywhere in the
1948 line and anything after the 
1949 .I :
1950 is interpeted as editor commands.  This option defaults to off because
1951 of unexpected behavior when editting files such as
1952 .I /etc/passwd.
1954 \fBnumber, nu\fR        default: nonumber
1956 Causes all output lines to be printed with their
1957 line numbers.
1958 In addition each input line will be prompted for by supplying the line number
1959 it will have.
1961 \fBopen\fR      default: open
1963 If \fInoopen\fR, the commands
1964 .I open
1966 .I visual
1967 are not permitted.
1968 This is set for
1969 .I edit
1970 to prevent confusion resulting from accidental entry to 
1971 open or visual mode.
1973 \fBoptimize, opt\fR     default: optimize
1975 Throughput of text is expedited by setting the terminal
1976 to not do automatic carriage returns
1977 when printing more than one (logical) line of output,
1978 greatly speeding output on terminals without addressable
1979 cursors when text with leading white space is printed.
1981 \fBparagraphs,\ para\fR default: para=IPLPPPQPP\0LIbp
1983 Specifies the paragraphs for the \fB{\fR and \fB}\fR operations in
1984 .I open
1985 and 
1986 .I visual.
1987 The pairs of characters in the option's value are the names
1988 of the macros which start paragraphs.
1990 \fBprompt\fR    default: prompt
1992 Command mode input is prompted for with a `:'.
1994 \fBredraw\fR    default: noredraw
1996 The editor simulates (using great amounts of output), an intelligent
1997 terminal on a dumb terminal (e.g. during insertions in
1998 .I visual
1999 the characters to the right of the cursor position are refreshed
2000 as each input character is typed.)
2001 Useful only at very high speed.
2003 \fBremap\fP     default: remap
2005 If on, macros are repeatedly tried until they are unchanged.
2006 For example, if
2007 .B o
2008 is mapped to
2009 .B O ,
2011 .B O
2012 is mapped to
2013 .B I ,
2014 then if
2015 .I remap
2016 is set,
2017 .B o
2018 will map to
2019 .B I ,
2020 but if
2021 .I noremap
2022 is set, it will map to
2023 .B O .
2025 \fBreport\fR    default: report=5\(dg
2027 \(dg 2 for \fIedit\fR.
2030 Specifies a threshold for feedback from commands.
2031 Any command which modifies more than the specified number of lines
2032 will provide feedback as to the scope of its changes.
2033 For commands such as
2034 .I global ,
2035 .I open ,
2036 .I undo ,
2038 .I visual
2039 which have potentially more far reaching scope,
2040 the net change in the number of lines in the buffer is
2041 presented at the end of the command, subject to this same threshold.
2042 Thus notification is suppressed during a
2043 .I global
2044 command on the individual commands performed.
2046 \fBscroll\fR    default: scroll=\(12 window
2048 Determines the number of logical lines scrolled when an end-of-file
2049 is received from a terminal input in command mode,
2050 and the number of lines printed by a command mode
2051 .I z
2052 command (double the value of
2053 .I scroll ).
2055 \fBsections\fR  default: sections=SHNHH\0HU
2057 Specifies the section macros for the \fB[[\fR and \fB]]\fR operations
2059 .I open
2061 .I visual.
2062 The pairs of characters in the options's value are the names
2063 of the macros which start paragraphs.
2065 \fBshell\fR, \fBsh\fR   default: sh=/bin/sh
2067 Gives the path name of the shell forked for 
2068 the shell escape command `!', and by the
2069 .I shell
2070 command.
2071 The default is taken from SHELL in the environment, if present.
2073 \fBshiftwidth\fR, \fBsw\fR      default: sw=8
2075 Gives the width a software tab stop,
2076 used in reverse tabbing with \fB^D\fR when using
2077 .I autoindent
2078 to append text,
2079 and by the shift commands.
2081 \fBshowmatch, sm\fR     default: nosm
2084 .I open
2086 .I visual
2087 mode, when a \fB)\fR or \fB}\fR is typed, move the cursor to the matching
2088 \fB(\fR or \fB{\fR for one second if this matching character is on the
2089 screen.  Extremely useful with
2090 .I lisp.
2092 \fBslowopen, slow\fR    terminal dependent
2094 Affects the display algorithm used in
2095 .I visual
2096 mode, holding off display updating during input of new text to improve
2097 throughput when the terminal in use is both slow and unintelligent.
2099 .I "An Introduction to Display Editing with Vi"
2100 for more details.
2102 \fBtabstop,\ ts\fR      default: ts=8
2104 The editor expands tabs in the input file to be on
2105 .I tabstop
2106 boundaries for the purposes of display.
2108 \fBtaglength,\ tl\fR    default: tl=0
2110 Tags are not significant beyond this many characters.
2111 A value of zero (the default) means that all characters are significant.
2113 \fBtags\fR      default: tags=tags /usr/lib/tags
2115 A path of files to be used as tag files for the
2116 .I tag
2117 command.
2118 A requested tag is searched for in the specified files, sequentially.
2119 By default, files called
2120 .B tags
2121 are searched for in the current directory and in /usr/lib
2122 (a master file for the entire system).
2124 \fBterm\fR      from environment TERM
2126 The terminal type of the output device.
2128 \fBterse\fR     default: noterse
2130 Shorter error diagnostics are produced for the experienced user.
2132 \fBwarn\fR      default: warn
2134 Warn if there has been `[No write since last change]' before a `!'
2135 command escape.
2137 \fBwindow\fR    default: window=speed dependent
2139 The number of lines in a text window in the
2140 .I visual
2141 command.
2142 The default is 8 at slow speeds (600 baud or less),
2143 16 at medium speed (1200 baud),
2144 and the full screen (minus one line) at higher speeds.
2146 \fBw300,\ w1200\, w9600\fR
2148 These are not true options but set
2149 .B window
2150 only if the speed is slow (300), medium (1200), or high (9600),
2151 respectively.
2152 They are suitable for an EXINIT
2153 and make it easy to change the 8/16/full screen rule.
2155 \fBwrapscan\fR, \fBws\fR        default: ws
2157 Searches using the regular expressions in addressing
2158 will wrap around past the end of the file.
2160 \fBwrapmargin\fR, \fBwm\fR      default: wm=0
2162 Defines a margin for automatic wrapover of text during input in
2163 .I open
2165 .I visual
2166 modes.  See
2167 .I "An Introduction to Text Editing with Vi"
2168 for details.
2170 \fBwriteany\fR, \fBwa\fR        default: nowa
2172 Inhibit the checks normally made before
2173 .I write
2174 commands, allowing a write to any file which the system protection
2175 mechanism will allow.
2176 .NH 1
2177 Acknowledgements
2179 Chuck Haley contributed greatly to the early development of
2180 .I ex.
2181 Bruce Englar encouraged the redesign which led to
2182 .I ex
2183 version 1.
2184 Bill Joy wrote versions 1 and 2.0 through 2.7,
2185 and created the framework that users see in the present editor.
2186 Mark Horton added macros and other features and made the
2187 editor work on a large number of terminals and Unix systems.