File: exref.html

package info (click to toggle)
nvi 1.81.6-8.2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 10,788 kB
  • sloc: ansic: 43,561; sh: 16,093; makefile: 639; perl: 262; tcl: 234; awk: 19
file content (1726 lines) | stat: -rw-r--r-- 90,330 bytes parent folder | download | duplicates (10)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
<html>
<head>
<meta name="generator" content="groff -Thtml, see www.gnu.org">
<meta name="Content-Style" content="text/css">
<title>Ex Reference Manual</title>
</head>
<body>

<h1 align=center>Ex Reference Manual</h1>
<a href="#1. Starting ex">1. Starting ex</a><br>
<a href="#2. File manipulation">2. File manipulation</a><br>
<a href="#2.1. Current file">2.1. Current file</a><br>
<a href="#2.2. Alternate file">2.2. Alternate file</a><br>
<a href="#2.3. Filename expansion">2.3. Filename expansion</a><br>
<a href="#2.4. Multiple files and named buffers">2.4. Multiple files and named buffers</a><br>
<a href="#2.5. Read only">2.5. Read only</a><br>
<a href="#3. Exceptional Conditions">3. Exceptional Conditions</a><br>
<a href="#3.1. Errors and interrupts">3.1. Errors and interrupts</a><br>
<a href="#3.2. Recovering from hangups and crashes">3.2. Recovering from hangups and crashes</a><br>
<a href="#4. Editing modes">4. Editing modes</a><br>
<a href="#5. Command structure">5. Command structure</a><br>
<a href="#5.1. Command parameters">5.1. Command parameters</a><br>
<a href="#5.2. Command variants">5.2. Command variants</a><br>
<a href="#5.3. Flags after commands">5.3. Flags after commands</a><br>
<a href="#5.4. Comments">5.4. Comments</a><br>
<a href="#5.5. Multiple commands per line">5.5. Multiple commands per line</a><br>
<a href="#5.6. Reporting large changes">5.6. Reporting large changes</a><br>
<a href="#6. Command addressing">6. Command addressing</a><br>
<a href="#6.1. Addressing primitives">6.1. Addressing primitives</a><br>
<a href="#6.2. Combining addressing primitives">6.2. Combining addressing primitives</a><br>
<a href="#7. Command descriptions">7. Command descriptions</a><br>
<a href="#8. Regular expressions and substitute replacement patterns">8. Regular expressions and substitute replacement patterns</a><br>
<a href="#8.1. Regular expressions">8.1. Regular expressions</a><br>
<a href="#8.2. Magic and nomagic">8.2. Magic and nomagic</a><br>
<a href="#8.3. Basic regular expression summary">8.3. Basic regular expression summary</a><br>
<a href="#8.4. Combining regular expression primitives">8.4. Combining regular expression primitives</a><br>
<a href="#8.5. Substitute replacement patterns">8.5. Substitute replacement patterns</a><br>
<a href="#9. Option descriptions">9. Option descriptions</a><br>
<a href="#10. Acknowledgements">10. Acknowledgements</a><br>

<hr>
<!-- Creator     : groff version 1.17.2 -->
<!-- CreationDate: Sun Nov 18 17:43:59 2007 -->

<p><b>Version 3.7</b></p>

<p align=center><i><small>ABSTRACT</small></i></p>
<pre><small></small></pre>

<p align=center><small>William Joy</small></p>
<pre><small>                           Mark Horton
                    Computer Science Division
     Department of Electrical Engineering and Computer Science
               University of California, Berkeley
                      Berkeley, Ca.  94720
</small></pre>

<p><small><i>Ex</i> a line oriented text editor, which
supports both command and display oriented editing. This
reference manual describes the command oriented part of
<i>ex;</i> the display editing features of <i>ex</i> are
described in <i>An Introduction to Display Editing with
Vi.</i> Other documents about the editor include the
introduction <i>Edit: A tutorial</i>, the <i>Ex/edit Command
Summary</i>, and a <i>Vi Quick Reference</i>
card.</small></p>
<a name="1. Starting ex"></a>
<h2>1. Starting ex</h2>


<p align=center><small></small></p>

<p><small>Each instance of the editor has a set of options,
which can be set to tailor it to your liking. The command
<i>edit</i> invokes a version of <i>ex</i> designed for more
casual or beginning users by changing the default settings
of some of these options. To simplify the description which
follows we assume the default settings of the
options.</small></p>

<p><small>When invoked, <i>ex</i> determines the terminal
type from the <small>TERM</small> variable in the
environment. It there is a <small>TERMCAP</small> variable
in the environment, and the type of the terminal described
there matches the <small>TERM</small> variable, then that
description is used. Also if the <small>TERMCAP</small>
variable contains a pathname (beginning with a <b>/</b>)
then the editor will seek the description of the terminal in
that file (rather than the default /etc/termcap). If there
is a variable <small>EXINIT</small> in the environment, then
the editor will execute the commands in that variable,
otherwise if there is a file <i>.exrc</i> in your
<small>HOME</small> directory <i>ex</i> reads commands from
that file, simulating a <i>source</i> command. Option
setting commands placed in <small>EXINIT</small> or
<i>.exrc</i> will be executed before each editor
session.</small></p>

<p><small>A command to enter <i>ex</i> has the following
prototype:</small></p>


<p align=center><small></small></p>
<pre><small><b>     ex</b> [ <b>-</b> ] [ <b>-v</b> ] [ <b>-t</b> <i>tag</i> ] [ <b>-r</b> ] [ <b>-l</b> ] [ <b>-w</b><i>n</i> ] [ <b>-x</b> ] [ <b>-R</b> ] [ <b>+</b><i>command</i> ] name ...
</small></pre>

<p><small>The most common case edits a single file with no
options, i.e.:</small></p>
<pre><small><b>     ex</b> name
</small></pre>

<p><small>The <b>-</b> command line option option
suppresses all interactive-user feedback and is useful in
processing editor scripts in command files. The <b>-v</b>
option is equivalent to using <i>vi</i> rather than
<i>ex.</i> The <b>-t</b> option is equivalent to an initial
<i>tag</i> command, editing the file containing the
<i>tag</i> and positioning the editor at its definition. The
<b>-r</b> option is used in recovering after an editor or
system crash, retrieving the last saved version of the named
file or, if no file is specified, typing a list of saved
files. The <b>-l</b> option sets up for editing
<small>LISP</small> , setting the <i>showmatch</i> and
<i>lisp</i> options. The <b>-w</b> option sets the default
window size to <i>n,</i> and is useful on dialups to start
in small windows. The <b>-x</b> option causes <i>ex</i> to
prompt for a <i>key</i>, which is used to encrypt and
decrypt the contents of the file, which should already be
encrypted using the same key, see <i>crypt</i>(1). The
<b>-R</b> option sets the <i>readonly</i> option at the
start. <i>Name</i> arguments indicate files to be edited. An
argument of the form <b>+</b><i>command</i> indicates that
the editor should begin by executing the specified command.
If <i>command</i> is omitted, then it defaults to ``$'',
positioning the editor at the last line of the first file
initially. Other useful commands here are scanning patterns
of the form ``/pat'' or line numbers, e.g. ``+100'' starting
at line 100.</small></p>
<a name="2. File manipulation"></a>
<h2>2. File manipulation</h2>
<a name="2.1. Current file"></a>
<h2>2.1. Current file</h2>

<p><small><i>Ex</i> is normally editing the contents of a
single file, whose name is recorded in the <i>current</i>
file name. <i>Ex</i> 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</i> 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.</small></p>

<p><small>The current file is almost always considered to
be <i>edited.</i> 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</i> then <i>ex</i> will not normally write on
it if it already exists.*</small></p>


<p align=center><small></small></p>
<a name="2.2. Alternate file"></a>
<h3>2.2. Alternate file</h3>

<p><small>Each time a new value is given to the current
file name, the previous current file name is saved as the
<i>alternate</i> file name. Similarly if a file is mentioned
but does not become the current file, it is saved as the
alternate file name.</small></p>
<a name="2.3. Filename expansion"></a>
<h3>2.3. Filename expansion</h3>

<p><small>Filenames within the editor may be specified
using the normal shell expansion conventions. In addition,
the character `%' in filenames is replaced by the
<i>current</i> file name and the character `#' by the
<i>alternate</i> file name.</small></p>


<p align=center><small></small></p>
<a name="2.4. Multiple files and named buffers"></a>
<h3>2.4. Multiple files and named buffers</h3>

<p><small>If more than one file is given on the command
line, then the first file is edited as described above. The
remaining arguments are placed with the first file in the
<i>argument list.</i> The current argument list may be
displayed with the <i>args</i> command. The next file in the
argument list may be edited with the <i>next</i> command.
The argument list may also be respecified by specifying a
list of names to the <i>next</i> command. These names are
expanded, the resulting list of names becomes the new
argument list, and <i>ex</i> edits the first file on the
list.</small></p>

<p><small>For saving blocks of text while editing, and
especially when editing more than one file, <i>ex</i> 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</i> through
<i>z.</i></small></p>


<p align=center><small></small></p>
<a name="2.5. Read only"></a>
<h3>2.5. Read only</h3>

<p><small>It is possible to use <i>ex</i> in <i>read
only</i> mode to look at files that you have no intention of
modifying. This mode protects you from accidently
overwriting the file. Read only mode is on when the
<i>readonly</i> option is set. It can be turned on with the
<b>-R</b> command line option, by the <i>view</i> command
line invocation, or by setting the <i>readonly</i> option.
It can be cleared by setting <i>noreadonly</i>. It is
possible to write, even while in read only mode, by
indicating that you really know what you are doing. You can
write to a different file, or can use the ! form of write,
even while in read only mode.</small></p>
<a name="3. Exceptional Conditions"></a>
<h2>3. Exceptional Conditions</h2>
<a name="3.1. Errors and interrupts"></a>
<h2>3.1. Errors and interrupts</h2>

<p><small>When errors occur <i>ex</i> (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</i> prints ``Interrupt'' and returns to its
command level. If the primary input is a file, then
<i>ex</i> will exit when this occurs.</small></p>
<a name="3.2. Recovering from hangups and crashes"></a>
<h3>3.2. Recovering from hangups and crashes</h3>

<p><small>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 you log in you should be
able to recover the work you were doing, losing at most a
few lines of changes from the last point before the hangup
or editor crash. To recover a file you can use the <b>-r</b>
option. If you were editing the file <i>resume,</i> then you
should change to the directory where you were when the crash
occurred, giving the command</small></p>
<pre><small><b>     ex -r</b> <i>resume
</i></small></pre>

<p><small>After checking that the retrieved file is indeed
ok, you can <i>write</i> it over the previous contents of
that file.</small></p>

<p><small>You will normally get mail from the system
telling you when a file has been saved after a crash. The
command</small></p>
<pre><small><b>     ex</b> -<b>r
</b></small></pre>

<p><small>will print a list of the files which have been
saved for you. (In the case of a hangup, the file will not
appear in the list, although it can be
recovered.)</small></p>
<a name="4. Editing modes"></a>
<h2>4. Editing modes</h2>

<p><small><i>Ex</i> has five distinct modes. The primary
mode is <i>command</i> 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</i> mode
<i>ex</i> gathers input lines and places them in the file.
The <i>append, insert,</i> and <i>change</i> commands use
text input mode. No prompt is printed when you are in text
input mode. This mode is left by typing a `.' alone at the
beginning of a line, and <i>command</i> mode
resumes.</small></p>

<p><small>The last three modes are <i>open</i> and
<i>visual</i> modes, entered by the commands of the same
name, and, within open and visual modes <i>text
insertion</i> mode. <i>Open</i> and <i>visual</i> modes
allow local editing operations to be performed on the text
in the file. The <i>open</i> command displays one line at a
time on any terminal while <i>visual</i> works on
<small>CRT</small> 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.</i></small></p>
<a name="5. Command structure"></a>
<h2>5. Command structure</h2>

<p><small>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.*</small></p>


<p align=center><small></small></p>
<a name="5.1. Command parameters"></a>
<h3>5.1. Command parameters</h3>

<p><small>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</i>
specifying the number of lines to be involved in the
command.</small></p>


<p align=center><small></small></p>

<p><small>Thus the command ``10p'' will print the tenth
line in the buffer while ``delete 5'' will delete five lines
from the buffer, starting with the current line.</small></p>

<p><small>Some commands take other information or
parameters, this information always being given after the
command name.</small></p>


<p align=center><small></small></p>
<a name="5.2. Command variants"></a>
<h3>5.2. Command variants</h3>

<p><small>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.</small></p>
<a name="5.3. Flags after commands"></a>
<h3>5.3. Flags after commands</h3>

<p><small>The characters `#', `p' and `l' may be placed
after many commands.**</small></p>


<p align=center><small></small></p>

<p><small>In this case, the command abbreviated by these
characters is executed after the command completes. Since
<i>ex</i> 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.</small></p>
<a name="5.4. Comments"></a>
<h3>5.4. Comments</h3>

<p><small>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: &quot;. Any command line beginning with &quot;
is ignored. Comments beginning with &quot; 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).</small></p>
<a name="5.5. Multiple commands per line"></a>
<h3>5.5. Multiple commands per line</h3>

<p><small>More than one command may be placed on a line by
separating each pair of commands by a `|' character. However
the <i>global</i> commands, comments, and the shell escape
`!' must be the last command on a line, as they are not
terminated by a `|'.</small></p>
<a name="5.6. Reporting large changes"></a>
<h3>5.6. Reporting large changes</h3>

<p><small>Most commands which change the contents of the
editor buffer give feedback if the scope of the change
exceeds a threshold given by the <i>report</i> option. This
feedback helps to detect undesirably large changes so that
they may be quickly and easily reversed with an <i>undo.</i>
After commands with more global effect such as <i>global</i>
or <i>visual,</i> you will be informed if the net change in
the number of lines in the buffer during this command
exceeds this threshold.</small></p>
<a name="6. Command addressing"></a>
<h2>6. Command addressing</h2>
<a name="6.1. Addressing primitives"></a>
<h2>6.1. Addressing primitives</h2>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="30%">
.</td><td width="70%">
<small>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 `<b>.</b>' is rarely used alone as an address.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="30%">
n</td><td width="70%">
<small>The <i>n</i>th line in the editor's buffer, lines
being numbered sequentially from 1.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="30%">
$</td><td width="70%">
<small>The last line in the buffer.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="30%">
%</td><td width="70%">
<small>An abbreviation for ``1,$'', the entire
buffer.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="30%">
+n -n</td><td width="70%">
<small>An offset relative to the current buffer
line.</small></td></table>


<p align=center><small></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="30%">
/ pat / ? pat ?</td><td width="70%">
<small>Scan forward and backward respectively for a line containing <i>pat</i>, 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 <i>pat</i>, then the trailing <b>/</b> or <b>?</b> may be omitted. If <i>pat</i> is omitted or explicitly empty, then the last regular expression specified is located.</small></td></table>


<p align=center><small></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="30%">
  x</td><td width="70%">
<small>Before each non-relative motion of the current line `<b>.</b>', the previous current line is marked with a tag, subsequently referred to as `'. This makes it easy to refer or return to this previous context. Marks may also be established by the <i>mark</i> command, using single lower case letters <i>x</i> and the marked lines referred to as `<i>x</i>'.</small></td></table>
<a name="6.2. Combining addressing primitives"></a>
<h3>6.2. Combining addressing primitives</h3>

<p><small>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 `<b>.</b>' 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.</small></p>


<p align=center><small></small></p>
<a name="7. Command descriptions"></a>
<h2>7. Command descriptions</h2>

<p><small>The following form is a prototype for all
<i>ex</i> commands:</small></p>
<pre><small><i>     address</i> <b>command</b> <i>! parameters count flags
</i></small></pre>

<p><small>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</i> mode,
<i>ex</i> ignores a ``:'' preceding any command.</small></p>

<p><small>In the following command descriptions, the
default addresses are shown in parentheses, which are
<i>not,</i> however, part of the command.</small></p>

<p><small><b>abbreviate</b> <i>word rhs</i> abbr:
<b>ab</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Add the named abbreviation to the current list. When in input mode in visual, if <i>word</i> is typed as a complete word, it will be changed to <i>rhs</i>.</small></td></table>

<p><small>( <b>.</b> ) <b>append</b> abbr: <b>a</b><i><br>
text</i><b><br>
.</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Reads the input text and places it after the specified line. After the command, `<b>.</b>' 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.</small></td></table>

<p><small><b>a!</b><i><br>
text</i><b><br>
.</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The variant flag to <i>append</i> toggles the setting for the <i>autoindent</i> option during the input of <i>text.</i></small></td></table>

<p><small><b>args</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The members of the argument list are printed, with the current argument delimited by `[' and `]'.</small></td></table>

<p><small>( <b>.</b> , <b>.</b> ) <b>change</b>
<i>count</i> abbr: <b>c</b><i><br>
text</i><b><br>
.</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Replaces the specified lines with the input <i>text</i>. The current line becomes the last line input; if no lines were input it is left as for a <i>delete</i>.</small></td></table>

<p><small><b>c!</b><i><br>
text</i><b><br>
.</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The variant toggles <i>autoindent</i> during the <i>change.</i></small></td></table>

<p><small>( <b>.</b> , <b>.</b> )<b>copy</b> <i>addr
flags</i> abbr: <b>co</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>A <i>copy</i> of the specified lines is placed after <i>addr,</i> which may be `0'. The current line `<b>.</b>' addresses the last line of the copy. The command <i>t</i> is a synonym for <i>copy.</i></small></td></table>

<p><small>( <b>.</b> , <b>.</b> )<b>delete</b> <i>buffer
count flags</i> abbr: <b>d</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>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</i> 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.</small></td></table>

<p><small><b>edit</b> <i>file</i> abbr: <b>e<br>
ex</b> <i>file</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>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</i> 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</small></td></table>


<p align=center><small></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>the editor reads the file into its buffer.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>If the read of the file completes without error, the
number of lines and characters read is typed. If there were
any non- <small>ASCII</small> characters in the file they
are stripped of their non- <small>ASCII</small> high bits,
and any null characters in the file are discarded. If none
of these errors occurred, the file is considered
<i>edited.</i> 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 `<b>.</b>' at the last line read.</small></td></table>


<p align=center><small></small></p>

<p><small><b>e!</b> <i>file</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>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.</small></td></table>

<p><small><b>e +</b><i>n file</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Causes the editor to begin at line <i>n</i> rather than at the last line; <i>n</i> may also be an editor command containing no spaces, e.g.: ``+/pat''.</small></td></table>

<p><small><b>file</b> abbr: <b>f</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Prints the current file name, whether it has been `[Modified]' since the last <i>write</i> command, whether it is <i>read only</i>, the current line, the number of lines in the buffer, and the percentage of the way through the buffer of the current line.*</small></td></table>


<p align=center><small></small></p>

<p><small><b>file</b> <i>file</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The current file name is changed to <i>file</i> which is considered `[Not edited]'.</small></td></table>

<p><small>( 1 , $ ) <b>global</b> /<i>pat</i>/ <i>cmds</i>
abbr: <b>g</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>First marks each line among those specified which matches the given regular expression. Then the given command list is executed with `<b>.</b>' initially set to each marked line.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>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 `'. If
<i>cmds</i> (and possibly the trailing <b>/</b> delimiter)
is omitted, each line matching <i>pat</i> is printed.
<i>Append, insert,</i> and <i>change</i> commands and
associated input are permitted; the `<b>.</b>' terminating
input may be omitted if it would be on the last line of the
command list. <i>Open</i> and <i>visual</i> commands are
permitted in the command list and take input from the
terminal.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The <i>global</i> command itself may not appear in
<i>cmds.</i> The <i>undo</i> command is also not permitted
there, as <i>undo</i> instead can be used to reverse the
entire <i>global</i> command. The options <i>autoprint</i>
and <i>autoindent</i> are inhibited during a <i>global,</i>
(and possibly the trailing <b>/</b> delimiter) and the value
of the <i>report</i> option is temporarily infinite, in
deference to a <i>report</i> 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</i> or <i>visual</i>
within the <i>global.</i></small></td></table>

<p><small><b>g! /</b><i>pat</i><b>/</b> <i>cmds</i> abbr:
<b>v</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The variant form of <i>global</i> runs <i>cmds</i> at each line not matching <i>pat</i>.</small></td></table>

<p><small>( <b>.</b> )<b>insert</b> abbr: <b>i</b><i><br>
text</i><b><br>
.</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>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</i> only in the placement of text.</small></td></table>

<p><small><b>i!</b><i><br>
text</i><b><br>
.</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The variant toggles <i>autoindent</i> during the <i>insert.</i></small></td></table>

<p><small>( <b>.</b> , <b>.</b>+1 ) <b>join</b> <i>count
flags</i> abbr: <b>j</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>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 `<b>.</b>' 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.</small></td></table>

<p><small><b>j!</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The variant causes a simpler <i>join</i> with no white space processing; the characters in the lines are simply concatenated.</small></td></table>

<p><small>( <b>.</b> ) <b>k</b> <i>x</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The <i>k</i> command is a synonym for <i>mark.</i> It does not require a blank or tab before the following letter.</small></td></table>

<p><small>( <b>.</b> , <b>.</b> ) <b>list</b> <i>count
flags</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>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.</small></td></table>

<p><small><b>map</b> <i>lhs rhs</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The <i>map</i> command is used to define macros for use in <i>visual</i> mode. <i>Lhs</i> should be a single character, or the sequence ``#n'', for n a digit, referring to function key <i>n</i>. When this character or function key is typed in <i>visual</i> mode, it will be as though the corresponding <i>rhs</i> had been typed. On terminals without function keys, you can type ``#n''. See section 6.9 of the ``Introduction to Display Editing with Vi'' for more details.</small></td></table>

<p><small>( <b>.</b> ) <b>mark</b> <i>x</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Gives the specified line mark <i>x,</i> a single lower case letter. The <i>x</i> 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.</small></td></table>

<p><small>( <b>.</b> , <b>.</b> ) <b>move</b> <i>addr</i>
abbr: <b>m</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The <i>move</i> command repositions the specified lines to be after <i>addr</i>. The first of the moved lines becomes the current line.</small></td></table>

<p><small><b>next</b> abbr: <b>n</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The next file from the command line argument list is edited.</small></td></table>

<p><small><b>n!</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The variant suppresses warnings about the modifications to the buffer not having been written out, discarding (irretrievably) any changes which may have been made.</small></td></table>

<p><small><b>n</b> <i>filelist</i><b><br>
n +</b><i>command filelist</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The specified <i>filelist</i> is expanded and the resulting list replaces the current argument list; the first file in the new list is then edited. If <i>command</i> is given (it must contain no spaces), then it is executed after editing the first such file.</small></td></table>

<p><small>( <b>.</b> , <b>.</b> ) <b>number</b> <i>count
flags</i> abbr: <b>#</b> or <b>nu</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Prints each specified line preceded by its buffer line number. The current line is left at the last line printed.</small></td></table>

<p><small>( <b>.</b> ) <b>open</b> <i>flags</i> abbr:
<b>o</b><br>
( <b>.</b> ) <b>open</b> /<i>pat</i>/
<i>flags</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Enters intraline editing <i>open</i> mode at each addressed line. If <i>pat</i> 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</i> for more details.</small></td></table>

<p><small><b>preserve</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>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</i> command has resulted in an error and you don't know how to save your work. After a <i>preserve</i> you should seek help.</small></td></table>

<p><small>( <b>.</b> , <b>.</b> )<b>print</b> <i>count</i>
abbr: <b>p</b> or <b>P</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Prints the specified lines with non-printing characters printed as control characters `^<i>x</i>'; delete (octal 177) is represented as `^?'. The current line is left at the last line printed.</small></td></table>

<p><small>( <b>.</b> )<b>put</b> <i>buffer</i> abbr:
<b>pu</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Puts back previously <i>deleted</i> or <i>yanked</i> lines. Normally used with <i>delete</i> to effect movement of lines, or with <i>yank</i> to effect duplication of lines. If no <i>buffer</i> is specified, then the last <i>deleted</i> or <i>yanked</i> text is restored.*</small></td></table>


<p align=center><small></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>By using a named buffer, text may be restored that was saved there at any previous time.</small></td></table>

<p><small><b>quit</b> abbr: <b>q</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Causes <i>ex</i> to terminate. No automatic write of the editor buffer to a file is performed. However, <i>ex</i> issues a warning message if the file has changed since the last <i>write</i> command was issued, and does not <i>quit.</i></small></td></table>


<p align=center><small></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Normally, you will wish to save your changes, and you should give a <i>write</i> command; if you wish to discard them, use the <b>q!</b> command variant.</small></td></table>

<p><small><b>q!</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Quits from the editor, discarding changes to the buffer without complaint.</small></td></table>

<p><small>( <b>.</b> ) <b>read</b> <i>file</i> abbr:
<b>r</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Places a copy of the text of the given file in the editing buffer after the specified line. If no <i>file</i> is given the current file name is used. The current file name is not changed unless there is none in which case <i>file</i> becomes the current name. The sensibility restrictions for the <i>edit</i> command apply here also. If the file buffer is empty and there is no current name then <i>ex</i> treats this as an <i>edit</i> command.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>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</i> command when the
<i>read</i> successfully terminates. After a <i>read</i> the
current line is the last line read.</small></td></table>


<p align=center><small></small></p>

<p><small>( <b>.</b> ) <b>read
!</b><i>command</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Reads the output of the command <i>command</i> into the buffer after the specified line. This is not a variant form of the command, rather a read specifying a <i>command</i> rather than a <i>filename;</i> a blank or tab before the <b>!</b> is mandatory.</small></td></table>

<p><small><b>recover</b> <i>file</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Recovers <i>file</i> from the system save area. Used after a accidental hangup of the phone**</small></td></table>


<p align=center><small></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>or a system crash** or <i>preserve</i> command. Except when you use <i>preserve</i> you will be notified by mail when a file is saved.</small></td></table>

<p><small><b>rewind</b> abbr: <b>rew</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The argument list is rewound, and the first file in the list is edited.</small></td></table>

<p><small><b>rew!</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Rewinds the argument list discarding any changes made to the current buffer.</small></td></table>

<p><small><b>set</b> <i>parameter</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>With no arguments, prints those options whose values have been changed from their defaults; with parameter <i>all</i> it prints all of the option values.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>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
<i>option</i>' to turn them on or `set no<i>option</i>' to
turn them off; string and numeric options are assigned via
the form `set <i>option</i>=value'.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>More than one parameter may be given to <i>set</i>;
they are interpreted left-to-right.</small></td></table>

<p><small><b>shell</b> abbr: <b>sh</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>A new shell is created. When it terminates, editing resumes.</small></td></table>

<p><small><b>source</b> <i>file</i> abbr:
<b>so</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Reads and executes commands from the specified file. <i>Source</i> commands may be nested.</small></td></table>

<p><small>( <b>.</b> , <b>.</b> ) <b>substitute</b>
/<i>pat</i>/<i>repl</i>/ <i>options count flags</i>abbr:
<b>s</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>On each specified line, the first instance of pattern <i>pat</i> is replaced by replacement pattern <i>repl.</i> If the <i>global</i> indicator option character `g' appears, then all instances are substituted; if the <i>confirm</i> 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</i> the current line is the last line substituted.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Lines may be split by substituting new-line
characters into them. The newline in <i>repl</i> must be
escaped by preceding it with a `'. Other metacharacters
available in <i>pat</i> and <i>repl</i> are described
below.</small></td></table>

<p><small><b>stop</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Suspends the editor, returning control to the top level shell. If <i>autowrite</i> is set and there are unsaved changes, a write is done first unless the form <b>stop</b>! is used. This commands is only available where supported by the teletype driver and operating system.</small></td></table>

<p><small>( <b>.</b> , <b>.</b> ) <b>substitute</b>
<i>options count flags</i>abbr: <b>s</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>If <i>pat</i> and <i>repl</i> are omitted, then the last substitution is repeated. This is a synonym for the <b>&amp;</b> command.</small></td></table>

<p><small>( <b>.</b> , <b>.</b> ) <b>t</b> <i>addr
flags</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The <i>t</i> command is a synonym for <i>copy</i>.</small></td></table>

<p><small><b>ta</b> <i>tag</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The focus of editing switches to the location of <i>tag,</i> switching to a different line in the current file where it is defined, or if necessary to another file.</small></td></table>


<p align=center><small></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The tags file is normally created by a program such as <i>ctags,</i> and consists of a number of lines with three fields separated by blanks or tabs. The first field gives the name of the tag, the second the name of the file where the tag resides, and the third gives an addressing form which can be used by the editor to find the tag; this field is usually a contextual scan using `/<i>pat</i>/' to be immune to minor changes in the file. Such scans are always performed as if <i>nomagic</i> was set.</small></td></table>

<p><small>The tag names in the tags file must be sorted
alphabetically.</small></p>

<p><small><b>unabbreviate</b> <i>word</i> abbr:
<b>una</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Delete <i>word</i> from the list of abbreviations.</small></td></table>

<p><small><b>undo</b> abbr: <b>u</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Reverses the changes made in the buffer by the last buffer editing command. Note that <i>global</i> commands are considered a single command for the purpose of <i>undo</i> (as are <i>open</i> and <i>visual.)</i> Also, the commands <i>write</i> and <i>edit</i> which interact with the file system cannot be undone. <i>Undo</i> is its own inverse.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small><i>Undo</i> always marks the previous value of the
current line `<b>.</b>' as `'. After an <i>undo</i> the
current line is the first line restored or the line before
the first line deleted if no lines were restored. For
commands with more global effect such as <i>global</i> and
<i>visual</i> the current line regains it's pre-command
value after an <i>undo.</i></small></td></table>

<p><small><b>unmap</b> <i>lhs</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The macro expansion associated by <i>map</i> for <i>lhs</i> is removed.</small></td></table>

<p><small>( 1 , $ ) <b>v</b> /<i>pat</i>/
<i>cmds</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>A synonym for the <i>global</i> command variant <b>g!</b>, running the specified <i>cmds</i> on each line which does not match <i>pat</i>.</small></td></table>

<p><small><b>version</b> abbr: <b>ve</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Prints the current version number of the editor as well as the date the editor was last changed.</small></td></table>

<p><small>( <b>.</b> ) <b>visual</b> <i>type count
flags</i> abbr: <b>vi</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Enters visual mode at the specified line. <i>Type</i> is optional and may be `-' , `' or `<b>.</b>' as in the <i>z</i> command to specify the placement of the specified line on the screen. By default, if <i>type</i> is omitted, the specified line is placed as the first on the screen. A <i>count</i> specifies an initial window size; the default is the value of the option <i>window.</i> See the document <i>An Introduction to Display Editing with Vi</i> for more details. To exit this mode, type Q.</small></td></table>

<p><small><b>visual</b> file<b><br>
visual</b> +<i>n</i> file</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>From visual mode, this command is the same as edit.</small></td></table>

<p><small>( 1 , $ ) <b>write</b> <i>file</i> abbr:
<b>w</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Writes changes made back to <i>file</i>, printing the number of lines and characters written. Normally <i>file</i> is omitted and the text goes back where it came from. If a <i>file</i> is specified, then text will be written to that file.*</small></td></table>


<p align=center><small></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>If the file does not exist it is created. The current file name is changed only if there is no current file name; the current line is never changed.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>If an error occurs while writing the current and
<i>edited</i> file, the editor considers that there has been
``No write since last change'' even if the buffer had not
previously been modified.</small></td></table>

<p><small>( 1 , $ ) <b>write&gt;&gt;</b> <i>file</i> abbr:
<b>w&gt;&gt;</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Writes the buffer contents at the end of an existing file.</small></td></table>

<p><small><b>w!</b> <i>name</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Overrides the checking of the normal <i>write</i> command, and will write to any file which the system permits.</small></td></table>

<p><small>( 1 , $ ) <b>w !</b><i>command</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Writes the specified lines into <i>command.</i> Note the difference between <b>w!</b> which overrides checks and <b>w !</b> which writes to a command.</small></td></table>

<p><small><b>wq</b> <i>name</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Like a <i>write</i> and then a <i>quit</i> command.</small></td></table>

<p><small><b>wq!</b> <i>name</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The variant overrides checking on the sensibility of the <i>write</i> command, as <b>w!</b> does.</small></td></table>

<p><small><b>xit</b> <i>name</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>If any changes have been made and not written, writes the buffer out. Then, in any case, quits.</small></td></table>

<p><small>( <b>.</b> , <b>.</b> )<b>yank</b> <i>buffer
count</i> abbr: <b>ya</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Places the specified lines in the named <i>buffer,</i> for later retrieval via <i>put.</i> If no buffer name is specified, the lines go to a more volatile place; see the <i>put</i> command description.</small></td></table>

<p><small>( <b>.+1</b> ) <b>z</b> <i>count</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Print the next <i>count</i> lines, default <i>window</i>.</small></td></table>

<p><small>( <b>.</b> ) <b>z</b> <i>type
count</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Prints a window of text with the specified line at the top. If <i>type</i> is `-' the line is placed at the bottom; a `<b>.</b>' causes the line to be placed in the center.* A count gives the number of lines to be displayed rather than double the number specified by the <i>scroll</i> option. On a <small>CRT</small> the screen is cleared before display begins unless a count which is less than the screen size is given. The current line is left at the last line printed.</small></td></table>


<p align=center><small></small></p>

<p><small><b>!</b> <i>command</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The remainder of the line after the `!' character is sent to a shell to be executed. Within the text of <i>command</i> the characters `%' and `#' are expanded as in filenames and the character `!' is replaced with the text of the previous command. Thus, in particular, `!!' repeats the last such shell escape. If any such expansion is performed, the expanded line will be echoed. The current line is unchanged by this command.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>If there has been ``[No write]'' of the buffer
contents since the last change to the editing buffer, then a
diagnostic will be printed before the command is executed as
a warning. A single `!' is printed when the command
completes.</small></td></table>

<p><small>( <i>addr</i> , <i>addr</i> ) <b>!</b>
<i>command</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Takes the specified address range and supplies it as standard input to <i>command;</i> the resulting output then replaces the input lines.</small></td></table>

<p><small>( $ ) <b>=</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Prints the line number of the addressed line. The current line is unchanged.</small></td></table>

<p><small>( <b>.</b> , <b>.</b> ) <b>&gt;</b> <i>count
flags</i><br>
( <b>.</b> , <b>.</b> ) <b>&lt;</b> <i>count
flags</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Perform intelligent shifting on the specified lines; <b>&lt;</b> shifts left and <b>&gt;</b> shift right. The quantity of shift is determined by the <i>shiftwidth</i> option and the repetition of the specification character. Only white space (blanks and tabs) is shifted; no non-white characters are discarded in a left-shift. The current line becomes the last line which changed due to the shifting.</small></td></table>

<p><small><b>^D</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>An end-of-file from a terminal input scrolls through the file. The <i>scroll</i> option specifies the size of the scroll, normally a half screen of text.</small></td></table>

<p><small>( <b>.</b>+1 , <b>.</b>+1 )<br>
( <b>.</b>+1 , <b>.</b>+1 ) |</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>An address alone causes the addressed lines to be printed. A blank line prints the next line in the file.</small></td></table>

<p><small>( <b>.</b> , <b>.</b> ) <b>&amp;</b> <i>options
count flags</i></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Repeats the previous <i>substitute</i> command.</small></td></table>

<p><small>( <b>.</b> , <b>.</b> )</small> <b>~</b>
<i><small>options count flags</small></i></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Replaces the previous regular expression with the previous replacement pattern from a substitution.</small></td></table>

<a name="8. Regular expressions and substitute replacement patterns"></a>

<h2>8. Regular expressions and substitute replacement patterns</h2>
<a name="8.1. Regular expressions"></a>
<h2>8.1. Regular expressions</h2>

<p><small>A regular expression specifies a set of strings
of characters. A member of this set of strings is said to be
<i>matched</i> by the regular expression. <i>Ex</i>
remembers two previous regular expressions: the previous
regular expression used in a <i>substitute</i> command and
the previous regular expression used elsewhere (referred to
as the previous <i>scanning</i> regular expression.) The
previous regular expression can always be referred to by a
null <i>re</i>, e.g. `//' or `??'.</small></p>
<a name="8.2. Magic and nomagic"></a>
<h3>8.2. Magic and nomagic</h3>

<p><small>The regular expressions allowed by <i>ex</i> are
constructed in one of two ways depending on the setting of
the <i>magic</i> option. The <i>ex</i> and <i>vi</i> default
setting of <i>magic</i> gives quick access to a powerful set
of regular expression metacharacters. The disadvantage of
<i>magic</i> is that the user must remember that these
metacharacters are <i>magic</i> and precede them with the
character `' to use them as ``ordinary'' characters. With
<i>nomagic,</i> the default for <i>edit,</i> regular
expressions are much simpler, there being only two
metacharacters. The power of the other metacharacters is
still available by preceding the (now) ordinary character
with a `'. Note that `' is thus always a
metacharacter.</small></p>

<p><small>The remainder of the discussion of regular
expressions assumes that that the setting of this option is
<i>magic.</i></small></p>


<p align=center><small></small></p>
<a name="8.3. Basic regular expression summary"></a>
<h3>8.3. Basic regular expression summary</h3>

<p><small>The following basic constructs are used to
construct <i>magic</i> mode regular expressions.</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="23%">
char</td><td width="77%">
<small>An ordinary character matches itself. The characters `' at the beginning of a line, `$' at the end of line, `*' as any character other than the first, `.', `', `[', and `</small> ~ <small>' are not ordinary characters and must be escaped (preceded) by `' to be treated as such.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="23%"></td><td width="77%">
<small>At the beginning of a pattern forces the match to
succeed only at the beginning of a
line.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="23%">
$</td><td width="77%">
<small>At the end of a regular expression forces the match
to succeed only at the end of the line.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="23%">
.</td><td width="77%">
<small>Matches any single character except the new-line
character.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="23%">
&lt;</td><td width="77%">
<small>Forces the match to occur only at the beginning of a
``variable'' or ``word''; that is, either at the beginning
of a line, or just before a letter, digit, or underline and
after a character not one of these.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="23%">
&gt;</td><td width="77%">
<small>Similar to `&lt;', but matching the end of a
``variable'' or ``word'', i.e. either the end of the line or
before character which is neither a letter, nor a digit, nor
the underline character.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="23%">
[ string ]</td><td width="77%">
<small>Matches any (single) character in the class defined
by <i>string.</i> Most characters in <i>string</i> define
themselves. A pair of characters separated by `-' in
<i>string</i> defines the set of characters collating
between the specified lower and upper bounds, thus `[a-z]'
as a regular expression matches any (single) lower-case
letter. If the first character of <i>string</i> is an `'
then the construct matches those characters which it
otherwise would not; thus `[a-z]' matches anything but a
lower-case letter (and of course a newline). To place any of
the characters `', `[', or `-' in <i>string</i> you must
escape them with a preceding `'.</small></td></table>
<a name="8.4. Combining regular expression primitives"></a>
<h3>8.4. Combining regular expression primitives</h3>

<p><small>The concatenation of two regular expressions
matches the leftmost and then longest string which can be
divided with the first piece matching the first regular
expression and the second piece matching the second. Any of
the (single character matching) regular expressions
mentioned above may be followed by the character `*' to form
a regular expression which matches any number of adjacent
occurrences (including 0) of characters matched by the
regular expression it follows.</small></p>

<p><small>The character `</small> ~ <small>' may be used in
a regular expression, and matches the text which defined the
replacement part of the last <i>substitute</i> command. A
regular expression may be enclosed between the sequences `'
and `)' with side effects in the <i>substitute</i>
replacement patterns.</small></p>
<a name="8.5. Substitute replacement patterns"></a>
<h3>8.5. Substitute replacement patterns</h3>

<p><small>The basic metacharacters for the replacement
pattern are `&amp;' and `~'; these are given as `&amp;' and
`~' when <i>nomagic</i> is set. Each instance of `&amp;' is
replaced by the characters which the regular expression
matched. The metacharacter `~' stands, in the replacement
pattern, for the defining text of the previous replacement
pattern.</small></p>

<p><small>Other metasequences possible in the replacement
pattern are always introduced by the escaping character `'.
The sequence `\<i>n</i>' is replaced by the text matched by
the <i>n</i>-th regular subexpression enclosed between `'
and `)'.</small></p>


<p align=center><small></small></p>

<p><small>The sequences `u' and `l' cause the immediately
following character in the replacement to be converted to
upper- or lower-case respectively if this character is a
letter. The sequences `U' and `L' turn such conversion on,
either until `E' or `e' is encountered, or until the end of
the replacement pattern.</small></p>
<a name="9. Option descriptions"></a>
<h2>9. Option descriptions</h2>

<p><small><b>autoindent</b>, <b>ai</b> default:
noai</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Can be used to ease the preparation of structured program text. At the beginning of each <i>append</i>, <i>change</i> or <i>insert</i> command or when a new line is <i>opened</i> or created by an <i>append</i>, <i>change</i>, <i>insert</i>, or <i>substitute</i> operation within <i>open</i> or <i>visual</i> mode, <i>ex</i> looks at the line being appended after, the first line changed or the line inserted before and calculates the amount of white space at the start of the line. It then aligns the cursor at the level of indentation so determined.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>If the user then types lines of text in, they will
continue to be justified at the displayed indenting level.
If more white space is typed at the beginning of a line, the
following line will start aligned with the first non-white
character of the previous line. To back the cursor up to the
preceding tab stop one can hit <b>^D</b>. The tab stops
going backwards are defined at multiples of the
<i>shiftwidth</i> option. You <i>cannot</i> backspace over
the indent, except by sending an end-of-file with a
<b>^D</b>.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Specially processed in this mode is a line with no
characters added to it, which turns into a completely blank
line (the white space provided for the <i>autoindent</i> is
discarded.) Also specially processed in this mode are lines
beginning with an `' and immediately followed by a
<b>^D</b>. This causes the input to be repositioned at the
beginning of the line, but retaining the previous indent for
the next line. Similarly, a `0' followed by a <b>^D</b>
repositions at the beginning but without retaining the
previous indent.</small></td></table>

<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small><i>Autoindent</i> doesn't happen in <i>global</i>
commands or when the input is not a
terminal.</small></td></table>

<p><small><b>autoprint</b>, <b>ap</b> default:
ap</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Causes the current line to be printed after each <i>delete</i>, <i>copy</i>, <i>join</i>, <i>move</i>, <i>substitute</i>, <i>t</i>, <i>undo</i> or shift command. This has the same effect as supplying a trailing `p' to each such command. <i>Autoprint</i> is suppressed in globals, and only applies to the last of many commands on a line.</small></td></table>

<p><small><b>autowrite</b>, <b>aw</b> default:
noaw</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Causes the contents of the buffer to be written to the current file if you have modified it and give a <i>next, rewind, stop, tag,</i> or <i>!</i> command, or a <b>^</b> (switch files) or <b>^]</b> (tag goto) command in <i>visual.</i> Note, that the <i>edit</i> and <i>ex</i> commands do <b>not</b> autowrite. In each case, there is an equivalent way of switching when autowrite is set to avoid the <i>autowrite</i> (<i>edit</i> for <i>next</i>, <i>rewind!</i> for .I rewind , <i>stop!</i> for <i>stop</i>, <i>tag!</i> for <i>tag</i>, <i>shell</i> for <i>!</i>, and <b>:e #</b> and a <b>:ta!</b> command from within <i>visual).</i></small></td></table>

<p><small><b>beautify</b>, <b>bf</b> default:
nobeautify</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Causes all control characters except tab, newline and form-feed to be discarded from the input. A complaint is registered the first time a backspace character is discarded. <i>Beautify</i> does not apply to command input.</small></td></table>

<p><small><b>directory</b>, <b>dir</b> default:
dir=/tmp</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Specifies the directory in which <i>ex</i> places its buffer file. If this directory in not writable, then the editor will exit abruptly when it fails to be able to create its buffer there.</small></td></table>

<p><small><b>edcompatible</b> default:
noedcompatible</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Causes the presence of absence of <b>g</b> and <b>c</b> suffixes on substitute commands to be remembered, and to be toggled by repeating the suffices. The suffix <b>r</b> makes the substitution be as in the <i>~</i> command, instead of like <i>&amp;.</i></small></td></table>

<p><small><b>errorbells</b>, <b>eb</b> default:
noeb</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Error messages are preceded by a bell.*</small></td></table>


<p align=center><small></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>If possible the editor always places the error message in a standout mode of the terminal (such as inverse video) instead of ringing the bell.</small></td></table>

<p><small><b>hardtabs</b>, <b>ht</b> default:
ht=8</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Gives the boundaries on which terminal hardware tabs are set (or on which the system expands tabs).</small></td></table>

<p><small><b>ignorecase</b>, <b>ic</b> default:
noic</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>All upper case characters in the text are mapped to lower case in regular expression matching. In addition, all upper case characters in regular expressions are mapped to lower case except in character class specifications.</small></td></table>

<p><small><b>lisp</b> default: nolisp</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small><i>Autoindent</i> indents appropriately for <i>lisp</i> code, and the <b>( ) { } [[</b> and <b>]]</b> commands in <i>open</i> and <i>visual</i> are modified to have meaning for <i>lisp</i>.</small></td></table>

<p><small><b>list</b> default: nolist</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>All printed lines will be displayed (more) unambiguously, showing tabs and end-of-lines as in the <i>list</i> command.</small></td></table>

<p><small><b>magic</b> default: magic for <i>ex</i> and
<i>vi</i></small></p>


<p align=center><small></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>If <i>nomagic</i> is set, the number of regular expression metacharacters is greatly reduced, with only `' and `$' having special effects. In addition the metacharacters `~' and `&amp;' of the replacement pattern are treated as normal characters. All the normal metacharacters may be made <i>magic</i> when <i>nomagic</i> is set by preceding them with a `'.</small></td></table>

<p><small><b>mesg</b> default: mesg</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Causes write permission to be turned off to the terminal while you are in visual mode, if <i>nomesg</i> is set.</small></td></table>

<p><small><b>modeline</b> default: nomodeline</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>If <i>modeline</i> is set, then the first 5 lines and the last five lines of the file will be checked for ex command lines and the comands issued. To be recognized as a command line, the line must have the string <b>ex:</b> or <b>vi:</b> preceeded by a tab or a space. This string may be anywhere in the line and anything after the <i>:</i> is interpeted as editor commands. This option defaults to off because of unexpected behavior when editting files such as <i>/etc/passwd.</i></small></td></table>

<p><small><b>number, nu</b> default: nonumber</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Causes all output lines to be printed with their line numbers. In addition each input line will be prompted for by supplying the line number it will have.</small></td></table>

<p><small><b>open</b> default: open</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>If <i>noopen</i>, the commands <i>open</i> and <i>visual</i> are not permitted. This is set for <i>edit</i> to prevent confusion resulting from accidental entry to open or visual mode.</small></td></table>

<p><small><b>optimize, opt</b> default:
optimize</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Throughput of text is expedited by setting the terminal to not do automatic carriage returns when printing more than one (logical) line of output, greatly speeding output on terminals without addressable cursors when text with leading white space is printed.</small></td></table>

<p><small><b>paragraphs, para</b> default: para=IPLPPPQPP
LIbp</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Specifies the paragraphs for the <b>{</b> and <b>}</b> operations in <i>open</i> and <i>visual.</i> The pairs of characters in the option's value are the names of the macros which start paragraphs.</small></td></table>

<p><small><b>prompt</b> default: prompt</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Command mode input is prompted for with a `:'.</small></td></table>

<p><small><b>redraw</b> default: noredraw</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The editor simulates (using great amounts of output), an intelligent terminal on a dumb terminal (e.g. during insertions in <i>visual</i> the characters to the right of the cursor position are refreshed as each input character is typed.) Useful only at very high speed.</small></td></table>

<p><small><b>remap</b> default: remap</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>If on, macros are repeatedly tried until they are unchanged. For example, if <b>o</b> is mapped to <b>O</b>, and <b>O</b> is mapped to <b>I</b>, then if <i>remap</i> is set, <b>o</b> will map to <b>I</b>, but if <i>noremap</i> is set, it will map to <b>O</b>.</small></td></table>

<p><small><b>report</b> default: report=5</small></p>


<p align=center><small></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Specifies a threshold for feedback from commands. Any command which modifies more than the specified number of lines will provide feedback as to the scope of its changes. For commands such as <i>global</i>, <i>open</i>, <i>undo</i>, and <i>visual</i> which have potentially more far reaching scope, the net change in the number of lines in the buffer is presented at the end of the command, subject to this same threshold. Thus notification is suppressed during a <i>global</i> command on the individual commands performed.</small></td></table>

<p><small><b>scroll</b> default: scroll= window</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Determines the number of logical lines scrolled when an end-of-file is received from a terminal input in command mode, and the number of lines printed by a command mode <i>z</i> command (double the value of <i>scroll</i>).</small></td></table>

<p><small><b>sections</b> default: sections=SHNHH
HU</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Specifies the section macros for the <b>[[</b> and <b>]]</b> operations in <i>open</i> and <i>visual.</i> The pairs of characters in the options's value are the names of the macros which start paragraphs.</small></td></table>

<p><small><b>shell</b>, <b>sh</b> default:
sh=/bin/sh</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Gives the path name of the shell forked for the shell escape command `!', and by the <i>shell</i> command. The default is taken from SHELL in the environment, if present.</small></td></table>

<p><small><b>shiftwidth</b>, <b>sw</b> default:
sw=8</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Gives the width a software tab stop, used in reverse tabbing with <b>^D</b> when using <i>autoindent</i> to append text, and by the shift commands.</small></td></table>

<p><small><b>showmatch, sm</b> default: nosm</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>In <i>open</i> and <i>visual</i> mode, when a <b>)</b> or <b>}</b> is typed, move the cursor to the matching <b>(</b> or <b>{</b> for one second if this matching character is on the screen. Extremely useful with <i>lisp.</i></small></td></table>

<p><small><b>slowopen, slow</b> terminal
dependent</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Affects the display algorithm used in <i>visual</i> mode, holding off display updating during input of new text to improve throughput when the terminal in use is both slow and unintelligent. See <i>An Introduction to Display Editing with Vi</i> for more details.</small></td></table>

<p><small><b>tabstop, ts</b> default: ts=8</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The editor expands tabs in the input file to be on <i>tabstop</i> boundaries for the purposes of display.</small></td></table>

<p><small><b>taglength, tl</b> default: tl=0</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Tags are not significant beyond this many characters. A value of zero (the default) means that all characters are significant.</small></td></table>

<p><small><b>tags</b> default: tags=tags
/usr/lib/tags</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>A path of files to be used as tag files for the <i>tag</i> command. A requested tag is searched for in the specified files, sequentially. By default, files called <b>tags</b> are searched for in the current directory and in /usr/lib (a master file for the entire system).</small></td></table>

<p><small><b>term</b> from environment TERM</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The terminal type of the output device.</small></td></table>

<p><small><b>terse</b> default: noterse</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Shorter error diagnostics are produced for the experienced user.</small></td></table>

<p><small><b>warn</b> default: warn</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Warn if there has been `[No write since last change]' before a `!' command escape.</small></td></table>

<p><small><b>window</b> default: window=speed
dependent</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>The number of lines in a text window in the <i>visual</i> command. The default is 8 at slow speeds (600 baud or less), 16 at medium speed (1200 baud), and the full screen (minus one line) at higher speeds.</small></td></table>

<p><small><b>w300, w1200 w9600</b></small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>These are not true options but set <b>window</b> only if the speed is slow (300), medium (1200), or high (9600), respectively. They are suitable for an EXINIT and make it easy to change the 8/16/full screen rule.</small></td></table>

<p><small><b>wrapscan</b>, <b>ws</b> default:
ws</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Searches using the regular expressions in addressing will wrap around past the end of the file.</small></td></table>

<p><small><b>wrapmargin</b>, <b>wm</b> default:
wm=0</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Defines a margin for automatic wrapover of text during input in <i>open</i> and <i>visual</i> modes. See <i>An Introduction to Text Editing with Vi</i> for details.</small></td></table>

<p><small><b>writeany</b>, <b>wa</b> default:
nowa</small></p>
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="7%"></td><td width="93%">
<small>Inhibit the checks normally made before <i>write</i> commands, allowing a write to any file which the system protection mechanism will allow.</small></td></table>
<a name="10. Acknowledgements"></a>
<h2>10. Acknowledgements</h2>

<p><small>Chuck Haley contributed greatly to the early
development of <i>ex.</i> Bruce Englar encouraged the
redesign which led to <i>ex</i> version 1. Bill Joy wrote
versions 1 and 2.0 through 2.7, and created the framework
that users see in the present editor. Mark Horton added
macros and other features and made the editor work on a
large number of terminals and Unix systems.</small></p>
<hr>
</body>
</html>