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
|
.\"
.\" This code contains changes by
.\" Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved.
.\"
.\" Conditions 1, 2, and 4 and the no-warranty notice below apply
.\" to these changes.
.\"
.\"
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"
.\" Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" Redistributions of source code and documentation must retain the
.\" above copyright notice, this list of conditions and the following
.\" disclaimer.
.\" Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed or owned by Caldera
.\" International, Inc.
.\" Neither the name of Caldera International, Inc. nor the names of
.\" other contributors may be used to endorse or promote products
.\" derived from this software without specific prior written permission.
.\"
.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE
.\" LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" from vi.1 6.1 (Berkeley) 4/29/85
.\"
.\" Sccsid @(#)vi.1 1.26 (gritter) 3/12/03
.\"
.ie \n(.g==1 \{\
.ds lq \(lq
.ds rq \(rq
.\}
.el \{\
.ds lq ``
.ds rq ''
.\}
.TH VI 1 "3/12/03" "Ancient Unix Ports" "User Commands"
.SH NAME
vi, view, vedit \- screen oriented (visual) display editor based on ex
.SH SYNOPSIS
.HP
.ad l
\fBvi\fR [\fB\-c\fI\ command\fR|\fB+\fIcommand\fR]
[\fB\-r\fR\ [\fIfilename\fR]] [\fB\-s\fR|\fB\-\fR]
[\fB\-t\fI\ tagstring\fR] [\fB\-w\fI\ size\fR]
[\fB\-lLRV\fR] [\fIfile\fR ...]
.HP
.ad l
\fBview\fR [\fB\-c\fI\ command\fR|\fB+\fIcommand\fR]
[\fB\-r\fR\ [\fIfilename\fR]] [\fB\-s\fR|\fB\-\fR]
[\fB\-t\fI\ tagstring\fR] [\fB\-w\fI\ size\fR]
[\fB\-lLRV\fR] [\fIfile\fR ...]
.HP
.ad l
\fBvedit\fR [\fB\-c\fI\ command\fR|\fB+\fIcommand\fR]
[\fB\-r\fR\ [\fIfilename\fR]] [\fB\-s\fR|\fB\-\fR]
[\fB\-t\fI\ tagstring\fR] [\fB\-w\fI\ size\fR]
[\fB\-lLRV\fR] [\fIfile\fR ...]
.br
.ad b
.SH DESCRIPTION
.I Vi
(visual) is a display oriented text editor based on
.IR ex (1).
.I Ex
and
.I vi
run the same code; it is possible to get to
the command mode of
.I ex
from within
.I vi
and vice-versa.
.PP
The
.I view
command is identical to
.I vi
except that files are opened read-only.
The
.I vedit
command is also identical,
but sets some options to values more useful for novices.
.PP
The following options are accepted:
.TP
\fB\-c\fP\fI\ command\fP or \fB+\fP\fIcommand\fP
Execute
.I command
when editing begins.
.TP
.B \-l
Start in a special mode useful for the
.I Lisp
programming language.
.TP
\fB\-r\fI\ [filename]\fR or \fB\-L\fR
When no argument is supplied with this option,
all files to be recovered are listed
and the editor exits immediately.
If a
.I filename
is specified,
the corresponding temporary file is opened in recovery mode.
.TP
.B \-R
Files are opened read-only when this option is given.
.TP
.BR \-s \ or\ \-
Script mode;
all feedback for interactive editing is disabled.
.SM EXINIT
and
.I .exrc
files are not processed.
.TP
.BI \-t \ tagstring
Read the
.I tags
file,
then choose the file and position specified by
.I tagstring
for editing.
.TP
.B \-V
Echo command input to standard error,
unless it originates from a terminal.
.TP
.BI \-w \ size
Specify the size of the editing window for visual mode.
.PP
The
.I "Introduction to Display Editing with Vi"
provides full details on using
.I vi.
.PP
Most of the
.I ex
commands are available in
.I visual
mode when prefixed by a
.B :
character. See
.BR ex (1)
for a description of them.
.\" from vi.chars 8.1 (Berkeley) 6/8/93
.PP
The following gives the uses the editor makes of each character. The
characters are presented in their order in the \s-1ASCII\s0 character
set: Control characters come first, then most special characters, then
the digits, upper and then lower case characters.
.PP
For each character we tell a meaning it has as a command and any meaning it
has during an insert.
If it has only meaning as a command, then only this is discussed.
Section numbers in parentheses indicate where the character is discussed
in \*(lqAn Introduction to Display Editing with Vi\*(rq;
a `f' after the section number means that the character is mentioned
in a footnote.
.TP
\fB^@\fR
Not a command character.
If typed as the first character of an insertion it is replaced with the
last text inserted, and the insert terminates. Only 128 characters are
saved from the last insert; if more characters were inserted the mechanism
is not available.
A \fB^@\fR cannot be part of the file due to the editor implementation
(7.5f).
.TP
\fB^A\fR
Unused.
.TP
\fB^B\fR
Backward window.
A count specifies repetition.
Two lines of continuity are kept if possible (2.1, 6.1, 7.2).
.TP
\fB^C\fR
Unused.
.TP
\fB^D\fR
As a command, scrolls down a half-window of text.
A count gives the number of (logical) lines to scroll, and is remembered
for future \fB^D\fR and \fB^U\fR commands (2.1, 7.2).
During an insert, backtabs over \fIautoindent\fR white space at the beginning
of a line (6.6, 7.5); this white space cannot be backspaced over.
.TP
\fB^E\fR
Exposes one more line below the current screen in the file, leaving
the cursor where it is if possible.
.TP
\fB^F\fR
Forward window. A count specifies repetition.
Two lines of continuity are kept if possible (2.1, 6.1, 7.2).
.TP
\fB^G\fR
Equivalent to \fB:f\fR\s-1CR\s0, printing the current file, whether
it has been modified, the current line number and the number of lines
in the file, and the percentage of the way through the file.
.TP
\fB^H (\fR\s-1BS\s0\fB)\fR
Same as
.BR "left arrow" .
(See
.BR h ).
During an insert, eliminates the last input character, backing over it
but not erasing it; it remains so the user can see what he typed if he
wishes to type something only slightly different (3.1, 7.5).
.TP
\fB^I\ (\fR\s-1TAB\s0\fB)\fR
Not a command character.
When inserted it prints as some
number of spaces.
When the cursor is at a tab character it rests at the last of the spaces
which represent the tab.
The spacing of tabstops is controlled by the \fItabstop\fR option (4.1, 6.6).
.TP
\fB^J\ (\fR\s-1LF\s0\fB)\fR
Same as
.B "down arrow"
(see
.BR j ).
.TP
\fB^K\fR
Unused.
.TP
\fB^L\fR
The \s-1ASCII\s0 formfeed character, this causes the screen to be cleared
and redrawn. This is useful after a transmission error, if characters
typed by a program other than the editor scramble the screen,
or after output is stopped by an interrupt (5.4, 7.2f).
.TP
\fB^M\ (\fR\s-1CR\s0\fB)\fR
A carriage return advances to the next line, at the first non-white position
in the line. Given a count, it advances that many lines (2.3).
During an insert, a \s-1CR\s0 causes the insert to continue onto
another line (3.1).
.TP
\fB^N\fR
Same as
.B "down arrow"
(see
.BR j ).
.TP
\fB^O\fR
Unused.
.TP
\fB^P\fR
Same as
.B "up arrow"
(see
.BR k ).
.TP
\fB^Q\fR
Not a command character.
In input mode,
.B ^Q
quotes the next character, the same as
.B ^V ,
except that some teletype drivers will eat the
.B ^Q
so that the editor never sees it.
.TP
\fB^R\fR
Redraws the current screen, eliminating logical lines not corresponding
to physical lines (lines with only a single @ character on them).
On hardcopy terminals in \fIopen\fR mode, retypes the current line
(5.4, 7.2, 7.8).
.TP
\fB^S\fR
Unused. Some teletype drivers use
.B ^S
to suspend output until
.B ^Q is pressed.
.TP
\fB^T\fR
Not a command character.
During an insert, with \fIautoindent\fR set and at the beginning of the
line, inserts \fIshiftwidth\fR white space.
.TP
\fB^U\fR
Scrolls the screen up, inverting \fB^D\fR which scrolls down. Counts work as
they do for \fB^D\fR, and the previous scroll amount is common to both.
On a dumb terminal, \fB^U\fR will often necessitate clearing and redrawing
the screen further back in the file (2.1, 7.2).
.TP
\fB^V\fR
Not a command character.
In input mode, quotes the next character so that it is possible
to insert non-printing and special characters into the file (4.2, 7.5).
.TP
\fB^W\fR
Not a command character.
During an insert, backs up as \fBb\fR would in command mode; the deleted
characters remain on the display (see \fB^H\fR) (7.5).
.TP
\fB^X\fR
Unused.
.TP
\fB^Y\fR
Exposes one more line above the current screen, leaving the cursor where
it is if possible. (No mnemonic value for this key; however, it is next
to \fB^U\fR which scrolls up a bunch.)
.TP
\fB^Z\fR
If supported by the Unix system,
stops the editor, exiting to the top level shell.
Same as \fB:stop\fP\s-1CR\s0.
Otherwise, unused.
.TP
\fB^[\ (\fR\s-1ESC\s0\fB)\fR
Cancels a partially formed command, such as a \fBz\fR when no following
character has yet been given; terminates inputs on the last line (read
by commands such as \fB: /\fR and \fB?\fR); ends insertions of new text
into the buffer.
If an \s-1ESC\s0 is given when quiescent in command state, the editor
rings the bell or flashes the screen. The user can thus hit \s-1ESC\s0 if
he doesn't know what is happening till the editor rings the bell.
If the user doesn't know whether he is in insert mode
he can type \s-1ESC\s0\fBa\fR,
and then material to be input; the material will be inserted correctly
whether or not he was in insert mode when he started (1.6, 3.1, 7.5).
.TP
\fB^\e\fR
Unused.
.TP
\fB^]\fR
Searches for the word which is after the cursor as a tag. Equivalent
to typing \fB:ta\fR, this word, and then a \s-1CR\s0.
Mnemonically, this command is \*(lq right to\*(rq (7.3).
.TP
\fB^^\fR
Equivalent to \fB:e #\fR\s-1CR\s0, returning to the previous position
in the last edited file, or editing a file which the user specified if he
got a `No write since last change diagnostic' and does not want to have
to type the file name again (7.3).
(The user has to do a \fB:w\fR before \fB^^\fR
will work in this case. If he does not wish to write the file he should
do \fB:e!\ #\fR\s-1CR\s0 instead.)
.TP
\fB^_\fR
Unused.
Reserved as the command character for the
Tektronix 4025 and 4027 terminal.
.TP
\fB\fR\s-1SPACE\s0\fB\fR
Same as
.B "right arrow"
(see
.BR l ).
.TP
\fB!\fR
An operator, which processes lines from the buffer with reformatting commands.
Follow \fB!\fR with the object to be processed, and then the command name
terminated by \s-1CR\s0. Doubling \fB!\fR and preceding it by a count
causes count lines to be filtered; otherwise the count
is passed on to the object after the \fB!\fR. Thus \fB2!}\fR\fIfmt\fR\s-1CR\s0
reformats the next two paragraphs by running them through the program
\fIfmt\fR. If working on \s-1LISP\s0,
the command \fB!%\fR\fIgrind\fR\s-1CR\s0,
.\"*
.\".FS
.\"*Both
.\".I fmt
.\"and
.\".I grind
.\"are Berkeley programs and may not be present at all installations.
.\".FE
given at the beginning of a
function, will run the text of the function through the \s-1LISP\s0 grinder
(6.7, 7.3).
To read a file or the output of a command into the buffer \fB:r\fR (7.3)
can be used.
To simply execute a command, \fB:!\fR (7.3).
.tr "
.iP 15
Precedes a named buffer specification. There are named buffers \fB1\-9\fR
used for saving deleted text and named buffers \fBa\-z\fR into which the
user can place text (4.3, 6.3)
.tr
.TP
\fB#\fR
The macro character which, when followed by a number, will substitute
for a function key on terminals without function keys (6.9).
In input mode,
if this is the erase character, it will delete the last character
typed in input mode, and must be preceded with a \fB\e\fR to insert
it, since it normally backs over the last input character.
.TP
\fB$\fR
Moves to the end of the current line. If the \fBlist\fR option is set,
then the end of each line will be shown by printing a \fB$\fR after the
end of the displayed text in the line. Given a count, advances to the
count'th following end of line; thus \fB2$\fR advances to the end of the
following line.
.TP
\fB%\fR
Moves to the parenthesis or brace \fB{ }\fR which balances the parenthesis
or brace at the current cursor position.
.TP
\fB&\fR
A synonym for \fB:&\fR\s-1CR\s0, by analogy with the
.I ex
.B &
command.
.TP
\fB\(aa\fR
When followed by a \fB\(aa\fR returns to the previous context at the
beginning of a line. The previous context is set whenever the current
line is moved in a non-relative way.
When followed by a letter \fBa\fR\-\fBz\fR, returns to the line which
was marked with this letter with a \fBm\fR command, at the first non-white
character in the line. (2.2, 5.3).
When used with an operator such as \fBd\fR, the operation takes place
over complete lines; if \fB\(ga\fR is used, the operation takes place
from the exact marked place to the current cursor position within the
line.
.TP
\fB(\fR
Retreats to the beginning of a
sentence, or to the beginning of a \s-1LISP\s0 s-expression
if the \fIlisp\fR option is set.
A sentence ends at a \fB. !\fR or \fB?\fR which is followed by either
the end of a line or by two spaces. Any number of closing \fB) ] "\fR
and \fB\(aa\fR characters may appear after the \fB. !\fR or \fB?\fR,
and before the spaces or end of line. Sentences also begin
at paragraph and section boundaries
(see \fB{\fR and \fB[[\fR below).
A count advances that many sentences (4.2, 6.8).
.TP
\fB)\fR
Advances to the beginning of a sentence.
A count repeats the effect.
See \fB(\fR above for the definition of a sentence (4.2, 6.8).
.TP
\fB*\fR
Unused.
.TP
\fB+\fR
Same as \s-1CR\s0 when used as a command.
.TP
\fB,\fR
Reverse of the last \fBf F t\fR or \fBT\fR command, looking the other way
in the current line. Especially useful after hitting too many \fB;\fR
characters. A count repeats the search.
.TP
\fB\-\fR
Retreats to the previous line at the first non-white character.
This is the inverse of \fB+\fR and \s-1RETURN\s0.
If the line moved to is not on the screen, the screen is scrolled, or
cleared and redrawn if this is not possible.
If a large amount of scrolling would be required the screen is also cleared
and redrawn, with the current line at the center (2.3).
.TP
\fB\&.\fR
Repeats the last command which changed the buffer. Especially useful
when deleting words or lines; the user can delete some words/lines and then
hit \fB.\fR to delete more and more words/lines.
Given a count, it passes it on to the command being repeated. Thus after
a \fB2dw\fR, \fB3.\fR deletes three words (3.3, 6.3, 7.2, 7.4).
.TP
\fB/\fR
Reads a string from the last line on the screen, and scans forward for
the next occurrence of this string. The normal input editing sequences may
be used during the input on the bottom line; an returns to command state
without ever searching.
The search begins when the user hits \s-1CR\s0 to terminate the pattern;
the cursor moves to the beginning of the last line to indicate that the search
is in progress; the search may then
be terminated with a \s-1DEL\s0 or \s-1RUB\s0, or by backspacing when
at the beginning of the bottom line, returning the cursor to
its initial position.
Searches normally wrap end-around to find a string
anywhere in the buffer.
.IP
When used with an operator the enclosed region is normally affected.
By mentioning an
offset from the line matched by the pattern the user can force whole lines
to be affected. To do this a pattern with a closing
a closing \fB/\fR and then an offset \fB+\fR\fIn\fR or \fB\-\fR\fIn\fR
must be given.
.IP
To include the character \fB/\fR in the search string, it must be escaped
with a preceding \fB\e\fR.
A \fB^\fR at the beginning of the pattern forces the match to occur
at the beginning of a line only; this speeds the search. A \fB$\fR at
the end of the pattern forces the match to occur at the end of a line
only.
More extended pattern matching is available, see section 7.4;
unless \fBnomagic\fR ist set in the \fI\&.exrc\fR file the user will have
to preceed the characters \fB. [ *\fR and \fB~\fR in the search pattern
with a \fB\e\fR to get them to work as one would naively expect (1.6, 2.2,
6.1, 7.2, 7.4).
.TP
\fB0\fR
Moves to the first character on the current line.
Also used, in forming numbers, after an initial \fB1\fR\-\fB9\fR.
.TP
\fB1\-9\fR
Used to form numeric arguments to commands (2.3, 7.2).
.TP
\fB:\fR
A prefix to a set of commands for file and option manipulation and escapes
to the system. Input is given on the bottom line and terminated with
an \s-1CR\s0, and the command then executed. The user can return to where
he was by hitting \s-1DEL\s0 or \s-1RUB\s0 if he hit \fB:\fR accidentally
(see
.BR ex (1)
and primarily 6.2 and 7.3).
.TP
\fB;\fR
Repeats the last single character find which used \fBf F t\fR or \fBT\fR.
A count iterates the basic scan (4.1).
.TP
\fB<\fR
An operator which shifts lines left one \fIshiftwidth\fR, normally 8
spaces. Like all operators, affects lines when repeated, as in
\fB<<\fR. Counts are passed through to the basic object, thus \fB3<<\fR
shifts three lines (6.6, 7.2).
.TP
\fB=\fR
Reindents line for \s-1LISP\s0, as though they were typed in with \fIlisp\fR
and \fIautoindent\fR set (6.8).
.TP
\fB>\fR
An operator which shifts lines right one \fIshiftwidth\fR, normally 8
spaces. Affects lines when repeated as in \fB>>\fR. Counts repeat the
basic object (6.6, 7.2).
.TP
\fB?\fR
Scans backwards, the opposite of \fB/\fR. See the \fB/\fR description
above for details on scanning (2.2, 6.1, 7.4).
.TP
\fB@\fR
A macro character (6.9). If this is the kill character, it must be escaped
with a \e
to type it in during input mode, as it normally backs over the input
given on the current line (3.1, 3.4, 7.5).
.TP
\fBA\fR
Appends at the end of line, a synonym for \fB$a\fR (7.2).
.TP
\fBB\fR
Backs up a word, where words are composed of non-blank sequences, placing
the cursor at the beginning of the word. A count repeats the effect
(2.4).
.TP
\fBC\fR
Changes the rest of the text on the current line; a synonym for \fBc$\fR.
.TP
\fBD\fR
Deletes the rest of the text on the current line; a synonym for \fBd$\fR.
.TP
\fBE\fR
Moves forward to the end of a word, defined as blanks and non-blanks,
like \fBB\fR and \fBW\fR. A count repeats the effect.
.TP
\fBF\fR
Finds a single following character, backwards in the current line.
A count repeats this search that many times (4.1).
.TP
\fBG\fR
Goes to the line number given as preceding argument, or the end of the
file if no preceding count is given. The screen is redrawn with the
new current line in the center if necessary (7.2).
.TP
\fBH\fR
.BR "Home arrow" .
Homes the cursor to the top line on the screen. If a count is given,
then the cursor is moved to the count'th line on the screen.
In any case the cursor is moved to the first non-white character on the
line. If used as the target of an operator, full lines are affected
(2.3, 3.2).
.TP
\fBI\fR
Inserts at the beginning of a line; a synonym for \fB^i\fR.
.TP
\fBJ\fR
Joins together lines, supplying appropriate white space: one space between
words, two spaces after a \fB.\fR, and no spaces at all if the first
character of the joined on line is \fB)\fR. A count causes that many
lines to be joined rather than the default two (6.5, 7.1f).
.TP
\fBK\fR
Unused.
.TP
\fBL\fR
Moves the cursor to the first non-white character of the last line on
the screen. With a count, to the first non-white of the count'th line
from the bottom. Operators affect whole lines when used with \fBL\fR
(2.3).
.TP
\fBM\fR
Moves the cursor to the middle line on the screen, at the first non-white
position on the line (2.3).
.TP
\fBN\fR
Scans for the next match of the last pattern given to
\fB/\fR or \fB?\fR, but in the reverse direction; this is the reverse
of \fBn\fR.
.TP
\fBO\fR
Opens a new line above the current line and inputs text there up to an
\s-1ESC\s0. A count can be used on dumb terminals to specify a number
of lines to be opened; this is generally obsolete, as the \fIslowopen\fR
option works better (3.1).
.TP
\fBP\fR
Puts the last deleted text back before/above the cursor. The text goes
back as whole lines above the cursor if it was deleted as whole lines.
Otherwise the text is inserted between the characters before and at the
cursor. May be preceded by a named buffer specification \fB"\fR\fIx\fR
to retrieve the contents of the buffer; buffers \fB1\fR\-\fB9\fR contain
deleted material, buffers \fBa\fR\-\fBz\fR are available for general
use (6.3).
.TP
\fBQ\fR
Quits from \fIvi\fR to \fIex\fR command mode. In this mode, whole lines
form commands, ending with a \s-1RETURN\s0. One can give all the \fB:\fR
commands; the editor supplies the \fB:\fR as a prompt (7.7).
.TP
\fBR\fR
Replaces characters on the screen with characters typed (overlay fashion).
Terminates with an \s-1ESC\s0.
.TP
\fBS\fR
Changes whole lines, a synonym for \fBcc\fR. A count substitutes for
that many lines. The lines are saved in the numeric buffers, and erased
on the screen before the substitution begins.
.TP
\fBT\fR
Takes a single following character, locates the character before the
cursor in the current line, and places the cursor just after that character.
A count repeats the effect. Most useful with operators such as \fBd\fR
(4.1).
.TP
\fBU\fR
Restores the current line to its state before the user started changing it
(3.5).
.TP
\fBV\fR
Unused.
.TP
\fBW\fR
Moves forward to the beginning of a word in the current line,
where words are defined as sequences of blank/non-blank characters.
A count repeats the effect (2.4).
.TP
\fBX\fR
Deletes the character before the cursor. A count repeats the effect,
but only characters on the current line are deleted.
.TP
\fBY\fR
Yanks a copy of the current line into the unnamed buffer, to be put back
by a later \fBp\fR or \fBP\fR; a very useful synonym for \fByy\fR.
A count yanks that many lines. May be preceded by a buffer name to put
lines in that buffer (7.4).
.TP
\fBZZ\fR
Exits the editor.
(Same as \fB:x\fP\s-1CR\s0.)
If any changes have been made, the buffer is written out to the current file.
Then the editor quits.
.TP
\fB[[\fR
Backs up to the previous section boundary. A section begins at each
macro in the \fIsections\fR option,
normally a `.NH' or `.SH' and also at lines which which start
with a formfeed \fB^L\fR. Lines beginning with \fB{\fR also stop \fB[[\fR;
this makes it useful for looking backwards, a function at a time, in C
programs. If the option \fIlisp\fR is set, stops at each \fB(\fR at the
beginning of a line, and is thus useful for moving backwards at the top
level \s-1LISP\s0 objects. (4.2, 6.1, 6.6, 7.2).
.TP
\fB\e\fR
Unused.
.TP
\fB]]\fR
Forward to a section boundary, see \fB[[\fR for a definition (4.2, 6.1,
6.6, 7.2).
.TP
\fB^\fR
Moves to the first non-white position on the current line (4.4).
.TP
\fB_\fR
Unused.
.TP
\fB\(ga\fR
When followed by a \fB\(ga\fR returns to the previous context.
The previous context is set whenever the current
line is moved in a non-relative way.
When followed by a letter \fBa\fR\-\fBz\fR, returns to the position which
was marked with this letter with a \fBm\fR command.
When used with an operator such as \fBd\fR, the operation takes place
from the exact marked place to the current position within the line;
if using \fB\(aa\fR, the operation takes place over complete lines
(2.2, 5.3).
.TP
\fBa\fR
Appends arbitrary text after the current cursor position; the insert
can continue onto multiple lines by using \s-1RETURN\s0 within the insert.
A count causes the inserted text to be replicated, but only if the inserted
text is all on one line.
The insertion terminates with an \s-1ESC\s0 (3.1, 7.2).
.TP
\fBb\fR
Backs up to the beginning of a word in the current line. A word is a
sequence of alphanumerics, or a sequence of special characters.
A count repeats the effect (2.4).
.TP
\fBc\fR
An operator which changes the following object, replacing it with the
following input text up to an \s-1ESC\s0. If more than part of a single
line is affected, the text which is changed away is saved in the numeric named
buffers. If only part of the current line is affected, then the last
character to be changed away is marked with a \fB$\fR.
A count causes that many objects to be affected, thus both
\fB3c)\fR and \fBc3)\fR change the following three sentences (7.4).
.TP
\fBd\fR
An operator which deletes the following object. If more than part of
a line is affected, the text is saved in the numeric buffers.
A count causes that many objects to be affected; thus \fB3dw\fR is the
same as \fBd3w\fR (3.3, 3.4, 4.1, 7.4).
.TP
\fBe\fR
Advances to the end of the next word, defined as for \fBb\fR and \fBw\fR.
A count repeats the effect (2.4, 3.1).
.TP
\fBf\fR
Finds the first instance of the next character following the cursor on
the current line. A count repeats the find (4.1).
.TP
\fBg\fR
Unused.
.sp
Arrow keys
.BR h ,
.BR j ,
.BR k ,
.BR l ,
and
.BR H .
.TP
\fBh\fR
.B "Left arrow" .
Moves the cursor one character to the left.
Like the other arrow keys, either
.BR h ,
the
.B "left arrow"
key, or one of the synonyms (\fB^H\fP) has the same effect.
A count repeats the effect (3.1, 7.5).
.TP
\fBi\fR
Inserts text before the cursor, otherwise like \fBa\fR (7.2).
.TP
\fBj\fR
.B "Down arrow" .
Moves the cursor one line down in the same column.
If the position does not exist,
.I vi
comes as close as possible to the same column.
Synonyms include
.B ^J
(linefeed) and
.B ^N .
.TP
\fBk\fR
.B "Up arrow" .
Moves the cursor one line up.
.B ^P
is a synonym.
.TP
\fBl\fR
.B "Right arrow" .
Moves the cursor one character to the right.
\s-1SPACE\s0 is a synonym.
.TP
\fBm\fR
Marks the current position of the cursor in the mark register which is
specified by the next character \fBa\fR\-\fBz\fR. The user can return
to this position or use it with an operator
using \fB\(ga\fR or \fB\(aa\fR (5.3).
.TP
\fBn\fR
Repeats the last \fB/\fR or \fB?\fR scanning commands (2.2).
.TP
\fBo\fR
Opens new lines below the current line; otherwise like \fBO\fR (3.1).
.TP
\fBp\fR
Puts text after/below the cursor; otherwise like \fBP\fR (6.3).
.TP
\fBq\fR
Unused.
.TP
\fBr\fR
Replaces the single character at the cursor with a single character typed.
The new character may be a \s-1RETURN\s0; this is the easiest
way to split lines. A count replaces each of the following count characters
with the single character given; see \fBR\fR above which is the more
usually useful iteration of \fBr\fR (3.2).
.TP
\fBs\fR
Changes the single character under the cursor to the text which follows
up to an \s-1ESC\s0; given a count, that many characters from the current
line are changed. The last character to be changed is marked with \fB$\fR
as in \fBc\fR (3.2).
.TP
\fBt\fR
Advances the cursor upto the character before the next character typed.
Most useful with operators such as \fBd\fR and \fBc\fR to delete the
characters up to a following character. One can use \fB.\fR to delete
more if this doesn't delete enough the first time (4.1).
.TP
\fBu\fR
Undoes the last change made to the current buffer. If repeated, will
alternate between these two states, thus is its own inverse. When used
after an insert which inserted text on more than one line, the lines are
saved in the numeric named buffers (3.5).
.TP
\fBv\fR
Unused.
.TP
\fBw\fR
Advances to the beginning of the next word, as defined by \fBb\fR (2.4).
.TP
\fBx\fR
Deletes the single character under the cursor. With a count deletes
deletes that many characters forward from the cursor position, but only
on the current line (6.5).
.TP
\fBy\fR
An operator, yanks the following object into the unnamed temporary buffer.
If preceded by a named buffer specification, \fB"\fR\fIx\fR, the text
is placed in that buffer also. Text can be recovered by a later \fBp\fR
or \fBP\fR (7.4).
.TP
\fBz\fR
Redraws the screen with the current line placed as specified by the following
character: \s-1RETURN\s0 specifies the top of the screen, \fB.\fR the
center of the screen, and \fB\-\fR at the bottom of the screen.
A count may be given after the \fBz\fR and before the following character
to specify the new screen size for the redraw.
A count before the \fBz\fR gives the number of the line to place in the
center of the screen instead of the default current line. (5.4)
.TP
\fB{\fR
Retreats to the beginning of the beginning of the preceding paragraph.
A paragraph begins at each macro in the \fIparagraphs\fR option, normally
`.IP', `.LP', `.PP', `.QP' and `.bp'.
A paragraph also begins after a completely
empty line, and at each section boundary (see \fB[[\fR above) (4.2, 6.8,
7.6).
.TP
\fB|\fR
Places the cursor on the character in the column specified
by the count (7.1, 7.2).
.TP
\fB}\fR
Advances to the beginning of the next paragraph. See \fB{\fR for the
definition of paragraph (4.2, 6.8, 7.6).
.TP
\fB~\fR
Switches the case of the given count of characters
starting from the current cursor position to the end of the current line.
Non-alphabetic characters remain unchanged.
.TP
\fB^?\ (\s-1\fRDEL\fB\s0)\fR
Interrupts the editor, returning it to command accepting state (1.6,
7.5).
.SH "ENVIRONMENT VARIABLES"
.PP
The following environment variables affect the behaviour of vi:
.TP
.B COLUMNS
Overrides the system-supplied number of terminal columns.
.TP
.B EXINIT
Contains commands to execute at editor startup.
If this variable is present, the
.I .exrc
file in the user's home directory is ignored.
.TP
.B HOME
Used to locate the editor startup file.
.TP
.BR LANG ", " LC_ALL
See
.IR locale (7).
.TP
.B LC_CTYPE
Determines the mapping of bytes to characters,
types of characters,
case conversion
and composition of character classes in regular expressions.
.TP
.B LC_MESSAGES
Sets the language used for diagnostic and informal messages.
.TP
.B LINES
Overrides the system-supplied number of terminal lines.
.TP
.B NLSPATH
See
.IR catopen (3).
.TP
.B SHELL
The program file used to execute external commands.
.TP
.B TERM
Determines the terminal type.
.SH FILES
.TP
.B /usr/libexec/expreserve
preserve command
.TP
.B /usr/libexec/exrecover
recover command
.TP
.B /etc/termcap
describes capabilities of terminals
.TP
.B $HOME/.exrc
editor startup file
.TP
.B /var/tmp/Ex\fInnnnnnnnnn\fP
editor temporary
.TP
.B /var/tmp/Rx\fInnnnnnnnnn\fP
named buffer temporary
.TP
.B /var/preserve
preservation directory
.SH SEE ALSO
ex(1),
edit(1),
\*(lqVi Quick Reference\*(rq card,
\*(lqAn Introduction to Display Editing with Vi\*(rq.
.SH AUTHOR
William Joy.
.PP
Mark Horton added macros to
.I visual
mode and was maintaining version 3.
.PP
This version incorporates changes by Gunnar Ritter.
.SH NOTES
Software tabs using \fB^T\fP work only immediately after the
.I autoindent.
.PP
Left and right shifts on intelligent terminals don't make use of
insert and delete character operations in the terminal.
.PP
The
.I wrapmargin
option can be fooled since it looks at output columns when blanks are typed.
If a long word passes through the margin and onto the next line without a
break, then the line won't be broken.
.PP
Insert/delete within a line can be slow if tabs are present on intelligent
terminals, since the terminals need help in doing this correctly.
.\".PP
.\"Saving text on deletes in the named buffers is somewhat inefficient.
.PP
The
.I source
command does not work when executed as \fB:source\fP;
there is no way to use the \fB:append\fP, \fB:change\fP,
and \fB:insert\fP commands, since it is not possible to give
more than one line of input to a \fB:\fP escape. To use these
on a \fB:global\fP one must \fBQ\fP to \fIex\fP command mode,
execute them, and then reenter the screen editor with
.I vi
or
.I open.
|