forked from ffimnsr-archive/ex-vi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex.1
2045 lines (2045 loc) · 57.7 KB
/
ex.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.\"
.\" This code contains changes by
.\" Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved.
.\"
.\" Conditions 1, 2, and 4 and the no-warranty notice below apply
.\" to these changes.
.\"
.\"
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"
.\" Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" Redistributions of source code and documentation must retain the
.\" above copyright notice, this list of conditions and the following
.\" disclaimer.
.\" Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed or owned by Caldera
.\" International, Inc.
.\" Neither the name of Caldera International, Inc. nor the names of
.\" other contributors may be used to endorse or promote products
.\" derived from this software without specific prior written permission.
.\"
.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE
.\" LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" from ex.1 6.4.1 (2.11BSD) 1996/10/21
.\"
.\" Sccsid @(#)ex.1 1.44 (gritter) 12/1/04
.\"
.ie \n(.g==1 \{\
.ds lq \(lq
.ds rq \(rq
.\}
.el \{\
.ds lq ``
.ds rq ''
.\}
.TH EX 1 "12/1/04" "Ancient Unix Ports" "User Commands"
.SH NAME
ex, edit \- text editor
.SH SYNOPSIS
.HP
.ad l
\fBex\fR [\fB\-c\fI\ command\fR|\fB+\fIcommand\fR]
[\fB\-r\fR\ [\fIfilename\fR]] [\fB\-s\fR|\fB\-\fR]
[\fB\-t\fI\ tagstring\fR] [\fB\-w\fI\ size\fR]
[\fB\-lLRvV\fR] [\fIfile\fR ...]
.HP
.ad l
\fBedit\fR [\fB\-c\fI\ command\fR|\fB+\fIcommand\fR]
[\fB\-r\fR\ [\fIfilename\fR]] [\fB\-s\fR|\fB\-\fR]
[\fB\-t\fI\ tagstring\fR] [\fB\-w\fI\ size\fR]
[\fB\-lLRvV\fR] [\fIfile\fR ...]
.br
.ad b
.SH DESCRIPTION
.I Ex
is the root of a family of editors:
.I edit,
.I ex
and
.I vi.
.I Ex
is a superset of
.I ed,
with the most notable extension being a display editing facility.
Display based editing on
.SM CRT
terminals is the focus of
.IR vi .
.PP
For those who have not used
.I ed,
or for casual users, the editor
.I edit
may be convenient.
It avoids some of the complexities of
.I ex
used mostly by systems programmers and persons very familiar with
.I ed.
.PP
The following options are accepted:
.TP
\fB\-c\fP\fI\ command\fP or \fB+\fP\fIcommand\fP
Execute
.I command
when editing begins.
.TP
.B \-l
Start in a special mode useful for the
.I Lisp
programming language.
.TP
\fB\-r\fI\ [filename]\fR or \fB\-L\fR
When no argument is supplied with this option,
all files to be recovered are listed
and the editor exits immediately.
If a
.I filename
is specified,
the corresponding temporary file is opened in recovery mode.
.TP
.B \-R
Files are opened read-only when this option is given.
.TP
.BR \-s \ or\ \-
Script mode;
all feedback for interactive editing is disabled.
.SM EXINIT
and
.I .exrc
files are not processed.
.TP
.BI \-t \ tagstring
Read the
.I tags
file,
then choose the file and position specified by
.I tagstring
for editing.
.TP
.B \-v
Start in visual mode even if called as
.IR ex .
.TP
.B \-V
Echo command input to standard error,
unless it originates from a terminal.
.TP
.BI \-w \ size
Specify the size of the editing window for visual mode.
.\" from ex.rm 8.1 (Berkeley) 6/8/93
.SS "File manipulation"
.I Ex
is normally editing the contents of a single file,
whose name is recorded in the
.I current
file name.
.I Ex
performs all editing actions in a buffer
(actually a temporary file)
into which the text of the file is initially read.
Changes made to the buffer have no effect on the file being
edited unless and until the buffer contents are written out to the
file with a
.I write
command.
After the buffer contents are written,
the previous contents of the written file are no longer accessible.
When a file is edited,
its name becomes the current file name,
and its contents are read into the buffer.
.PP
The current file is almost always considered to be
.I edited.
This means that the contents of the buffer are logically
connected with the current file name,
so that writing the current buffer contents onto that file,
even if it exists,
is a reasonable action.
If the current file is not
.I edited
then
.I ex
will not normally write on it if it already exists.
.PP
For saving blocks of text while editing, and especially when editing
more than one file,
.I ex
has a group of named buffers.
These are similar to the normal buffer, except that only a limited number
of operations are available on them.
The buffers have names
.I a
through
.I z.
.SS "Exceptional Conditions"
.PP
When errors occur
.I ex
(optionally) rings the terminal bell and, in any case, prints an error
diagnostic. If the primary input is from a file, editor processing
will terminate. If an interrupt signal is received,
.I ex
prints \*(lqInterrupt\*(rq and returns to its command level. If the primary
input is a file, then
.I ex
will exit when this occurs.
.PP
If a hangup signal is received and the buffer has been modified since
it was last written out, or if the system crashes, either the editor
(in the first case) or the system (after it reboots in the second) will
attempt to preserve the buffer. The next time the user logs in he should be
able to recover the work he was doing, losing at most a few lines of
changes from the last point before the hangup or editor crash. To
recover a file one can use the
.B \-r
option. If one was editing the file
.I resume,
then he should change
to the directory where he were when the crash occurred, giving the command
.RS
.sp
\fBex \-r\fP\fI resume\fP
.sp
.RE
After checking that the retrieved file is indeed ok, he can
.I write
it over the previous contents of that file.
.PP
The user will normally get mail from the system telling him when a file has
been saved after a crash. The command
.RS
.sp
\fBex\fP \-\fBr\fP
.sp
.RE
will print a list of the files which have been saved for the user.
.\"(In the case of a hangup,
.\"the file will not appear in the list,
.\"although it can be recovered.)
.SS "Editing modes"
.PP
.I Ex
has five distinct modes. The primary mode is
.I command
mode. Commands are entered in command mode when a `:' prompt is
present, and are executed each time a complete line is sent. In
.I "text input"
mode
.I ex
gathers input lines and places them in the file. The
.I append,
.I insert,
and
.I change
commands use text input mode.
No prompt is printed when in text input mode.
This mode is left by typing a `.' alone at the beginning of a line, and
.I command
mode resumes.
.PP
The last three modes are
.I open
and
.I visual
modes, entered by the commands of the same name, and, within open and
visual modes
.I "text insertion"
mode.
.I Open
and
.I visual
modes allow local editing operations to be performed on the text in the
file. The
.I open
command displays one line at a time on any terminal while
.I visual
works on
.SM CRT
terminals with random positioning cursors, using the
screen as a (single) window for file editing changes.
These modes are described (only) in
.I "An Introduction to Display Editing with Vi."
.SS "Command structure"
.PP
Most command names are English words,
and initial prefixes of the words are acceptable abbreviations.
The ambiguity of abbreviations is resolved in favor of the more commonly
used commands.
.PP
Most commands accept prefix addresses specifying the lines in the file
upon which they are to have effect.
The forms of these addresses will be discussed below.
A number of commands also may take a trailing
.I count
specifying the number of lines to be involved in the command.
Thus the command \*(lq10p\*(rq will print the tenth line in the buffer while
\*(lqdelete 5\*(rq will delete five lines from the buffer,
starting with the current line.
.PP
Some commands take other information or parameters,
this information always being given after the command name.
.PP
A number of commands have two distinct variants.
The variant form of the command is invoked by placing an
`!' immediately after the command name.
Some of the default variants may be controlled by options;
in this case, the `!' serves to toggle the default.
.PP
The characters `#', `p' and `l' may be placed after many commands
(A `p' or `l' must be preceded by a blank or tab
except in the single special case `dp').
In this case, the command abbreviated by these characters
is executed after the command completes.
Since
.I ex
normally prints the new current line after each change, `p' is rarely necessary.
Any number of `+' or `\-' characters may also be given with these flags.
If they appear, the specified offset is applied to the current line
value before the printing command is executed.
.PP
It is possible to give editor commands which are ignored.
This is useful when making complex editor scripts
for which comments are desired.
The comment character is the double quote: ".
Any command line beginning with " is ignored.
Comments beginning with " may also be placed at the ends
of commands, except in cases where they could be confused as part
of text (shell escapes and the substitute and map commands).
.PP
More than one command may be placed on a line by separating each pair
of commands by a `|' character.
However the
.I global
commands,
comments,
and the shell escape `!'
must be the last command on a line, as they are not terminated by a `|'.
.SS "Command addressing"
.IP \fB.\fR 20
The current line.
Most commands leave the current line as the last line which they affect.
The default address for most commands is the current line,
thus `\fB.\fR' is rarely used alone as an address.
.IP \fIn\fR 20
The \fIn\fRth line in the editor's buffer, lines being numbered
sequentially from 1.
.IP \fB$\fR 20
The last line in the buffer.
.IP \fB%\fR 20
An abbreviation for \*(lq1,$\*(rq, the entire buffer.
.IP \fI+n\fR\ \fI\-n\fR 20
An offset relative to the current buffer line.
The forms `.+3' `+3' and `+++' are all equivalent;
if the current line is line 100 they all address line 103.
.IP \fB/\fIpat\fR\fB/\fR\ \fB?\fIpat\fR\fB?\fR 20
Scan forward and backward respectively for a line containing \fIpat\fR, a
regular expression (as defined below). The scans normally wrap around the end
of the buffer.
If all that is desired is to print the next line containing \fIpat\fR, then
the trailing \fB/\fR or \fB?\fR may be omitted.
If \fIpat\fP is omitted or explicitly empty, then the last
regular expression specified is located.
The forms \fB\e/\fP and \fB\e?\fP scan
using the last regular expression used in a scan; after a substitute
\fB//\fP and \fB??\fP would scan using the substitute's regular expression.
.IP \fB\(aa\(aa\fP\ \fB\(aa\fP\fIx\fP 20
Before each non-relative motion of the current line `\fB.\fP',
the previous current line is marked with a tag, subsequently referred to as
`\(aa\(aa'.
This makes it easy to refer or return to this previous context.
Marks may also be established by the
.I mark
command, using single lower case letters
.I x
and the marked lines referred to as
`\(aa\fIx\fR'.
.PP
Addresses to commands consist of a series of addressing primitives,
separated by `,' or `;'.
Such address lists are evaluated left-to-right.
When addresses are separated by `;' the current line `\fB.\fR'
is set to the value of the previous addressing expression
before the next address is interpreted.
If more addresses are given than the command requires,
then all but the last one or two are ignored.
If the command takes two addresses, the first addressed line must
precede the second in the buffer.
.PP
Null address specifications are permitted in a list of addresses,
the default in this case is the current line `.';
thus `,100' is equivalent to `\fB.\fR,100'.
It is an error to give a prefix address to a command which expects none.
.SS "Command descriptions"
.PP
The following form is a prototype for all
.I ex
commands:
.RS
.sp
\fIaddress\fR \fBcommand\fR \fI! parameters count flags\fR
.sp
.RE
All parts are optional; the degenerate case is the empty command which prints
the next line in the file. For sanity with use from within
.I visual
mode,
.I ex
ignores a \*(lq:\*(rq preceding any command.
.PP
In the following command descriptions, the
default addresses are shown in parentheses,
which are
.I not,
however,
part of the command.
.TP
\fBabbreviate\fR \fIword rhs\fP abbr: \fBab\fP
Add the named abbreviation to the current list.
When in input mode in visual, if
.I word
is typed as a complete word, it will be changed to
.I rhs .
.LP
( \fB.\fR ) \fBappend\fR abbr: \fBa\fR
.br
\fItext\fR
.br
\&\fB.\fR
.RS
Reads the input text and places it after the specified line.
After the command, `\fB.\fR'
addresses the last line input or the
specified line if no lines were input.
If address `0' is given,
text is placed at the beginning of the buffer.
.RE
.LP
\fBa!\fR
.br
\fItext\fR
.br
\&\fB.\fR
.RS
The variant flag to
.I append
toggles the setting for the
.I autoindent
option during the input of
.I text.
.RE
.TP
\fBargs\fR
The members of the argument list are printed, with the current argument
delimited by `[' and `]'.
.TP
\fBcd\fR \fIdirectory\fR
The
.I cd
command is a synonym for
.I chdir.
.LP
( \fB.\fP , \fB.\fP ) \fBchange\fP \fIcount\fP abbr: \fBc\fP
.br
\fItext\fP
.br
\&\fB.\fP
.RS
Replaces the specified lines with the input \fItext\fP.
The current line becomes the last line input;
if no lines were input it is left as for a
\fIdelete\fP.
.RE
.LP
\fBc!\fP
.br
\fItext\fP
.br
\&\fB.\fP
.RS
The variant toggles
.I autoindent
during the
.I change.
.RE
.TP
\fBchdir\fR \fIdirectory\fR
The specified \fIdirectory\fR becomes the current directory.
If no directory is specified, the current value of the
.I home
option is used as the target directory.
After a
.I chdir
the current file is not considered to have been
edited so that write restrictions on pre-existing files apply.
.TP
( \fB.\fP , \fB.\fP )\|\fBcopy\fP \fIaddr\fP \fIflags\fP abbr: \fBco\fP
A \fIcopy\fP
of the specified lines is placed after
.I addr,
which may be `0'.
The current line
`\fB.\fR'
addresses the last line of the copy.
The command
.I t
is a synonym for
.I copy.
.TP
( \fB.\fR , \fB.\fR )\|\fBdelete\fR \fIbuffer\fR \fIcount\fR \fIflags\fR abbr: \fBd\fR
Removes the specified lines from the buffer.
The line after the last line deleted becomes the current line;
if the lines deleted were originally at the end,
the new last line becomes the current line.
If a named
.I buffer
is specified by giving a letter,
then the specified lines are saved in that buffer,
or appended to it if an upper case letter is used.
.LP
\fBedit\fR \fIfile\fR abbr: \fBe\fR
.br
\fBex\fR \fIfile\fR
.RS
Used to begin an editing session on a new file.
The editor
first checks to see if the buffer has been modified since the last
.I write
command was issued.
If it has been,
a warning is issued and the
command is aborted.
The
command otherwise deletes the entire contents of the editor buffer,
makes the named file the current file and prints the new filename.
After insuring that this file is sensible
(i.e., that it is not a binary file such as a directory,
a block or character special file other than
.I /dev/tty,
a terminal,
or a binary or executable file),
the editor reads the file into its buffer.
.PP
If the read of the file completes without error,
the number of lines and characters read is typed.
Any null characters in the file are discarded.
If none of these errors occurred, the file is considered
.I edited.
If the last line of the input file is missing the trailing
newline character, it will be supplied and a complaint will be issued.
This command leaves the current line `\fB.\fR' at the last line read.
If executed from within
.I open
or
.I visual,
the current line is initially the first line of the file.
.RE
.TP
\fBe!\fR \fIfile\fR
The variant form suppresses the complaint about modifications having
been made and not written from the editor buffer, thus
discarding all changes which have been made before editing the new file.
.TP
\fBe\fR \fB+\fIn\fR \fIfile\fR
Causes the editor to begin at line
.I n
rather than at the last line;
\fIn\fR may also be an editor command containing no spaces,
e.g.: \*(lq+/pat\*(rq.
.TP
\fBfile\fR abbr: \fBf\fR
Prints the current file name,
whether it has been `[Modified]' since the last
.I write
command,
whether it is
.I "read only" ,
the current line,
the number of lines in the buffer,
and the percentage of the way through the buffer of the current line.
In the rare case that the current file is `[Not edited]' this is
noted also; in this case one has to use the form \fBw!\fR to write to
the file, since the editor is not sure that a \fBwrite\fR will not
destroy a file unrelated to the current contents of the buffer.
.TP
\fBfile\fR \fIfile\fR
The current file name is changed to
.I file
which is considered
`[Not edited]'.
.TP
( 1 , $ ) \fBglobal\fR /\fIpat\|\fR/ \fIcmds\fR abbr: \fBg\fR
First marks each line among those specified which matches
the given regular expression.
Then the given command list is executed with `\fB.\fR' initially
set to each marked line.
.IP
The command list consists of the remaining commands on the current
input line and may continue to multiple lines by ending all but the
last such line with a `\e'.
If
.I cmds
(and possibly the trailing \fB/\fR delimiter) is omitted, each line matching
.I pat
is printed.
.I Append,
.I insert,
and
.I change
commands and associated input are permitted;
the `\fB.\fR' terminating input may be omitted if it would be on the
last line of the command list.
.I Open
and
.I visual
commands are permitted in the command list and take input from the terminal.
.IP
The
.I global
command itself may not appear in
.I cmds.
The
.I undo
command is also not permitted there,
as
.I undo
instead can be used to reverse the entire
.I global
command.
The options
.I autoprint
and
.I autoindent
are inhibited during a
.I global,
(and possibly the trailing \fB/\fR delimiter) and the value of the
.I report
option is temporarily infinite,
in deference to a \fIreport\fR for the entire global.
Finally, the context mark `\'\'' is set to the value of
`.' before the global command begins and is not changed during a global
command,
except perhaps by an
.I open
or
.I visual
within the
.I global.
.TP
\fBg!\fR \fB/\fIpat\fB/\fR \fIcmds\fR abbr: \fBv\fR
The variant form of \fIglobal\fR runs \fIcmds\fR at each line not matching
\fIpat\fR.
.LP
( \fB.\fR )\|\fBinsert\fR abbr: \fBi\fR
.br
\fItext\fR
.br
\&\fB.\fR
.RS
Places the given text before the specified line.
The current line is left at the last line input;
if there were none input it is left at the line before the addressed line.
This command differs from
.I append
only in the placement of text.
.RE
.LP
\fBi!\fR
.br
\fItext\fR
.br
\&\fB.\fR
.RS
The variant toggles
.I autoindent
during the
.I insert.
.RE
.TP
( \fB.\fR , \fB.\fR+1 ) \fBjoin\fR \fIcount\fR \fIflags\fR abbr: \fBj\fR
Places the text from a specified range of lines
together on one line.
White space is adjusted at each junction to provide at least
one blank character, two if there was a `\fB.\fR' at the end of the line,
or none if the first following character is a `)'.
If there is already white space at the end of the line,
then the white space at the start of the next line will be discarded.
.TP
\fBj!\fR
The variant causes a simpler
.I join
with no white space processing; the characters in the lines are simply
concatenated.
.TP
( \fB.\fR ) \fBk\fR \fIx\fR
The
.I k
command is a synonym for
.I mark.
It does not require a blank or tab before the following letter.
.TP
( \fB.\fR , \fB.\fR ) \fBlist\fR \fIcount\fR \fIflags\fR
Prints the specified lines in a more unambiguous way:
tabs are printed as `^I'
and the end of each line is marked with a trailing `$'.
The current line is left at the last line printed.
.TP
\fBmap\fR[\fB!\fR] \fIlhs\fR \fIrhs\fR
The
.I map
command is used to define macros for use in
.I visual
command mode.
.I Lhs
should be a single character, or the sequence \*(lq#n\*(rq, for n a digit,
referring to function key \fIn\fR. When this character or function key
is typed in
.I visual
mode, it will be as though the corresponding \fIrhs\fR had been typed.
On terminals without function keys, the user can type \*(lq#n\*(rq.
If the `\fB!\fP' character follows the command name,
the mapping is interpreted in input mode.
See section 6.9 of the \*(lqIntroduction to Display Editing with Vi\*(rq
for more details.
.TP
( \fB.\fR ) \fBmark\fR \fIx\fR
Gives the specified line mark
.I x,
a single lower case letter.
The
.I x
must be preceded by a blank or a tab.
The addressing form `\'x' then addresses this line.
The current line is not affected by this command.
.TP
( \fB.\fR , \fB.\fR ) \fBmove\fR \fIaddr\fR abbr: \fBm\fR
The
.I move
command repositions the specified lines to be after
.I addr .
The first of the moved lines becomes the current line.
.TP
\fBnext\fR abbr: \fBn\fR
The next file from the command line argument list is edited.
.TP
\fBn!\fR
The variant suppresses warnings about the modifications to the buffer not
having been written out, discarding (irretrievably) any changes which may
have been made.
.LP
\fBn\fR \fIfilelist\fR
.br
\fBn\fR \fB+\fIcommand\fR \fIfilelist\fR
.RS
The specified
.I filelist
is expanded and the resulting list replaces the
current argument list;
the first file in the new list is then edited.
If
.I command
is given (it must contain no spaces), then it is executed after editing the first such file.
.RE
.TP
( \fB.\fR , \fB.\fR ) \fBnumber\fR \fIcount\fR \fIflags\fR abbr: \fB#\fR or \fBnu\fR
Prints each specified line preceded by its buffer line
number.
The current line is left at the last line printed.
.LP
( \fB.\fR ) \fBopen\fR \fIflags\fR abbr: \fBo\fR
.br
( \fB.\fR ) \fBopen\fR /\fIpat\|\fR/ \fIflags\fR
.RS
Enters intraline editing \fIopen\fR mode at each addressed line.
If
.I pat
is given,
then the cursor will be placed initially at the beginning of the
string matched by the pattern.
To exit this mode use Q.
See
.I "An Introduction to Display Editing with Vi"
for more details.
.RE
.TP
\fBpreserve\fR
The current editor buffer is saved as though the system had just crashed.
This command is for use only in emergencies when a
.I write
command has resulted in an error.
.TP
( \fB.\fR , \fB.\fR )\|\fBprint\fR \fIcount\fR abbr: \fBp\fR or \fBP\fR
Prints the specified lines
with non-printing characters printed as control characters `^\fIx\fR\|';
delete (octal 177) is represented as `^?'.
The current line is left at the last line printed.
.TP
( \fB.\fR )\|\fBput\fR \fIbuffer\fR abbr: \fBpu\fR
Puts back
previously
.I deleted
or
.I yanked
lines.
Normally used with
.I delete
to effect movement of lines,
or with
.I yank
to effect duplication of lines.
If no
.I buffer
is specified, then the last
.I deleted
or
.I yanked
text is restored.
But no modifying commands may intervene between the
.I delete
or
.I yank
and the
.I put,
nor may lines be moved between files without using a named buffer.
By using a named buffer, text may be restored that was saved there at any
previous time.
.TP
\fBquit\fR abbr: \fBq\fR
Causes
.I ex
to terminate.
No automatic write of the editor buffer to a file is performed.
However,
.I ex
issues a warning message if the file has changed
since the last
.I write
command was issued, and does not
.I quit.
\fIEx\fR
will also issue a diagnostic if there are more files in the argument
list.
.FE
Normally, the user will wish to save his changes, and he
should give a \fIwrite\fR command;
if he wishes to discard them, he should the \fBq!\fR command variant.
.TP
\fBq!\fR
Quits from the editor, discarding changes to the buffer without complaint.
.TP
( \fB.\fR ) \fBread\fR \fIfile\fR abbr: \fBr\fR
Places a copy of the text of the given file in the
editing buffer after the specified line.
If no
.I file
is given the current file name is used.
The current file name is not changed unless there is none in which
case
.I file
becomes the current name.
The sensibility restrictions for the
.I edit
command apply here also.
If the file buffer is empty and there is no current name then
.I ex
treats this as an
.I edit
command.
.IP
Address `0' is legal for this command and causes the file to be read at
the beginning of the buffer.
Statistics are given as for the
.I edit
command when the
.I read
successfully terminates.
After a
.I read
the current line is the last line read.
Within
.I open
and
.I visual
the current line is set to the first line read rather than the last.
.TP
( \fB.\fR ) \fBread\fR \fB!\fR\fIcommand\fR
Reads the output of the command
.I command
into the buffer after the specified line.
This is not a variant form of the command, rather a read
specifying a
.I command
rather than a
.I filename;
a blank or tab before the \fB!\fR is mandatory.
.TP
\fBrecover \fIfile\fR
Recovers
.I file
from the system save area.
Used after a accidental hangup of the phone
or a system crash or
.I preserve
command.
Except when
.I preserve
is used, the user will be notified by mail when a file is saved.
.TP
\fBrewind\fR abbr: \fBrew\fR
The argument list is rewound, and the first file in the list is edited.
.TP
\fBrew!\fR
Rewinds the argument list discarding any changes made to the current buffer.
.TP
\fBset\fR \fIparameter\fR
With no arguments, prints those options whose values have been
changed from their defaults;
with parameter
.I all
it prints all of the option values.
.IP
Giving an option name followed by a `?'
causes the current value of that option to be printed.
The `?' is unnecessary unless the option is Boolean valued.
Boolean options are given values either by the form
`set \fIoption\fR' to turn them on or
`set no\fIoption\fR' to turn them off;
string and numeric options are assigned via the form
`set \fIoption\fR=value'.
.IP
More than one parameter may be given to
.I set \|;
they are interpreted left-to-right.
.IP
A list of options can be found below.
.TP
\fBshell\fR abbr: \fBsh\fR
A new shell is created.
When it terminates, editing resumes.
.TP
\fBsource\fR \fIfile\fR abbr: \fBso\fR
Reads and executes commands from the specified file.
.I Source
commands may be nested.
.LP
.ad l
(\ \fB.\fR\ ,\ \fB.\fR\ )\ \fBsubstitute\fR\ /\fIpat\fR\|/\fIrepl\fR\|/\ \fIoptions\fR\ \fIcount\fR\ \fIflags\fR
.RS
abbr: \fBs\fR
.br
.ad b
On each specified line, the first instance of pattern
.I pat
is replaced by replacement pattern
.I repl.
If the
.I global
indicator option character `g'
appears, then all instances are substituted;
if the
.I confirm
indication character `c' appears,
then before each substitution the line to be substituted
is typed with the string to be substituted marked
with `^' characters.
By typing an `y' one can cause the substitution to be performed,
any other input causes no change to take place.
After a
.I substitute
the current line is the last line substituted.
.PP
Lines may be split by substituting