Subversion Repositories planix.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
99 7u83 1
.\"
2
.\" This code contains changes by
3
.\"      Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved.
4
.\"
5
.\" Conditions 1, 2, and 4 and the no-warranty notice below apply
6
.\" to these changes.
7
.\"
8
.\"
9
.\" Copyright (c) 1980, 1993
10
.\" 	The Regents of the University of California.  All rights reserved.
11
.\"
12
.\" Redistribution and use in source and binary forms, with or without
13
.\" modification, are permitted provided that the following conditions
14
.\" are met:
15
.\" 1. Redistributions of source code must retain the above copyright
16
.\"    notice, this list of conditions and the following disclaimer.
17
.\" 2. Redistributions in binary form must reproduce the above copyright
18
.\"    notice, this list of conditions and the following disclaimer in the
19
.\"    documentation and/or other materials provided with the distribution.
20
.\" 3. All advertising materials mentioning features or use of this software
21
.\"    must display the following acknowledgement:
22
.\" 	This product includes software developed by the University of
23
.\" 	California, Berkeley and its contributors.
24
.\" 4. Neither the name of the University nor the names of its contributors
25
.\"    may be used to endorse or promote products derived from this software
26
.\"    without specific prior written permission.
27
.\"
28
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38
.\" SUCH DAMAGE.
39
.\"
40
.\"
41
.\" Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
42
.\"
43
.\" Redistribution and use in source and binary forms, with or without
44
.\" modification, are permitted provided that the following conditions
45
.\" are met:
46
.\"   Redistributions of source code and documentation must retain the
47
.\"    above copyright notice, this list of conditions and the following
48
.\"    disclaimer.
49
.\"   Redistributions in binary form must reproduce the above copyright
50
.\"    notice, this list of conditions and the following disclaimer in the
51
.\"    documentation and/or other materials provided with the distribution.
52
.\"   All advertising materials mentioning features or use of this software
53
.\"    must display the following acknowledgement:
54
.\"      This product includes software developed or owned by Caldera
55
.\"      International, Inc.
56
.\"   Neither the name of Caldera International, Inc. nor the names of
57
.\"    other contributors may be used to endorse or promote products
58
.\"    derived from this software without specific prior written permission.
59
.\"
60
.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
61
.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
62
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
63
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
64
.\" ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE
65
.\" LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR
66
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
67
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
68
.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
69
.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
70
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
71
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
72
.\"
73
.\"	from vi.1	6.1 (Berkeley) 4/29/85
74
.\"
75
.\"	Sccsid @(#)vi.1	1.26 (gritter) 3/12/03
76
.\"
77
.ie \n(.g==1 \{\
78
.ds lq \(lq
79
.ds rq \(rq
80
.\}
81
.el \{\
82
.ds lq ``
83
.ds rq ''
84
.\}
85
.TH VI 1 "3/12/03" "Ancient Unix Ports" "User Commands"
86
.SH NAME
87
vi, view, vedit \- screen oriented (visual) display editor based on ex
88
.SH SYNOPSIS
89
.HP
90
.ad l
91
\fBvi\fR [\fB\-c\fI\ command\fR|\fB+\fIcommand\fR]
92
[\fB\-r\fR\ [\fIfilename\fR]] [\fB\-s\fR|\fB\-\fR]
93
[\fB\-t\fI\ tagstring\fR] [\fB\-w\fI\ size\fR]
94
[\fB\-lLRV\fR] [\fIfile\fR ...]
95
.HP
96
.ad l
97
\fBview\fR [\fB\-c\fI\ command\fR|\fB+\fIcommand\fR]
98
[\fB\-r\fR\ [\fIfilename\fR]] [\fB\-s\fR|\fB\-\fR]
99
[\fB\-t\fI\ tagstring\fR] [\fB\-w\fI\ size\fR]
100
[\fB\-lLRV\fR] [\fIfile\fR ...]
101
.HP
102
.ad l
103
\fBvedit\fR [\fB\-c\fI\ command\fR|\fB+\fIcommand\fR]
104
[\fB\-r\fR\ [\fIfilename\fR]] [\fB\-s\fR|\fB\-\fR]
105
[\fB\-t\fI\ tagstring\fR] [\fB\-w\fI\ size\fR]
106
[\fB\-lLRV\fR] [\fIfile\fR ...]
107
.br
108
.ad b
109
.SH DESCRIPTION
110
.I Vi
111
(visual) is a display oriented text editor based on
112
.IR ex (1).
113
.I Ex
114
and
115
.I vi
116
run the same code; it is possible to get to
117
the command mode of
118
.I ex
119
from within
120
.I vi
121
and vice-versa.
122
.PP
123
The
124
.I view
125
command is identical to
126
.I vi
127
except that files are opened read-only.
128
The
129
.I vedit
130
command is also identical,
131
but sets some options to values more useful for novices.
132
.PP
133
The following options are accepted:
134
.TP
135
\fB\-c\fP\fI\ command\fP or \fB+\fP\fIcommand\fP
136
Execute
137
.I command
138
when editing begins.
139
.TP
140
.B \-l
141
Start in a special mode useful for the
142
.I Lisp
143
programming language.
144
.TP
145
\fB\-r\fI\ [filename]\fR or \fB\-L\fR
146
When no argument is supplied with this option,
147
all files to be recovered are listed
148
and the editor exits immediately.
149
If a
150
.I filename
151
is specified,
152
the corresponding temporary file is opened in recovery mode.
153
.TP
154
.B \-R
155
Files are opened read-only when this option is given.
156
.TP
157
.BR \-s \ or\  \-
158
Script mode;
159
all feedback for interactive editing is disabled.
160
.SM EXINIT
161
and
162
.I .exrc
163
files are not processed.
164
.TP
165
.BI \-t \ tagstring
166
Read the
167
.I tags
168
file,
169
then choose the file and position specified by
170
.I tagstring
171
for editing.
172
.TP
173
.B \-V
174
Echo command input to standard error,
175
unless it originates from a terminal.
176
.TP
177
.BI \-w \ size
178
Specify the size of the editing window for visual mode.
179
.PP
180
The
181
.I "Introduction to Display Editing with Vi"
182
provides full details on using
183
.I vi.
184
.PP
185
Most of the
186
.I ex
187
commands are available in
188
.I visual
189
mode when prefixed by a
190
.B :
191
character. See
192
.BR ex (1)
193
for a description of them.
194
.\"	from vi.chars	8.1 (Berkeley) 6/8/93
195
.PP
196
The following gives the uses the editor makes of each character.  The
197
characters are presented in their order in the \s-1ASCII\s0 character
198
set:  Control characters come first, then most special characters, then
199
the digits, upper and then lower case characters.
200
.PP
201
For each character we tell a meaning it has as a command and any meaning it
202
has during an insert.
203
If it has only meaning as a command, then only this is discussed.
204
Section numbers in parentheses indicate where the character is discussed
205
in \*(lqAn Introduction to Display Editing with Vi\*(rq;
206
a `f' after the section number means that the character is mentioned
207
in a footnote.
208
.TP
209
\fB^@\fR
210
Not a command character.
211
If typed as the first character of an insertion it is replaced with the
212
last text inserted, and the insert terminates.  Only 128 characters are
213
saved from the last insert; if more characters were inserted the mechanism
214
is not available.
215
A \fB^@\fR cannot be part of the file due to the editor implementation
216
(7.5f).
217
.TP
218
\fB^A\fR
219
Unused.
220
.TP
221
\fB^B\fR
222
Backward window.
223
A count specifies repetition.
224
Two lines of continuity are kept if possible (2.1, 6.1, 7.2).
225
.TP
226
\fB^C\fR
227
Unused.
228
.TP
229
\fB^D\fR
230
As a command, scrolls down a half-window of text.  
231
A count gives the number of (logical) lines to scroll, and is remembered
232
for future \fB^D\fR and \fB^U\fR commands (2.1, 7.2).
233
During an insert, backtabs over \fIautoindent\fR white space at the beginning
234
of a line (6.6, 7.5); this white space cannot be backspaced over.
235
.TP
236
\fB^E\fR
237
Exposes one more line below the current screen in the file, leaving
238
the cursor where it is if possible.
239
.TP
240
\fB^F\fR
241
Forward window.  A count specifies repetition.
242
Two lines of continuity are kept if possible (2.1, 6.1, 7.2).
243
.TP
244
\fB^G\fR
245
Equivalent to \fB:f\fR\s-1CR\s0, printing the current file, whether
246
it has been modified, the current line number and the number of lines
247
in the file, and the percentage of the way through the file.
248
.TP
249
\fB^H (\fR\s-1BS\s0\fB)\fR
250
Same as
251
.BR "left arrow" .
252
(See
253
.BR h ).
254
During an insert, eliminates the last input character, backing over it
255
but not erasing it; it remains so the user can see what he typed if he
256
wishes to type something only slightly different (3.1, 7.5).
257
.TP
258
\fB^I\ (\fR\s-1TAB\s0\fB)\fR
259
Not a command character.
260
When inserted it prints as some
261
number of spaces.
262
When the cursor is at a tab character it rests at the last of the spaces
263
which represent the tab.
264
The spacing of tabstops is controlled by the \fItabstop\fR option (4.1, 6.6).
265
.TP
266
\fB^J\ (\fR\s-1LF\s0\fB)\fR
267
Same as
268
.B "down arrow"
269
(see
270
.BR j ).
271
.TP
272
\fB^K\fR
273
Unused.
274
.TP
275
\fB^L\fR
276
The \s-1ASCII\s0 formfeed character, this causes the screen to be cleared
277
and redrawn.  This is useful after a transmission error, if characters
278
typed by a program other than the editor scramble the screen,
279
or after output is stopped by an interrupt (5.4, 7.2f).
280
.TP
281
\fB^M\ (\fR\s-1CR\s0\fB)\fR
282
A carriage return advances to the next line, at the first non-white position
283
in the line.  Given a count, it advances that many lines (2.3).
284
During an insert, a \s-1CR\s0 causes the insert to continue onto
285
another line (3.1).
286
.TP
287
\fB^N\fR
288
Same as
289
.B "down arrow"
290
(see
291
.BR j ).
292
.TP
293
\fB^O\fR
294
Unused.
295
.TP
296
\fB^P\fR
297
Same as
298
.B "up arrow"
299
(see
300
.BR k ).
301
.TP
302
\fB^Q\fR
303
Not a command character.
304
In input mode,
305
.B ^Q
306
quotes the next character, the same as
307
.B ^V ,
308
except that some teletype drivers will eat the
309
.B ^Q
310
so that the editor never sees it.
311
.TP
312
\fB^R\fR
313
Redraws the current screen, eliminating logical lines not corresponding
314
to physical lines (lines with only a single @ character on them).
315
On hardcopy terminals in \fIopen\fR mode, retypes the current line
316
(5.4, 7.2, 7.8).
317
.TP
318
\fB^S\fR
319
Unused.  Some teletype drivers use
320
.B ^S
321
to suspend output until
322
.B ^Q is pressed.
323
.TP
324
\fB^T\fR
325
Not a command character.
326
During an insert, with \fIautoindent\fR set and at the beginning of the
327
line, inserts \fIshiftwidth\fR white space.
328
.TP
329
\fB^U\fR
330
Scrolls the screen up, inverting \fB^D\fR which scrolls down.  Counts work as
331
they do for \fB^D\fR, and the previous scroll amount is common to both.
332
On a dumb terminal, \fB^U\fR will often necessitate clearing and redrawing
333
the screen further back in the file (2.1, 7.2).
334
.TP
335
\fB^V\fR
336
Not a command character.
337
In input mode, quotes the next character so that it is possible
338
to insert non-printing and special characters into the file (4.2, 7.5).
339
.TP
340
\fB^W\fR
341
Not a command character.
342
During an insert, backs up as \fBb\fR would in command mode; the deleted
343
characters remain on the display (see \fB^H\fR) (7.5).
344
.TP
345
\fB^X\fR
346
Unused.
347
.TP
348
\fB^Y\fR
349
Exposes one more line above the current screen, leaving the cursor where
350
it is if possible.  (No mnemonic value for this key; however, it is next
351
to \fB^U\fR which scrolls up a bunch.)
352
.TP
353
\fB^Z\fR
354
If supported by the Unix system,
355
stops the editor, exiting to the top level shell.
356
Same as \fB:stop\fP\s-1CR\s0.
357
Otherwise, unused.
358
.TP
359
\fB^[\ (\fR\s-1ESC\s0\fB)\fR
360
Cancels a partially formed command, such as a \fBz\fR when no following
361
character has yet been given; terminates inputs on the last line (read
362
by commands such as \fB: /\fR and \fB?\fR); ends insertions of new text
363
into the buffer.
364
If an \s-1ESC\s0 is given when quiescent in command state, the editor
365
rings the bell or flashes the screen.  The user can thus hit \s-1ESC\s0 if
366
he doesn't know what is happening till the editor rings the bell.
367
If the user doesn't know whether he is in insert mode
368
he can type \s-1ESC\s0\fBa\fR,
369
and then material to be input; the material will be inserted correctly
370
whether or not he was in insert mode when he started (1.6, 3.1, 7.5).
371
.TP
372
\fB^\e\fR
373
Unused.
374
.TP
375
\fB^]\fR
376
Searches for the word which is after the cursor as a tag.  Equivalent
377
to typing \fB:ta\fR, this word, and then a \s-1CR\s0.
378
Mnemonically, this command is \*(lq right to\*(rq (7.3).
379
.TP
380
\fB^^\fR
381
Equivalent to \fB:e #\fR\s-1CR\s0, returning to the previous position
382
in the last edited file, or editing a file which the user specified if he
383
got a `No write since last change diagnostic' and does not want to have
384
to type the file name again (7.3).
385
(The user has to do a \fB:w\fR before \fB^^\fR
386
will work in this case.  If he does not wish to write the file he should
387
do \fB:e!\ #\fR\s-1CR\s0 instead.)
388
.TP
389
\fB^_\fR
390
Unused.
391
Reserved as the command character for the
392
Tektronix 4025 and 4027 terminal.
393
.TP
394
\fB\fR\s-1SPACE\s0\fB\fR
395
Same as
396
.B "right arrow"
397
(see
398
.BR l ).
399
.TP
400
\fB!\fR
401
An operator, which processes lines from the buffer with reformatting commands.
402
Follow \fB!\fR with the object to be processed, and then the command name
403
terminated by \s-1CR\s0.  Doubling \fB!\fR and preceding it by a count
404
causes count lines to be filtered; otherwise the count
405
is passed on to the object after the \fB!\fR.  Thus \fB2!}\fR\fIfmt\fR\s-1CR\s0
406
reformats the next two paragraphs by running them through the program
407
\fIfmt\fR.  If working on \s-1LISP\s0,
408
the command \fB!%\fR\fIgrind\fR\s-1CR\s0,
409
.\"*
410
.\".FS
411
.\"*Both
412
.\".I fmt
413
.\"and
414
.\".I grind
415
.\"are Berkeley programs and may not be present at all installations.
416
.\".FE
417
given at the beginning of a
418
function, will run the text of the function through the \s-1LISP\s0 grinder
419
(6.7, 7.3).
420
To read a file or the output of a command into the buffer \fB:r\fR (7.3)
421
can be used.
422
To simply execute a command, \fB:!\fR (7.3).
423
.tr "
424
.iP  15
425
Precedes a named buffer specification.  There are named buffers \fB1\-9\fR
426
used for saving deleted text and named buffers \fBa\-z\fR into which the
427
user can place text (4.3, 6.3)
428
.tr 
429
.TP
430
\fB#\fR
431
The macro character which, when followed by a number, will substitute
432
for a function key on terminals without function keys (6.9).
433
In input mode, 
434
if this is the erase character, it will delete the last character
435
typed in input mode, and must be preceded with a \fB\e\fR to insert
436
it, since it normally backs over the last input character.
437
.TP
438
\fB$\fR
439
Moves to the end of the current line.  If the \fBlist\fR option is set,
440
then the end of each line will be shown by printing a \fB$\fR after the
441
end of the displayed text in the line.  Given a count, advances to the
442
count'th following end of line; thus \fB2$\fR advances to the end of the
443
following line.
444
.TP
445
\fB%\fR
446
Moves to the parenthesis or brace \fB{ }\fR which balances the parenthesis
447
or brace at the current cursor position.
448
.TP
449
\fB&\fR
450
A synonym for \fB:&\fR\s-1CR\s0, by analogy with the
451
.I ex
452
.B &
453
command.
454
.TP
455
\fB\(aa\fR
456
When followed by a \fB\(aa\fR returns to the previous context at the
457
beginning of a line.  The previous context is set whenever the current
458
line is moved in a non-relative way.
459
When followed by a letter \fBa\fR\-\fBz\fR, returns to the line which
460
was marked with this letter with a \fBm\fR command, at the first non-white
461
character in the line. (2.2, 5.3).
462
When used with an operator such as \fBd\fR, the operation takes place
463
over complete lines; if \fB\(ga\fR is used, the operation takes place
464
from the exact marked place to the current cursor position within the
465
line.
466
.TP
467
\fB(\fR
468
Retreats to the beginning of a
469
sentence, or to the beginning of a \s-1LISP\s0 s-expression
470
if the \fIlisp\fR option is set.
471
A sentence ends at a \fB. !\fR or \fB?\fR which is followed by either
472
the end of a line or by two spaces.  Any number of closing \fB) ] "\fR
473
and \fB\(aa\fR characters may appear after the \fB. !\fR or \fB?\fR,
474
and before the spaces or end of line.  Sentences also begin
475
at paragraph and section boundaries
476
(see \fB{\fR and \fB[[\fR below).
477
A count advances that many sentences (4.2, 6.8).
478
.TP
479
\fB)\fR
480
Advances to the beginning of a sentence.
481
A count repeats the effect.
482
See \fB(\fR above for the definition of a sentence (4.2, 6.8).
483
.TP
484
\fB*\fR
485
Unused.
486
.TP
487
\fB+\fR
488
Same as \s-1CR\s0 when used as a command.
489
.TP
490
\fB,\fR
491
Reverse of the last \fBf F t\fR or \fBT\fR command, looking the other way
492
in the current line.  Especially useful after hitting too many \fB;\fR
493
characters.  A count repeats the search.
494
.TP
495
\fB\-\fR
496
Retreats to the previous line at the first non-white character.
497
This is the inverse of \fB+\fR and \s-1RETURN\s0.
498
If the line moved to is not on the screen, the screen is scrolled, or
499
cleared and redrawn if this is not possible.
500
If a large amount of scrolling would be required the screen is also cleared
501
and redrawn, with the current line at the center (2.3).
502
.TP
503
\fB\&.\fR
504
Repeats the last command which changed the buffer.  Especially useful
505
when deleting words or lines; the user can delete some words/lines and then
506
hit \fB.\fR to delete more and more words/lines.
507
Given a count, it passes it on to the command being repeated.  Thus after
508
a \fB2dw\fR, \fB3.\fR deletes three words (3.3, 6.3, 7.2, 7.4).
509
.TP
510
\fB/\fR
511
Reads a string from the last line on the screen, and scans forward for
512
the next occurrence of this string.  The normal input editing sequences may
513
be used during the input on the bottom line; an returns to command state
514
without ever searching.
515
The search begins when the user hits \s-1CR\s0 to terminate the pattern;
516
the cursor moves to the beginning of the last line to indicate that the search
517
is in progress; the search may then
518
be terminated with a \s-1DEL\s0 or \s-1RUB\s0, or by backspacing when
519
at the beginning of the bottom line, returning the cursor to
520
its initial position.
521
Searches normally wrap end-around to find a string
522
anywhere in the buffer.
523
.IP
524
When used with an operator the enclosed region is normally affected.
525
By mentioning an
526
offset from the line matched by the pattern the user can force whole lines
527
to be affected.  To do this a pattern with a closing
528
a closing \fB/\fR and then an offset \fB+\fR\fIn\fR or \fB\-\fR\fIn\fR
529
must be given.
530
.IP
531
To include the character \fB/\fR in the search string, it must be escaped
532
with a preceding \fB\e\fR.
533
A \fB^\fR at the beginning of the pattern forces the match to occur
534
at the beginning of a line only; this speeds the search.  A \fB$\fR at
535
the end of the pattern forces the match to occur at the end of a line
536
only.
537
More extended pattern matching is available, see section 7.4;
538
unless \fBnomagic\fR ist set in the \fI\&.exrc\fR file the user will have
539
to preceed the characters \fB. [ *\fR and \fB~\fR in the search pattern
540
with a \fB\e\fR to get them to work as one would naively expect (1.6, 2.2,
541
6.1, 7.2, 7.4).
542
.TP
543
\fB0\fR
544
Moves to the first character on the current line.
545
Also used, in forming numbers, after an initial \fB1\fR\-\fB9\fR.
546
.TP
547
\fB1\-9\fR
548
Used to form numeric arguments to commands (2.3, 7.2).
549
.TP
550
\fB:\fR
551
A prefix to a set of commands for file and option manipulation and escapes
552
to the system.  Input is given on the bottom line and terminated with
553
an \s-1CR\s0, and the command then executed.  The user can return to where
554
he was by hitting \s-1DEL\s0 or \s-1RUB\s0 if he hit \fB:\fR accidentally
555
(see 
556
.BR ex (1)
557
and primarily 6.2 and 7.3).
558
.TP
559
\fB;\fR
560
Repeats the last single character find which used \fBf F t\fR or \fBT\fR.
561
A count iterates the basic scan (4.1).
562
.TP
563
\fB<\fR
564
An operator which shifts lines left one \fIshiftwidth\fR, normally 8
565
spaces.  Like all operators, affects lines when repeated, as in
566
\fB<<\fR.  Counts are passed through to the basic object, thus \fB3<<\fR
567
shifts three lines (6.6, 7.2).
568
.TP
569
\fB=\fR
570
Reindents line for \s-1LISP\s0, as though they were typed in with \fIlisp\fR
571
and \fIautoindent\fR set (6.8).
572
.TP
573
\fB>\fR
574
An operator which shifts lines right one \fIshiftwidth\fR, normally 8
575
spaces.  Affects lines when repeated as in \fB>>\fR.  Counts repeat the
576
basic object (6.6, 7.2).
577
.TP
578
\fB?\fR
579
Scans backwards, the opposite of \fB/\fR.  See the \fB/\fR description
580
above for details on scanning (2.2, 6.1, 7.4).
581
.TP
582
\fB@\fR
583
A macro character (6.9).  If this is the kill character, it must be escaped
584
with a \e
585
to type it in during input mode, as it normally backs over the input
586
given on the current line (3.1, 3.4, 7.5).
587
.TP
588
\fBA\fR
589
Appends at the end of line, a synonym for \fB$a\fR (7.2).
590
.TP
591
\fBB\fR
592
Backs up a word, where words are composed of non-blank sequences, placing
593
the cursor at the beginning of the word.  A count repeats the effect
594
(2.4).
595
.TP
596
\fBC\fR
597
Changes the rest of the text on the current line; a synonym for \fBc$\fR.
598
.TP
599
\fBD\fR
600
Deletes the rest of the text on the current line; a synonym for \fBd$\fR.
601
.TP
602
\fBE\fR
603
Moves forward to the end of a word, defined as blanks and non-blanks,
604
like \fBB\fR and \fBW\fR.  A count repeats the effect.
605
.TP
606
\fBF\fR
607
Finds a single following character, backwards in the current line.
608
A count repeats this search that many times (4.1).
609
.TP
610
\fBG\fR
611
Goes to the line number given as preceding argument, or the end of the
612
file if no preceding count is given.  The screen is redrawn with the
613
new current line in the center if necessary (7.2).
614
.TP
615
\fBH\fR
616
.BR "Home arrow" .
617
Homes the cursor to the top line on the screen.  If a count is given,
618
then the cursor is moved to the count'th line on the screen.
619
In any case the cursor is moved to the first non-white character on the
620
line.  If used as the target of an operator, full lines are affected
621
(2.3, 3.2).
622
.TP
623
\fBI\fR
624
Inserts at the beginning of a line; a synonym for \fB^i\fR.
625
.TP
626
\fBJ\fR
627
Joins together lines, supplying appropriate white space: one space between
628
words, two spaces after a \fB.\fR, and no spaces at all if the first
629
character of the joined on line is \fB)\fR.  A count causes that many
630
lines to be joined rather than the default two (6.5, 7.1f).
631
.TP
632
\fBK\fR
633
Unused.
634
.TP
635
\fBL\fR
636
Moves the cursor to the first non-white character of the last line on
637
the screen.  With a count, to the first non-white of the count'th line
638
from the bottom.  Operators affect whole lines when used with \fBL\fR
639
(2.3).
640
.TP
641
\fBM\fR
642
Moves the cursor to the middle line on the screen, at the first non-white
643
position on the line (2.3).
644
.TP
645
\fBN\fR
646
Scans for the next match of the last pattern given to
647
\fB/\fR or \fB?\fR, but in the reverse direction; this is the reverse
648
of \fBn\fR.
649
.TP
650
\fBO\fR
651
Opens a new line above the current line and inputs text there up to an
652
\s-1ESC\s0.  A count can be used on dumb terminals to specify a number
653
of lines to be opened; this is generally obsolete, as the \fIslowopen\fR
654
option works better (3.1).
655
.TP
656
\fBP\fR
657
Puts the last deleted text back before/above the cursor.  The text goes
658
back as whole lines above the cursor if it was deleted as whole lines.
659
Otherwise the text is inserted between the characters before and at the
660
cursor.  May be preceded by a named buffer specification \fB"\fR\fIx\fR
661
to retrieve the contents of the buffer; buffers \fB1\fR\-\fB9\fR contain
662
deleted material, buffers \fBa\fR\-\fBz\fR are available for general
663
use (6.3).
664
.TP
665
\fBQ\fR
666
Quits from \fIvi\fR to \fIex\fR command mode.  In this mode, whole lines
667
form commands, ending with a \s-1RETURN\s0.  One can give all the \fB:\fR
668
commands; the editor supplies the \fB:\fR as a prompt (7.7).
669
.TP
670
\fBR\fR
671
Replaces characters on the screen with characters typed (overlay fashion).
672
Terminates with an \s-1ESC\s0.
673
.TP
674
\fBS\fR
675
Changes whole lines, a synonym for \fBcc\fR.  A count substitutes for
676
that many lines.  The lines are saved in the numeric buffers, and erased
677
on the screen before the substitution begins.
678
.TP
679
\fBT\fR
680
Takes a single following character, locates the character before the
681
cursor in the current line, and places the cursor just after that character.
682
A count repeats the effect.  Most useful with operators such as \fBd\fR
683
(4.1).
684
.TP
685
\fBU\fR
686
Restores the current line to its state before the user started changing it
687
(3.5).
688
.TP
689
\fBV\fR
690
Unused.
691
.TP
692
\fBW\fR
693
Moves forward to the beginning of a word in the current line,
694
where words are defined as sequences of blank/non-blank characters.
695
A count repeats the effect (2.4).
696
.TP
697
\fBX\fR
698
Deletes the character before the cursor.  A count repeats the effect,
699
but only characters on the current line are deleted.
700
.TP
701
\fBY\fR
702
Yanks a copy of the current line into the unnamed buffer, to be put back
703
by a later \fBp\fR or \fBP\fR; a very useful synonym for \fByy\fR. 
704
A count yanks that many lines.  May be preceded by a buffer name to put
705
lines in that buffer (7.4).
706
.TP
707
\fBZZ\fR
708
Exits the editor.
709
(Same as \fB:x\fP\s-1CR\s0.)
710
If any changes have been made, the buffer is written out to the current file.
711
Then the editor quits.
712
.TP
713
\fB[[\fR
714
Backs up to the previous section boundary.  A section begins at each
715
macro in the \fIsections\fR option,
716
normally a `.NH' or `.SH' and also at lines which which start
717
with a formfeed \fB^L\fR.  Lines beginning with \fB{\fR also stop \fB[[\fR;
718
this makes it useful for looking backwards, a function at a time, in C
719
programs.  If the option \fIlisp\fR is set, stops at each \fB(\fR at the
720
beginning of a line, and is thus useful for moving backwards at the top
721
level \s-1LISP\s0 objects. (4.2, 6.1, 6.6, 7.2).
722
.TP
723
\fB\e\fR
724
Unused.
725
.TP
726
\fB]]\fR
727
Forward to a section boundary, see \fB[[\fR for a definition (4.2, 6.1,
728
6.6, 7.2).
729
.TP
730
\fB^\fR
731
Moves to the first non-white position on the current line (4.4).
732
.TP
733
\fB_\fR
734
Unused.
735
.TP
736
\fB\(ga\fR
737
When followed by a \fB\(ga\fR returns to the previous context.
738
The previous context is set whenever the current
739
line is moved in a non-relative way.
740
When followed by a letter \fBa\fR\-\fBz\fR, returns to the position which
741
was marked with this letter with a \fBm\fR command.
742
When used with an operator such as \fBd\fR, the operation takes place
743
from the exact marked place to the current position within the line;
744
if using \fB\(aa\fR, the operation takes place over complete lines
745
(2.2, 5.3).
746
.TP
747
\fBa\fR
748
Appends arbitrary text after the current cursor position; the insert
749
can continue onto multiple lines by using \s-1RETURN\s0 within the insert.
750
A count causes the inserted text to be replicated, but only if the inserted
751
text is all on one line.
752
The insertion terminates with an \s-1ESC\s0 (3.1, 7.2).
753
.TP
754
\fBb\fR
755
Backs up to the beginning of a word in the current line.  A word is a
756
sequence of alphanumerics, or a sequence of special characters.
757
A count repeats the effect (2.4).
758
.TP
759
\fBc\fR
760
An operator which changes the following object, replacing it with the
761
following input text up to an \s-1ESC\s0.  If more than part of a single
762
line is affected, the text which is changed away is saved in the numeric named
763
buffers.  If only part of the current line is affected, then the last
764
character to be changed away is marked with a \fB$\fR.
765
A count causes that many objects to be affected, thus both
766
\fB3c)\fR and \fBc3)\fR change the following three sentences (7.4).
767
.TP
768
\fBd\fR
769
An operator which deletes the following object.  If more than part of
770
a line is affected, the text is saved in the numeric buffers.
771
A count causes that many objects to be affected; thus \fB3dw\fR is the
772
same as \fBd3w\fR (3.3, 3.4, 4.1, 7.4).
773
.TP
774
\fBe\fR
775
Advances to the end of the next word, defined as for \fBb\fR and \fBw\fR.
776
A count repeats the effect (2.4, 3.1).
777
.TP
778
\fBf\fR
779
Finds the first instance of the next character following the cursor on
780
the current line.  A count repeats the find (4.1).
781
.TP
782
\fBg\fR
783
Unused.
784
.sp
785
Arrow keys
786
.BR h ,
787
.BR j ,
788
.BR k ,
789
.BR l ,
790
and
791
.BR H .
792
.TP
793
\fBh\fR
794
.B "Left arrow" .
795
Moves the cursor one character to the left.
796
Like the other arrow keys, either
797
.BR h ,
798
the
799
.B "left arrow"
800
key, or one of the synonyms (\fB^H\fP) has the same effect.
801
A count repeats the effect (3.1, 7.5).
802
.TP
803
\fBi\fR
804
Inserts text before the cursor, otherwise like \fBa\fR (7.2).
805
.TP
806
\fBj\fR
807
.B "Down arrow" .
808
Moves the cursor one line down in the same column.
809
If the position does not exist,
810
.I vi
811
comes as close as possible to the same column.
812
Synonyms include
813
.B ^J
814
(linefeed) and
815
.B ^N .
816
.TP
817
\fBk\fR
818
.B "Up arrow" .
819
Moves the cursor one line up.
820
.B ^P
821
is a synonym.
822
.TP
823
\fBl\fR
824
.B "Right arrow" .
825
Moves the cursor one character to the right.
826
\s-1SPACE\s0 is a synonym.
827
.TP
828
\fBm\fR
829
Marks the current position of the cursor in the mark register which is
830
specified by the next character \fBa\fR\-\fBz\fR.  The user can return
831
to this position or use it with an operator
832
using \fB\(ga\fR or \fB\(aa\fR (5.3).
833
.TP
834
\fBn\fR
835
Repeats the last \fB/\fR or \fB?\fR scanning commands (2.2).
836
.TP
837
\fBo\fR
838
Opens new lines below the current line; otherwise like \fBO\fR (3.1).
839
.TP
840
\fBp\fR
841
Puts text after/below the cursor; otherwise like \fBP\fR (6.3).
842
.TP
843
\fBq\fR
844
Unused.
845
.TP
846
\fBr\fR
847
Replaces the single character at the cursor with a single character typed.
848
The new character may be a \s-1RETURN\s0; this is the easiest
849
way to split lines.  A count replaces each of the following count characters
850
with the single character given; see \fBR\fR above which is the more
851
usually useful iteration of \fBr\fR (3.2).
852
.TP
853
\fBs\fR
854
Changes the single character under the cursor to the text which follows
855
up to an \s-1ESC\s0; given a count, that many characters from the current
856
line are changed.  The last character to be changed is marked with \fB$\fR
857
as in \fBc\fR (3.2).
858
.TP
859
\fBt\fR
860
Advances the cursor upto the character before the next character typed.
861
Most useful with operators such as \fBd\fR and \fBc\fR to delete the
862
characters up to a following character.  One can use \fB.\fR to delete
863
more if this doesn't delete enough the first time (4.1).
864
.TP
865
\fBu\fR
866
Undoes the last change made to the current buffer.  If repeated, will
867
alternate between these two states, thus is its own inverse. When used
868
after an insert which inserted text on more than one line, the lines are
869
saved in the numeric named buffers (3.5).
870
.TP
871
\fBv\fR
872
Unused.
873
.TP
874
\fBw\fR
875
Advances to the beginning of the next word, as defined by \fBb\fR (2.4).
876
.TP
877
\fBx\fR
878
Deletes the single character under the cursor.  With a count deletes
879
deletes that many characters forward from the cursor position, but only
880
on the current line (6.5).
881
.TP
882
\fBy\fR
883
An operator, yanks the following object into the unnamed temporary buffer.
884
If preceded by a named buffer specification, \fB"\fR\fIx\fR, the text
885
is placed in that buffer also.  Text can be recovered by a later \fBp\fR
886
or \fBP\fR (7.4).
887
.TP
888
\fBz\fR
889
Redraws the screen with the current line placed as specified by the following
890
character: \s-1RETURN\s0 specifies the top of the screen, \fB.\fR the
891
center of the screen, and \fB\-\fR at the bottom of the screen.
892
A count may be given after the \fBz\fR and before the following character
893
to specify the new screen size for the redraw.
894
A count before the \fBz\fR gives the number of the line to place in the
895
center of the screen instead of the default current line. (5.4)
896
.TP
897
\fB{\fR
898
Retreats to the beginning of the beginning of the preceding paragraph.
899
A paragraph begins at each macro in the \fIparagraphs\fR option, normally
900
`.IP', `.LP', `.PP', `.QP' and `.bp'.
901
A paragraph also begins after a completely
902
empty line, and at each section boundary (see \fB[[\fR above) (4.2, 6.8,
903
7.6).
904
.TP
905
\fB|\fR
906
Places the cursor on the character in the column specified
907
by the count (7.1, 7.2).
908
.TP
909
\fB}\fR
910
Advances to the beginning of the next paragraph.  See \fB{\fR for the
911
definition of paragraph (4.2, 6.8, 7.6).
912
.TP
913
\fB~\fR
914
Switches the case of the given count of characters
915
starting from the current cursor position to the end of the current line.
916
Non-alphabetic characters remain unchanged.
917
.TP
918
\fB^?\ (\s-1\fRDEL\fB\s0)\fR
919
Interrupts the editor, returning it to command accepting state (1.6,
920
7.5).
921
.SH "ENVIRONMENT VARIABLES"
922
.PP
923
The following environment variables affect the behaviour of vi:
924
.TP
925
.B COLUMNS
926
Overrides the system-supplied number of terminal columns.
927
.TP
928
.B EXINIT
929
Contains commands to execute at editor startup.
930
If this variable is present, the
931
.I .exrc
932
file in the user's home directory is ignored.
933
.TP
934
.B HOME
935
Used to locate the editor startup file.
936
.TP
937
.BR LANG ", " LC_ALL
938
See
939
.IR locale (7).
940
.TP
941
.B LC_CTYPE
942
Determines the mapping of bytes to characters,
943
types of characters,
944
case conversion
945
and composition of character classes in regular expressions.
946
.TP
947
.B LC_MESSAGES
948
Sets the language used for diagnostic and informal messages.
949
.TP
950
.B LINES
951
Overrides the system-supplied number of terminal lines.
952
.TP
953
.B NLSPATH
954
See
955
.IR catopen (3).
956
.TP
957
.B SHELL
958
The program file used to execute external commands.
959
.TP
960
.B TERM
961
Determines the terminal type.
962
.SH FILES
963
.TP
964
.B /usr/libexec/expreserve
965
preserve command
966
.TP
967
.B /usr/libexec/exrecover
968
recover command
969
.TP
970
.B /etc/termcap
971
describes capabilities of terminals
972
.TP
973
.B $HOME/.exrc
974
editor startup file
975
.TP
976
.B /var/tmp/Ex\fInnnnnnnnnn\fP
977
editor temporary
978
.TP
979
.B /var/tmp/Rx\fInnnnnnnnnn\fP
980
named buffer temporary
981
.TP
982
.B /var/preserve
983
preservation directory
984
.SH SEE ALSO
985
ex(1),
986
edit(1),
987
\*(lqVi Quick Reference\*(rq card,
988
\*(lqAn Introduction to Display Editing with Vi\*(rq.
989
.SH AUTHOR
990
William Joy.
991
.PP
992
Mark Horton added macros to
993
.I visual
994
mode and was maintaining version 3.
995
.PP
996
This version incorporates changes by Gunnar Ritter.
997
.SH NOTES
998
Software tabs using \fB^T\fP work only immediately after the
999
.I autoindent.
1000
.PP
1001
Left and right shifts on intelligent terminals don't make use of
1002
insert and delete character operations in the terminal.
1003
.PP
1004
The
1005
.I wrapmargin
1006
option can be fooled since it looks at output columns when blanks are typed.
1007
If a long word passes through the margin and onto the next line without a 
1008
break, then the line won't be broken.
1009
.PP
1010
Insert/delete within a line can be slow if tabs are present on intelligent
1011
terminals, since the terminals need help in doing this correctly.
1012
.\".PP
1013
.\"Saving text on deletes in the named buffers is somewhat inefficient.
1014
.PP
1015
The
1016
.I source
1017
command does not work when executed as \fB:source\fP;
1018
there is no way to use the \fB:append\fP, \fB:change\fP,
1019
and \fB:insert\fP commands, since it is not possible to give
1020
more than one line of input to a \fB:\fP escape.  To use these
1021
on a \fB:global\fP one must \fBQ\fP to \fIex\fP command mode,
1022
execute them, and then reenter the screen editor with
1023
.I vi
1024
or
1025
.I open.