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
|
.\"
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
.\" permission to reproduce portions of its copyrighted documentation.
.\" Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\"
.\" The Institute of Electrical and Electronics Engineers and The Open
.\" Group, have given us permission to reprint portions of their
.\" documentation.
.\"
.\" In the following statement, the phrase ``this text'' refers to portions
.\" of the system documentation.
.\"
.\" Portions of this text are reprinted and reproduced in electronic form
.\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
.\" Standard for Information Technology -- Portable Operating System
.\" Interface (POSIX), The Open Group Base Specifications Issue 6,
.\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
.\" Engineers, Inc and The Open Group. In the event of any discrepancy
.\" between these versions and the original IEEE and The Open Group
.\" Standard, the original IEEE and The Open Group Standard is the referee
.\" document. The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
.\" This notice shall appear on any product containing this material.
.\"
.\" The contents of this file are subject to the terms of the
.\" Common Development and Distribution License (the "License").
.\" You may not use this file except in compliance with the License.
.\"
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
.\" or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions
.\" and limitations under the License.
.\"
.\" When distributing Covered Code, include this CDDL HEADER in each
.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
.\" If applicable, add the following below this CDDL HEADER, with the
.\" fields enclosed by brackets "[]" replaced with your own identifying
.\" information: Portions Copyright [yyyy] [name of copyright owner]
.\"
.\"
.\" Copyright 1989 AT&T
.\" Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
.\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved.
.\"
.TH EX 1HAS "Jun 15, 2004"
.SH NAME
ex \- text editor
.SH SYNOPSIS
.LP
.nf
\fB/usr/bin/ex\fR [\fB-|\fR \fB-s\fR] [\fB-l\fR] [\fB-L\fR] [\fB-R\fR] [\fB-r\fR [\fIfile\fR]] [\fB-t\fR \fItag\fR]
[\fB-v\fR] [\fB-V\fR] [\fB-x\fR] [\fB-w\fR\fIn\fR] [\fB-C\fR] [+\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfile\fR...
.fi
.LP
.nf
\fB/usr/xpg4/bin/ex\fR [\fB-|\fR \fB-s\fR] [\fB-l\fR] [\fB-L\fR] [\fB-R\fR] [\fB-r\fR [\fIfile\fR]]
[\fB-t\fR \fItag\fR] [\fB-v\fR] [\fB-V\fR] [\fB-x\fR] [\fB-w\fR\fIn\fR] [\fB-C\fR]
[+\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfile\fR...
.fi
.LP
.nf
\fB/usr/xpg6/bin/ex\fR [\fB-|\fR \fB-s\fR] [\fB-l\fR] [\fB-L\fR] [\fB-R\fR] [\fB-r\fR [\fIfile\fR]]
[\fB-t\fR \fItag\fR] [\fB-v\fR] [\fB-V\fR] [\fB-x\fR] [\fB-w\fR\fIn\fR] [\fB-C\fR]
[+\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfile\fR...
.fi
.SH DESCRIPTION
.sp
.LP
The \fBex\fR utility is the root of a family of editors: \fBex\fR and \fBvi\fR.
\fBex\fR is a superset of \fBed\fR(1), with the most notable extension being a
display editing facility. Display based editing is the focus of \fBvi\fR.
.sp
.LP
If you have a \fBCRT\fR terminal, you can wish to use a display based editor;
in this case see \fBvi\fR(1), which is a command which focuses on the
display-editing portion of \fBex\fR.
.sp
.LP
If you have used \fBed\fR you find that, in addition to having all of the
\fBed\fR commands available, \fBex\fR has a number of additional features
useful on \fBCRT\fR terminals. Intelligent terminals and high speed terminals
are very pleasant to use with \fBvi\fR. Generally, the \fBex\fR editor uses far
more of the capabilities of terminals than \fBed\fR does, and uses the terminal
capability data base (see \fBterminfo\fR(4)) and the type of the terminal you
are using from the environment variable \fBTERM\fR to determine how to drive
your terminal efficiently. The editor makes use of features such as insert and
delete character and line in its \fBvisual\fR command (which can be abbreviated
\fBvi\fR) and which is the central mode of editing when using the \fBvi\fR
command.
.sp
.LP
The \fBex\fR utility contains a number of features for easily viewing the text
of the file. The \fBz\fR command gives easy access to windows of text. Typing
\fB^D\fR (CTRL-D) causes the editor to scroll a half-window of text and is more
useful for quickly stepping through a file than just typing return. Of course,
the screen-oriented \fBvisual\fR mode gives constant access to editing context.
.sp
.LP
The \fBex\fR utility gives you help when you make mistakes. The \fBundo\fR
(\fBu\fR) command allows you to reverse any single change which goes astray.
\fBex\fR gives you a lot of feedback, normally printing changed lines, and
indicates when more than a few lines are affected by a command so that it is
easy to detect when a command has affected more lines than it should have.
.sp
.LP
The editor also normally prevents overwriting existing files, unless you edited
them, so that you do not accidentally overwrite a file other than the one you
are editing. If the system (or editor) crashes, or you accidentally hang up the
telephone, you can use the editor \fBrecover\fR command (or \fB-r\fR\fI file\fR
option) to retrieve your work. This gets you back to within a few lines of
where you left off.
.sp
.LP
The \fBex\fR utility has several features for dealing with more than one file
at a time. You can give it a list of files on the command line and use the
\fBnext\fR (\fBn\fR) command to deal with each in turn. The \fBnext\fR command
can also be given a list of file names, or a pattern as used by the shell to
specify a new set of files to be dealt with. In general, file names in the
editor can be formed with full shell metasyntax. The metacharacter `%' is also
available in forming file names and is replaced by the name of the current
file.
.sp
.LP
The editor has a group of buffers whose names are the ASCII lower-case letters
(\fBa\fR-\fBz\fR). You can place text in these named buffers where it is
available to be inserted elsewhere in the file. The contents of these buffers
remain available when you begin editing a new file using the \fBedit\fR
(\fBe\fR) command.
.sp
.LP
There is a command \fB&\fR in \fBex\fR which repeats the last \fBsubstitute\fR
command. In addition, there is a confirmed substitute command. You give a range
of substitutions to be done and the editor interactively asks whether each
substitution is desired.
.sp
.LP
It is possible to ignore the case of letters in searches and substitutions.
\fBex\fR also allows regular expressions which match words to be constructed.
This is convenient, for example, in searching for the word ``edit'' if your
document also contains the word ``editor.''
.sp
.LP
\fBex\fR has a set of options which you can set to tailor it to your liking.
One option which is very useful is the \fBautoindent\fR option that allows the
editor to supply leading white space to align text automatically. You can then
use \fB^D\fR as a backtab and space or tab to move forward to align new code
easily.
.sp
.LP
Miscellaneous useful features include an intelligent \fBjoin\fR (\fBj\fR)
command that supplies white space between joined lines automatically, commands
\fB<\fR and \fB>\fR which shift groups of lines, and the ability to filter
portions of the buffer through commands such as \fBsort\fR.
.SH OPTIONS
.sp
.LP
The following options are supported:
.sp
.ne 2
.na
\fB\fB\(mi\fR | \fB-s\fR\fR
.ad
.RS 25n
Suppresses all interactive user feedback. This is useful when processing editor
scripts.
.RE
.sp
.ne 2
.na
\fB\fB-l\fR\fR
.ad
.RS 25n
Sets up for editing \fBLISP\fR programs.
.RE
.sp
.ne 2
.na
\fB\fB-L\fR\fR
.ad
.RS 25n
Lists the name of all files saved as the result of an editor or system crash.
.RE
.sp
.ne 2
.na
\fB\fB-R\fR\fR
.ad
.RS 25n
\fBReadonly\fR mode. The \fBreadonly\fR flag is set, preventing accidental
overwriting of the file.
.RE
.sp
.ne 2
.na
\fB\fB-r\fR \fIfile\fR\fR
.ad
.RS 25n
Edits \fIfile\fR after an editor or system crash. (Recovers the version of
\fIfile\fR that was in the buffer when the crash occurred.)
.RE
.sp
.ne 2
.na
\fB\fB-t\fR \fItag\fR\fR
.ad
.RS 25n
Edits the file containing the \fItag\fR and positions the editor at its
definition. It is an error to specify more than one \fB-t\fR option.
.RE
.sp
.ne 2
.na
\fB\fB-v\fR\fR
.ad
.RS 25n
Starts up in display editing state, using \fBvi\fR. You can achieve the same
effect by typing the \fBvi\fR command itself.
.RE
.sp
.ne 2
.na
\fB\fB-V\fR\fR
.ad
.RS 25n
Verbose. When \fBex\fR commands are read by means of standard input, the input
is echoed to standard error. This can be useful when processing \fBex\fR
commands within shell scripts.
.RE
.sp
.ne 2
.na
\fB\fB-x\fR\fR
.ad
.RS 25n
Encryption option. Simulates the \fBX\fR command and prompts the user for a
key. This key is used to encrypt and decrypt text using the algorithm of the
\fBcrypt\fR command. The \fBX\fR command makes an educated guess to determine
whether text read in is encrypted or not. The temporary buffer file is
encrypted also, using a transformed version of the key typed in for the
\fB-x\fR option.
.RE
.sp
.ne 2
.na
\fB\fB-w\fR\fIn\fR\fR
.ad
.RS 25n
Sets the default window size to \fIn\fR. This is useful when using the editor
over a slow speed line.
.RE
.sp
.ne 2
.na
\fB\fB-C\fR\fR
.ad
.RS 25n
Encryption option. Same as the \fB-x\fR option, except that \fB-C\fR simulates
the \fBC\fR command. The \fBC\fR command is like the \fBX\fR command, except
that all text read in is assumed to have been encrypted.
.RE
.sp
.ne 2
.na
\fB\fB+\fR\fIcommand\fR | \fB-c\fR\fI command\fR\fR
.ad
.RS 25n
Begins editing by executing the specified editor \fIcommand\fR (usually a
search or positioning command).
.RE
.sp
.ne 2
.na
\fB\fB/usr/xpg4/bin/ex\fR, \fB/usr/xpg6/bin/ex\fR\fR
.ad
.sp .6
.RS 4n
If both the \fB-t\fR\fI tag\fR and the \fB-c\fR\fI command\fR options are
given, the \fB-t\fR\fI tag\fR is processed first. That is, the file containing
the tag is selected by \fB-t\fR and then the command is executed.
.RE
.SH OPERANDS
.sp
.LP
The following operand is supported:
.sp
.ne 2
.na
\fB\fIfile\fR\fR
.ad
.RS 8n
A path name of a file to be edited.
.RE
.SH USAGE
.sp
.LP
This section defines the \fBex\fR states, commands, initializing options, and
scanning pattern formations.
.SS "ex States"
.sp
.ne 2
.na
\fBCommand\fR
.ad
.RS 11n
Normal and initial state. Input prompted for by "\fB:\fR". The line kill
character cancels a partial command.
.RE
.sp
.ne 2
.na
\fBInsert\fR
.ad
.RS 11n
Entered by \fBa\fR, \fBi\fR, or \fBc\fR. Arbitrary text can be entered. Insert
state normally is terminated by a line having only "\fB\&.\fR" on it, or,
abnormally, with an interrupt.
.RE
.sp
.ne 2
.na
\fBVisual\fR
.ad
.RS 11n
Entered by typing \fBvi\fR. Terminated by typing \fBQ\fR or ^\e (Control-\e).
.RE
.SS "ex Command Names and Abbreviations"
.sp
.in +2
.nf
Command Abbrevi- Command Abbrevi- Command Abbrevi-
Name ation Name ation Name ation
abbrev ab map set se
append a mark ma shell sh
args ar move m source so
change c next n substitute s
copy co number nu unabbrev unab
delete d preserve pre undo u
edit e print p unmap unm
file f put pu version ve
global g quit q visual vi
insert i read r write
w
join j recover rec xit x
list l rewind rew yank ya
.fi
.in -2
.sp
.SS "Join Command Arguments"
.sp
.in +2
.nf
Join [\fIrange\fR] j[\fIoin\fR][!] [\fIcount\fR] [\fIflags\fR]
.fi
.in -2
.sp
.sp
.LP
If count is specified:
.sp
.ne 2
.na
\fB\fB/usr/bin/ex\fR, \fB/usr/xpg6/bin/ex\fR\fR
.ad
.sp .6
.RS 4n
If no address is specified, the\fB join\fR command behaves as if \fI2addr\fR
were the current line and the current line plus \fIcount\fR (\fB\&.,. +\fR\fI
count\fR). If one address is specified, the \fBjoin\fR command behaves as if
\fI2addr\fR were the specified address and the specified address plus
\fIcount\fR ( \fIaddr\fR\fB,\fR \fIaddr\fR \fB+\fR \fIcount\fR).
.RE
.sp
.ne 2
.na
\fB\fB/usr/xpg4/bin/ex\fR\fR
.ad
.sp .6
.RS 4n
If no address is specified, the \fBjoin\fR command behaves as if \fI2addr
\fRwere the current line and the current line plus \fIcount \fR\fB-1\fR
(\fB\&.,. +\fR \fIcount\fR \fB-1\fR). If one address is specified, the
\fBjoin\fR command behaves as if \fI2addr\fR were the specified address and the
specified address plus \fIcount\fR \fB-1\fR ( \fIaddr\fR\fB,\fR \fIaddr\fR
\fB+\fR \fIcount\fR \fB-1\fR).
.RE
.sp
.ne 2
.na
\fB\fB/usr/bin/ex\fR, \fB/usr/xpg4/bin/ex\fR, \fB/usr/xpg6/bin/ex\fR\fR
.ad
.sp .6
.RS 4n
If two or more addresses are specified, the \fBjoin\fR command behaves as if an
additional address, equal to the last address plus \fIcount\fR \fB-1\fR
(\fIaddr1\fR\fB, ...,\fR \fIlastaddr\fR\fB,\fR \fIlastaddr\fR + \fIcount\fR
\fB-1\fR), was specified. If this results in a second address greater than the
last line of the edit buffer, it is corrected to be equal to the last line of
the edit buffer.
.RE
.sp
.LP
If no count is specified:
.sp
.ne 2
.na
\fB\fB/usr/bin/ex\fR, \fB/usr/xpg4/bin/ex\fR, \fB/usr/xpg6/bin/ex\fR\fR
.ad
.sp .6
.RS 4n
If no address is specified, the \fBjoin\fR command behaves as if \fI2addr\fR
were the current line and the next line (\fB\&.,. +1\fR). If one address is
specified, the \fBjoin\fR command behaves as if \fI2addr\fR were the specified
address and the next line ( \fIaddr\fR\fB,\fR \fIaddr\fR \fB+1\fR).
.RE
.SS "Additional ex Command Arguments"
.sp
.ne 2
.na
\fB\fB/usr/bin/ex\fR, \fB/usr/xpg6/bin/ex\fR\fR
.ad
.sp .6
.RS 4n
For the following \fBex\fR commands, if \fIcount\fR is specified, it is
equivalent to specifying an additional address to the command. The additional
address is equal to the last address specified to the command (either
explicitly or by default) plus \fIcount\fR\fB-1\fR. If this results in an
address greater than the last line of the edit buffer, it is corrected to equal
the last line of the edit buffer.
.RE
.sp
.ne 2
.na
\fB\fB/usr/xpg4/bin/ex\fR\fR
.ad
.sp .6
.RS 4n
For the following \fBex\fR commands, if both a count and a range are specified
for a command that uses them, the number of lines affected is taken from the
count value rather than the range. The starting line for the command is taken
to be the first line addressed by the range.
.RE
.sp
.sp
.TS
l l
l l .
Abbreviate ab[brev] word rhs
Append [line]a[ppend][!]
Arguments ar[gs]
Change [range] c[hange][!] [count]
Change Directory T{
chd[ir][!] [directory]; cd[!] [directory]
T}
Copy T{
[range] co[py] line [flags]; [range] t line [flags]
T}
Delete T{
[range] d[elete] [buffer] [count] [flags]
T}
Edit T{
e[dit][!] [+line][file]; ex[!] [+line] [file]
T}
File f[ile] [file]
Global T{
[range] g[lobal] /pattern/ [commands]; [range] v /pattern/ [commands]
T}
Insert [line] i[nsert][!]
List [range] l[ist] [count] [flags]
Map map[!] [x rhs]
Mark [line] ma[rk] x; [line] k x
Move [range] m[ove] line
Next n[ext][!] [file ...]
Open [line] o[pen] /pattern/ [flags]
Preserve pre[serve]
Put [line] pu[t] [buffer]
Quit q[uit][!]
Read [line] r[ead][!] [file]
Recover rec[over] file
Rewind rew[ind][!]
Set T{
se[t] [option[=[value]]...] [nooption...] [option?...] [all]
T}
Shell sh[ell]
Source so[urce] file
Suspend su[spend][!]; st[op][!]
Tag ta[g][!] tagstring
Unabbreviate una[bbrev] word
Undo u[ndo]
Unmap unm[ap][!] x
Visual [line] v[isual] [type] [count] [flags]
Write T{
[range] w[rite][!] [>>] [file]; [range] w[rite][!] [file]; [range] wq[!] [>>] [file]
T}
Write and Exit [range] x[it][!] [file]
Yank [range] ya[nk] [buffer] [count]
Adjust Window [line] z [type] [count] [flags]
Escape ! command [range]! command
Scroll EOF
Write Line Number [line] = [flags]
Execute @ buffer; * buffer
.TE
.sp
.ne 2
.na
\fB\fB/usr/bin/ex\fR, \fB/usr/xpg4/bin/ex\fR, \fB/usr/xpg6/bin/ex\fR\fR
.ad
.sp .6
.RS 4n
For the following \fBex\fR commands, if \fIcount\fR is specified, it is
equivalent to specifying an additional address to the command. The additional
address is equal to the last address specified to the command (either
explicitly or by default) plus \fIcount\fR\fB-1\fR. If this results in an
address greater than the last line of the edit buffer, it is corrected to equal
the last line of the edit buffer.
.RE
.sp
.sp
.TS
l l
l l .
Number T{
[range] nu[mber] [count] [flags]; [range] | # [count] [flags]
T}
Print [range] p[rint] [count] [flags]
Substitute T{
[range] s[ubstitute] [/pattern/repl/[options] [count] [flags]]
T}
Shift Left [range] < [count] [flags]
Shift Right [range] > [count] [flags]
Resubstitute T{
[range] & [options] [count] [flags]; [range] s[ubstitute] [options] [count] [flags]; [range] ~ [options] [count [flags]
T}
.TE
.SS "ex Commands"
.sp
.sp
.TS
l l
l l .
\fBC\fR forced encryption
\fBX\fR heuristic encryption
\fB&\fR resubst
\fBCR\fR print next
\fB>\fR rshift
\fB<\fR lshift
\fB^D\fR scroll
\fBz\fR window
\fB!\fR shell escape
.TE
.SS "ex Command Addresses"
.sp
.sp
.TS
l l
l l .
\fIn\fR line \fIn\fR
\fB\&.\fR current
\fB$\fR last
\fB+\fR next
\fB-\fR previous
\fB+\fR\fIn\fR \fIn\fR forward
\fB%\fR 1,$
\fB/\fR\fIpat\fR next with \fIpat\fR
\fB?\fR\fIpat\fR previous with \fIpat\fR
\fIx\fR\fB-\fR\fIn\fR \fIn\fR before \fIx\fR
\fIx\fR\fB,\fR\fIy\fR \fIx\fR through \fIy\fR
\fB\&'\fR\fIx\fR marked with \fIx\fR
\fB"\fR previous context
.TE
.SS "Initializing Options"
.sp
.sp
.TS
l l
l l .
\fBEXINIT\fR place \fBset\fR's here in environment variable
\fB$HOME/.exrc\fR editor initialization file
\fB\&./.exrc\fR editor initialization file
\fBset\fR \fIx\fR enable option \fIx\fR
\fBset\fR \fBno\fR\fIx\fR disable option \fIx\fR
\fBset\fR \fIx\fR=\fIval\fR give value \fIval\fR to option \fIx\fR
\fBset\fR show changed options
\fBset\fR \fBall\fR show all options
\fBset\fR \fIx\fR\fB?\fR show value of option \fIx\fR
.TE
.SS "Useful Options and Abbreviations"
.sp
.sp
.TS
l l l
l l l .
autoindent \fBai\fR supply indent
autowrite \fBaw\fR write before changing files
directory T{
pathname of directory for temporary work files
T}
exrc \fBex\fR T{
allow \fBvi\fR/\fBex\fR to read the \fB\&.exrc\fR in the current directory. This option is set in the \fBEXINIT\fR shell variable or in the \fB\&.exrc\fR file in the \fB$\fR\fBHOME\fRdirectory.
T}
ignorecase \fBic\fR ignore case of letters in scanning
list print \fB^I\fR for tab, $ at end
magic treat \fB\&. [ *\fR special in patterns
modelines T{
first five lines and last five lines executed as \fBvi\fR/\fBex\fR commands if they are of the form \fBex:\fR\fBcommand\fR\fB:\fR or \fBvi:\fR\fBcommand\fR\fB:\fR
T}
number \fBnu\fR number lines
paragraphs \fBpara\fR macro names that start paragraphs
redraw simulate smart terminal
report T{
informs you if the number of lines modified by the last command is greater than the value of the \fBreport\fR variable
T}
scroll command mode lines
sections \fBsect\fR macro names that start sections
shiftwidth \fBsw\fR for \fB< >\fR, and input \fB^D\fR
showmatch \fBsm\fR to \fB)\fR and \fB}\fR as typed
showmode \fBsmd\fR show insert mode in \fB vi\fR
slowopen \fBslow\fR stop updates during insert
term T{
specifies to \fBvi\fR the type of terminal being used (the default is the value of the environment variable \fBTERM\fR)
T}
window visual mode lines
wrapmargin \fBwm\fR automatic line splitting
wrapscan \fBws\fR T{
search around end (or beginning) of buffer
T}
.TE
.SS "Scanning Pattern Formation"
.sp
.sp
.TS
l l
l l .
\fB^\fR beginning of line
\fB$\fR end of line
\fB\&.\fR any character
\fB\e<\fR beginning of word
\fB\e>\fR end of word
\fB[\fR\fIstr\fR\fB]\fR any character in \fIstr\fR
\fB[^\fR\fIstr\fR\fB]\fR any character not in \fIstr\fR
\fB[\fR\fIxy\fR\fB]\fR any character between \fIx\fR and \fIy\fR
\fB*\fR any number of preceding characters
.TE
.SH ENVIRONMENT VARIABLES
.sp
.LP
See \fBenviron\fR(5) for descriptions of the following environment variables
that affect the execution of \fBex\fR: \fBHOME\fR, \fBLANG\fR, \fBLC_ALL\fR,
\fBLC_COLLATE\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, \fBNLSPATH\fR, \fBPATH\fR,
\fBSHELL\fR, and \fBTERM\fR.
.sp
.ne 2
.na
\fB\fBCOLUMNS\fR\fR
.ad
.RS 11n
Override the system-selected horizontal screen size.
.RE
.sp
.ne 2
.na
\fB\fBEXINIT\fR\fR
.ad
.RS 11n
Determine a list of \fBex\fR commands that are executed on editor start-up,
before reading the first file. The list can contain multiple commands by
separating them using a vertical-line (\fB|\fR) character.
.RE
.sp
.ne 2
.na
\fB\fBLINES\fR\fR
.ad
.RS 11n
Override the system-selected vertical screen size, used as the number of lines
in a screenful and the vertical screen size in visual mode.
.RE
.SH EXIT STATUS
.sp
.LP
The following exit values are returned:
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 6n
Successful completion.
.RE
.sp
.ne 2
.na
\fB\fB>0\fR\fR
.ad
.RS 6n
An error occurred.
.RE
.SH FILES
.sp
.ne 2
.na
\fB\fB/var/tmp/Ex\fInnnnn\fR\fR\fR
.ad
.RS 29n
editor temporary
.RE
.sp
.ne 2
.na
\fB\fB/var/tmp/Rx\fInnnnn\fR\fR\fR
.ad
.RS 29n
named buffer temporary
.RE
.sp
.ne 2
.na
\fB\fB/usr/lib/expreserve\fR\fR
.ad
.RS 29n
preserve command
.RE
.sp
.ne 2
.na
\fB\fB/usr/lib/exrecover\fR\fR
.ad
.RS 29n
recover command
.RE
.sp
.ne 2
.na
\fB\fB/usr/lib/exstrings\fR\fR
.ad
.RS 29n
error messages
.RE
.sp
.ne 2
.na
\fB\fB/usr/share/lib/terminfo/*\fR\fR
.ad
.RS 29n
describes capabilities of terminals
.RE
.sp
.ne 2
.na
\fB\fB/var/preserve/login\fR\fR
.ad
.RS 29n
preservation directory (where \fBlogin\fR is the user's login)
.RE
.sp
.ne 2
.na
\fB\fB$HOME/.exrc\fR\fR
.ad
.RS 29n
editor startup file
.RE
.sp
.ne 2
.na
\fB\fB\&./.exrc\fR\fR
.ad
.RS 29n
editor startup file
.RE
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.SS "/usr/bin/ex"
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
CSI Enabled
.TE
.SS "\fB/usr/xpg4/bin/ex\fR"
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
CSI Enabled
_
Interface Stability Standard
.TE
.SS "\fB/usr/xpg6/bin/ex\fR"
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
CSI Enabled
_
Interface Stability Standard
.TE
.SH SEE ALSO
.sp
.LP
\fBed\fR(1), \fBedit\fR(1), \fBgrep\fR(1), \fBsed\fR(1), \fBsort\fR(1),
\fBvi\fR(1), \fBcurses\fR(3CURSES), \fBterm\fR(4), \fBterminfo\fR(4),
\fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)
.sp
.LP
\fISolaris Advanced User\&'s Guide\fR
.SH AUTHOR
.sp
.LP
The \fBvi\fR and \fBex\fR utilities are based on software developed by The
University of California, Berkeley California, Computer Science Division,
Department of Electrical Engineering and Computer Science.
.SH NOTES
.sp
.LP
Several options, although they continue to be supported, have been replaced in
the documentation by options that follow the Command Syntax Standard (see
\fBIntro\fR(1)). The \fB\(mi\fR option has been replaced by \fB-s\fR, a
\fB-r\fR option that is not followed with an option-argument has been replaced
by \fB-L\fR, and \fB+\fR\fBcommand\fR has been replaced by \fB-c\fR
\fBcommand\fR.
.sp
.LP
The message \fBfile too large to recover with \fR\fB-r\fR\fB option\fR, which
is seen when a file is loaded, indicates that the file can be edited and saved
successfully, but if the editing session is lost, recovery of the file with the
\fB-r\fR option is not possible.
.sp
.LP
The \fBz\fR command prints the number of logical rather than physical lines.
More than a screen full of output can result if long lines are present.
.sp
.LP
File input/output errors do not print a name if the command line \fB-s\fR
option is used.
.sp
.LP
The editing environment defaults to certain configuration options. When an
editing session is initiated, \fBex\fR attempts to read the \fBEXINIT\fR
environment variable. If it exists, the editor uses the values defined in
\fBEXINIT\fR, otherwise the values set in \fB$HOME/.exrc\fR are used. If
\fB$HOME/.exrc\fR does not exist, the default values are used.
.sp
.LP
To use a copy of \fB\&.exrc\fR located in the current directory other than
\fB$HOME\fR, set the \fIexrc\fR option in \fBEXINIT\fR or \fB$HOME/.exrc\fR.
Options set in \fBEXINIT\fR can be turned off in a local \fB\&.exrc\fR only if
\fIexrc\fR is set in \fBEXINIT\fR or \fB$HOME/.exrc\fR. In order to be used,
\fI\&.exrc\fR in \fB$HOME\fR or the current directory must fulfill these
conditions:
.RS +4
.TP
.ie t \(bu
.el o
It must exist.
.RE
.RS +4
.TP
.ie t \(bu
.el o
It must be owned by the same userid as the real userid of the process, or the
process has appropriate privileges.
.RE
.RS +4
.TP
.ie t \(bu
.el o
It is not writable by anyone other than the owner.
.RE
.sp
.LP
There is no easy way to do a single scan ignoring case.
.sp
.LP
The editor does not warn if text is placed in named buffers and not used before
exiting the editor.
.sp
.LP
Null characters are discarded in input files and cannot appear in resultant
files.
|