'\" te
.\"  Copyright 1989 AT&T  Copyright (c) 2007, Sun Microsystems, Inc.  All Rights Reserved  Portions Copyright (c) 1992, X/Open Company Limited  All Rights Reserved
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
.\"  This notice shall appear on any product containing this material.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH VI 1HAS "May 16, 2007"
.SH NAME
vi, view, vedit \- screen-oriented (visual) display editor based on ex
.SH SYNOPSIS
.LP
.nf
\fB/usr/bin/vi\fR [\fB-|\fR \fB-s\fR] [\fB-l\fR] [\fB-L\fR] [\fB-R\fR] [\fB-r\fR [\fIfilename\fR]] [\fB-S\fR]
     [\fB-t\fR \fItag\fR] [\fB-v\fR] [\fB-V\fR] [\fB-x\fR] [\fB-w\fR\fIn\fR] [\fB-C\fR]
     [\fB+\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
.fi

.LP
.nf
\fB/usr/bin/view\fR [\fB-|\fR \fB-s\fR] [\fB-l\fR] [\fB-L\fR] [\fB-R\fR] [\fB-r\fR [\fIfilename\fR]] [\fB-S\fR]
     [\fB-t\fR \fItag\fR] [\fB-v\fR] [\fB-V\fR] [\fB-x\fR] [\fB-w\fR\fIn\fR] [\fB-C\fR]
     [\fB+\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
.fi

.LP
.nf
\fB/usr/bin/vedit\fR [\fB-|\fR \fB-s\fR] [\fB-l\fR] [\fB-L\fR] [\fB-R\fR] [\fB-r\fR [\fIfilename\fR]] [\fB-S\fR]
     [\fB-t\fR \fItag\fR] [\fB-v\fR] [\fB-V\fR] [\fB-x\fR] [\fB-w\fR\fIn\fR] [\fB-C\fR]
     [\fB+\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
.fi

.LP
.nf
\fB/usr/xpg4/bin/vi\fR [\fB-|\fR \fB-s\fR] [\fB-l\fR] [\fB-L\fR] [\fB-R\fR] [\fB-r\fR [\fIfilename\fR]]
     [\fB-S\fR] [\fB-t\fR \fItag\fR] [\fB-v\fR] [\fB-V\fR] [\fB-x\fR] [\fB-w\fR\fIn\fR] [\fB-C\fR]
     [\fB+\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
.fi

.LP
.nf
\fB/usr/xpg4/bin/view\fR [\fB-|\fR \fB-s\fR] [\fB-l\fR] [\fB-L\fR] [\fB-R\fR] [\fB-r\fR [\fIfilename\fR]]
     [\fB-S\fR] [\fB-t\fR \fItag\fR] [\fB-v\fR] [\fB-V\fR] [\fB-x\fR] [\fB-w\fR\fIn\fR] [\fB-C\fR]
     [\fB+\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
.fi

.LP
.nf
\fB/usr/xpg4/bin/vedit\fR [\fB-|\fR \fB-s\fR] [\fB-l\fR] [\fB-L\fR] [\fB-R\fR] [\fB-r\fR [\fIfilename\fR]]
     [\fB-S\fR] [\fB-t\fR \fItag\fR] [\fB-v\fR] [\fB-V\fR] [\fB-x\fR] [\fB-w\fR\fIn\fR] [\fB-C\fR]
     [\fB+\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
.fi

.LP
.nf
\fB/usr/xpg6/bin/vi\fR [\fB-|\fR \fB-s\fR] [\fB-l\fR] [\fB-L\fR] [\fB-R\fR] [\fB-r\fR [\fIfilename\fR]]
     [\fB-S\fR] [\fB-t\fR \fItag\fR] [\fB-v\fR] [\fB-V\fR] [\fB-x\fR] [\fB-w\fR\fIn\fR] [\fB-C\fR]
     [\fB+\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
.fi

.LP
.nf
\fB/usr/xpg6/bin/view\fR [\fB-|\fR \fB-s\fR] [\fB-l\fR] [\fB-L\fR] [\fB-R\fR] [\fB-r\fR [\fIfilename\fR]]
     [\fB-S\fR] [\fB-t\fR \fItag\fR] [\fB-v\fR] [\fB-V\fR] [\fB-x\fR] [\fB-w\fR\fIn\fR] [\fB-C\fR]
     [\fB+\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
.fi

.LP
.nf
\fB/usr/xpg6/bin/vedit\fR [\fB-|\fR \fB-s\fR] [\fB-l\fR] [\fB-L\fR] [\fB-R\fR] [\fB-r\fR [\fIfilename\fR]]
     [\fB-S\fR] [\fB-t\fR \fItag\fR] [\fB-v\fR] [\fB-V\fR] [\fB-x\fR] [\fB-w\fR\fIn\fR] [\fB-C\fR]
     [\fB+\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
.fi

.SH DESCRIPTION
.sp
.LP
The \fBvi\fR (visual) utility is a display-oriented text editor based on an
underlying line editor \fBex\fR. It is possible to use the command mode of
\fBex\fR from within \fBvi\fR and to use the command mode of \fBvi\fR from
within \fBex\fR. The visual commands are described on this manual page; how to
set options (like automatically numbering lines and automatically starting a
new output line when you type carriage return) and all \fBex\fR line editor
commands are described on the \fBex\fR(1) manual page.
.sp
.LP
When using \fBvi\fR, changes you make to the file are reflected in what you see
on your terminal screen. The position of the cursor on the screen indicates the
position within the file.
.sp
.LP
The \fBview\fR invocation is the same as \fBvi\fR except that the
\fBreadonly\fR flag is set.
.sp
.LP
The \fBvedit\fR invocation is intended for beginners. It is the same as
\fBvi\fR except that the \fBreport\fR flag is set to \fB1\fR, the
\fBshowmode\fR and \fBnovice\fR flags are set, and \fBmagic\fR is turned off.
These defaults make it easier to learn how to use \fBvi\fR.
.SH OPTIONS
.sp
.LP
The following options are supporrted:
.SS "Invocation Options"
.sp
.LP
The following invocation options are interpreted by \fBvi\fR (previously
documented options are discussed under NOTES):
.sp
.ne 2
.na
\fB\fB\(mi\fR | \fB-s\fR\fR
.ad
.RS 25n
Suppresses all interactive user feedback. This is useful when processing editor
scripts.
.RE

.sp
.ne 2
.na
\fB\fB-C\fR\fR
.ad
.RS 25n
Encryption option. Same as the \fB-x\fR option, except that \fBvi\fR simulates
the \fBC\fR command of \fBex\fR. The \fBC\fR command is like the \fBX\fR
command of \fBex\fR, except that all text read in is assumed to have been
encrypted.
.RE

.sp
.ne 2
.na
\fB\fB-l\fR\fR
.ad
.RS 25n
Sets up for editing \fBLISP\fR programs.
.RE

.sp
.ne 2
.na
\fB\fB-L\fR\fR
.ad
.RS 25n
Lists the name of all files saved as the result of an editor or system crash.
.RE

.sp
.ne 2
.na
\fB\fB-r\fR \fIfilename\fR\fR
.ad
.RS 25n
Edits \fIfilename\fR after an editor or system crash. (Recovers the version of
\fIfilename\fR that was in the buffer when the crash occurred.)
.RE

.sp
.ne 2
.na
\fB\fB-R\fR\fR
.ad
.RS 25n
\fBReadonly\fR mode. The \fBreadonly\fR flag is set, preventing accidental
overwriting of the file.
.RE

.sp
.ne 2
.na
\fB\fB-S\fR\fR
.ad
.RS 25n
This option is used in conjunction with the \fB-t\fR \fItag\fR option to tell
\fBvi\fR that the tags file can not be sorted and that, if the binary search
(which relies on a sorted tags file) for \fItag\fR fails to find it, the much
slower linear search should also be done. Since the linear search is slow,
users of large tags files should ensure that the tags files are sorted rather
than use this flag. Creation of tags files normally produces sorted tags files.
See \fBctags\fR(1) for more information on tags files.
.RE

.sp
.ne 2
.na
\fB\fB-t\fR \fItag\fR\fR
.ad
.RS 25n
Edits the file containing \fItag\fR and position the editor at its definition.
It is an error to specify more than one \fB-t\fR option.
.RE

.sp
.ne 2
.na
\fB\fB-v\fR\fR
.ad
.RS 25n
Starts up in display editing state, using \fBvi\fR. You can achieve the same
effect by typing the \fBvi\fR command itself.
.RE

.sp
.ne 2
.na
\fB\fB-V\fR\fR
.ad
.RS 25n
Verbose. When \fBex\fR commands are read by means of standard input, the input
is echoed to standard error. This can be useful when processing \fBex\fR
commands within shell scripts.
.RE

.sp
.ne 2
.na
\fB\fB-w\fR\fIn\fR\fR
.ad
.RS 25n
Sets the default window size to \fIn\fR. This is useful when using the editor
over a slow speed line.
.RE

.sp
.ne 2
.na
\fB\fB-x\fR\fR
.ad
.RS 25n
Encryption option. When used, \fBvi\fR simulates the \fBX\fR command of
\fBex\fR and prompts the user for a key. This key is used to encrypt and
decrypt text using the algorithm of the \fBcrypt\fR command. The \fBX\fR
command makes an educated guess to determine whether text read in is encrypted
or not. The temporary buffer file is encrypted also, using a transformed
version of the key typed in for the \fB-x\fR option. If an empty encryption
key is entered (that is, if the return key is pressed right after the prompt),
the file is not encrypted. This is a good way to decrypt a file erroneously
encrypted with a mistyped encryption key, such as a backspace or undo key.
.RE

.sp
.ne 2
.na
\fB\fB-\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR\fR
.ad
.RS 25n
Begins editing by executing the specified editor \fIcommand\fR (usually a
search or positioning command).
.RE

.SS "/usr/xpg4/bin/vi and /usr/xpg6/bin/vi"
.sp
.LP
If both the \fB-t\fR \fItag\fR and the \fB-c\fR \fIcommand\fR options are
given, the \fB-t\fR \fItag\fR optionis processed first. That is, the file
containing \fItag\fR is selected by \fB-t\fR and then the command is executed.
.SH OPERANDS
.sp
.LP
The following operands are supported:
.sp
.ne 2
.na
\fB\fIfilename\fR\fR
.ad
.RS 12n
A file to be edited.
.RE

.SH COMMAND SUMMARY
.sp
.LP
The \fBvi\fR command modes are summarized in this section.
.SS "vi Modes"
.sp
.ne 2
.na
\fBCommand\fR
.ad
.RS 13n
Normal and initial mode. Other modes return to command mode upon completion.
\fIESC\fR (escape) is used to cancel a partial command.
.RE

.sp
.ne 2
.na
\fBInput\fR
.ad
.RS 13n
Entered by setting any of the following options:
.sp
.in +2
.nf
a A i I o O c C s S R
.fi
.in -2
.sp

Arbitrary text can then be entered. Input mode is normally terminated with the
\fIESC\fR character, or, abnormally, with an interrupt.
.RE

.sp
.ne 2
.na
\fBLast line\fR
.ad
.RS 13n
Reading input for \fB: / ?\fR or \fB!\fR. Terminate by typing a carriage
return. An interrupt cancels termination.
.RE

.SS "Sample Commands"
.sp
.LP
In the descriptions, \fICR\fR stands for carriage return and \fIESC\fR stands
for the escape key.
.sp
.ne 2
.na
\fB\(<-, \(->\fR
.ad
.br
.na
\fBdown-arrow\fR
.ad
.br
.na
\fBup-arrow\fR
.ad
.RS 14n
arrow keys move the cursor
.RE

.sp
.ne 2
.na
\fBh j k l\fR
.ad
.RS 14n
same as arrow keys
.RE

.sp
.ne 2
.na
\fBi\fItext\fR\fIESC\fR\fR
.ad
.RS 14n
insert \fItext\fR
.RE

.sp
.ne 2
.na
\fBcw\fInew\fR\fIESC\fR\fR
.ad
.RS 14n
change word to \fInew\fR
.RE

.sp
.ne 2
.na
\fBea\fIs\fR\fIESC\fR\fR
.ad
.RS 14n
pluralize word (end of word; append \fBs\fR; escape from input state)
.RE

.sp
.ne 2
.na
\fBx\fR
.ad
.RS 14n
delete a character
.RE

.sp
.ne 2
.na
\fBdw\fR
.ad
.RS 14n
delete a word
.RE

.sp
.ne 2
.na
\fBdd\fR
.ad
.RS 14n
delete a line
.RE

.sp
.ne 2
.na
\fB3dd\fR
.ad
.RS 14n
delete 3 lines
.RE

.sp
.ne 2
.na
\fBu\fR
.ad
.RS 14n
undo previous change
.RE

.sp
.ne 2
.na
\fBZZ\fR
.ad
.RS 14n
exit \fBvi\fR, saving changes
.RE

.sp
.ne 2
.na
\fB:q!\fICR\fR\fR
.ad
.RS 14n
quit, discarding changes
.RE

.sp
.ne 2
.na
\fB/\fItext\fR\fICR\fR\fR
.ad
.RS 14n
search for \fItext\fR
.RE

.sp
.ne 2
.na
\fB^U ^D\fR
.ad
.RS 14n
scroll up or down
.RE

.sp
.ne 2
.na
\fB:\fIcmd\fR\fICR\fR\fR
.ad
.RS 14n
any \fBex\fR or \fBed\fR command
.RE

.SS "Counts Before vi Commands"
.sp
.LP
Numbers can be typed as a prefix to some commands. They are interpreted in one
of these ways:
.sp
.ne 2
.na
\fBline/column number\fR
.ad
.RS 22n
z  G  |
.RE

.sp
.ne 2
.na
\fBscroll amount\fR
.ad
.RS 22n
^D  ^U
.RE

.sp
.ne 2
.na
\fBrepeat effect\fR
.ad
.RS 22n
most of the rest
.RE

.SS "Interrupting, Canceling"
.sp
.ne 2
.na
\fB\fIESC\fR\fR
.ad
.RS 7n
end insert or incomplete command
.RE

.sp
.ne 2
.na
\fB\fIDEL\fR\fR
.ad
.RS 7n
(delete or rubout) interrupts
.RE

.SS "File Manipulation"
.sp
.ne 2
.na
\fBZZ\fR
.ad
.RS 15n
if file modified, write and exit; otherwise, exit
.RE

.sp
.ne 2
.na
\fB:w\fICR\fR\fR
.ad
.RS 15n
write back changes
.RE

.sp
.ne 2
.na
\fB:w!\fICR\fR\fR
.ad
.RS 15n
forced write, if permission originally not valid
.RE

.sp
.ne 2
.na
\fB:q\fICR\fR\fR
.ad
.RS 15n
quit
.RE

.sp
.ne 2
.na
\fB:q!\fICR\fR\fR
.ad
.RS 15n
quit, discard changes
.RE

.sp
.ne 2
.na
\fB:e \fIname\fR\fICR\fR\fR
.ad
.RS 15n
edit file \fIname\fR
.RE

.sp
.ne 2
.na
\fB:e!\fICR\fR\fR
.ad
.RS 15n
reedit, discard changes
.RE

.sp
.ne 2
.na
\fB:e + \fIname\fR\fICR\fR\fR
.ad
.RS 15n
edit, starting at end
.RE

.sp
.ne 2
.na
\fB:e +\fIn\fR\fICR\fR\fR
.ad
.RS 15n
edit, starting at line \fIn\fR
.RE

.sp
.ne 2
.na
\fB:e #\fICR\fR\fR
.ad
.RS 15n
edit alternate file
.RE

.sp
.ne 2
.na
\fB:e! #\fICR\fR\fR
.ad
.RS 15n
edit alternate file, discard changes
.RE

.sp
.ne 2
.na
\fB:w \fIname\fR\fICR\fR\fR
.ad
.RS 15n
write file \fIname\fR
.RE

.sp
.ne 2
.na
\fB:w! \fIname\fR\fICR\fR\fR
.ad
.RS 15n
overwrite file \fIname\fR
.RE

.sp
.ne 2
.na
\fB:sh\fICR\fR\fR
.ad
.RS 15n
run shell, then return
.RE

.sp
.ne 2
.na
\fB:!\fIcmd\fR\fICR\fR\fR
.ad
.RS 15n
run \fIcmd\fR, then return
.RE

.sp
.ne 2
.na
\fB:n\fICR\fR\fR
.ad
.RS 15n
edit next file in arglist
.RE

.sp
.ne 2
.na
\fB:n \fIargs\fR\fICR\fR\fR
.ad
.RS 15n
specify new arglist
.RE

.sp
.ne 2
.na
\fB^G\fR
.ad
.RS 15n
show current file and line
.RE

.sp
.ne 2
.na
\fB:ta \fItag\fR\fICR\fR\fR
.ad
.RS 15n
position cursor to \fItag\fR
.RE

.sp
.LP
In general, any \fBex\fR or \fBed\fR command (such as \fIsubstitute\fR or
\fIglobal\fR) can be typed, preceded by a colon and followed by a carriage
return.
.SS "Positioning Within a File"
.sp
.ne 2
.na
\fBF\fR
.ad
.RS 14n
forward screen
.RE

.sp
.ne 2
.na
\fB^B\fR
.ad
.RS 14n
backward screen
.RE

.sp
.ne 2
.na
\fB^D\fR
.ad
.RS 14n
scroll down half screen
.RE

.sp
.ne 2
.na
\fB^U\fR
.ad
.RS 14n
scroll up half screen
.RE

.sp
.ne 2
.na
\fB\fIn\fRG\fR
.ad
.RS 14n
go to the beginning of the specified line (end default), where \fIn\fR is a
line number
.RE

.sp
.ne 2
.na
\fB/\fIpat\fR\fR
.ad
.RS 14n
next line matching \fIpat\fR
.RE

.sp
.ne 2
.na
\fB?\fIpat\fR\fR
.ad
.RS 14n
previous line matching \fIpat\fR
.RE

.sp
.ne 2
.na
\fBn\fR
.ad
.RS 14n
repeat last \fB/\fR or \fB?\fR command
.RE

.sp
.ne 2
.na
\fBN\fR
.ad
.RS 14n
reverse last \fB/\fR or \fB?\fR command
.RE

.sp
.ne 2
.na
\fB/\fIpat\fR/+\fIn\fR\fR
.ad
.RS 14n
\fIn\fRth line after \fIpat\fR
.RE

.sp
.ne 2
.na
\fB?\fIpat\fR?\(mi\fIn\fR\fR
.ad
.RS 14n
\fIn\fRth line before \fIpat\fR
.RE

.sp
.ne 2
.na
\fB]]\fR
.ad
.RS 14n
next section/function
.RE

.sp
.ne 2
.na
\fB[[\fR
.ad
.RS 14n
previous section/function
.RE

.sp
.ne 2
.na
\fB(\fR
.ad
.RS 14n
beginning of sentence
.RE

.sp
.ne 2
.na
\fB)\fR
.ad
.RS 14n
end of sentence
.RE

.sp
.ne 2
.na
\fB{\fR
.ad
.RS 14n
beginning of paragraph
.RE

.sp
.ne 2
.na
\fB}\fR
.ad
.RS 14n
end of paragraph
.RE

.sp
.ne 2
.na
\fB%\fR
.ad
.RS 14n
find matching \fB( )\fR or \fB{ }\fR
.RE

.SS "Adjusting the Screen"
.sp
.ne 2
.na
\fB^L\fR
.ad
.RS 16n
clear and redraw window
.RE

.sp
.ne 2
.na
\fB^R\fR
.ad
.RS 16n
clear and redraw window if \fB^L\fR is \(-> key
.RE

.sp
.ne 2
.na
\fBz\fICR\fR\fR
.ad
.RS 16n
redraw screen with current line at top of window
.RE

.sp
.ne 2
.na
\fBz\(mi\fICR\fR\fR
.ad
.RS 16n
redraw screen with current line at bottom of window
.RE

.sp
.ne 2
.na
\fBz.\fICR\fR\fR
.ad
.RS 16n
redraw screen with current line at center of window
.RE

.sp
.ne 2
.na
\fB/\fIpat\fR/z\(mi\fICR\fR\fR
.ad
.RS 16n
move \fIpat\fR line to bottom of window
.RE

.sp
.ne 2
.na
\fBz\fIn\fR.\fICR\fR\fR
.ad
.RS 16n
use \fIn\fR\(miline window
.RE

.sp
.ne 2
.na
\fB^E\fR
.ad
.RS 16n
scroll window down one line
.RE

.sp
.ne 2
.na
\fB^Y\fR
.ad
.RS 16n
scroll window up one line
.RE

.SS "Marking and Returning"
.sp
.ne 2
.na
\fB\(ga\(ga\fR
.ad
.RS 12n
move cursor to previous context
.RE

.sp
.ne 2
.na
\fBa\'a\'\fR
.ad
.RS 12n
move cursor to first non-white space in line
.RE

.sp
.ne 2
.na
\fBm\fIx\fR\fR
.ad
.RS 12n
mark current position with the \fBASCII\fR lower-case letter \fIx\fR
.RE

.sp
.ne 2
.na
\fB\(ga\fIx\fR\fR
.ad
.RS 12n
move cursor to mark \fIx\fR
.RE

.sp
.ne 2
.na
\fBa\'\fIx\fR\fR
.ad
.RS 12n
move cursor to first non-white space in line marked by \fIx\fR
.RE

.SS "Line Positioning"
.sp
.ne 2
.na
\fBH\fR
.ad
.RS 14n
top line on screen
.RE

.sp
.ne 2
.na
\fBL\fR
.ad
.RS 14n
last line on screen
.RE

.sp
.ne 2
.na
\fBM\fR
.ad
.RS 14n
middle line on screen
.RE

.sp
.ne 2
.na
\fB+\fR
.ad
.RS 14n
next line, at first non-white space character
.RE

.sp
.ne 2
.na
\fB\(mi\fR
.ad
.RS 14n
previous line, at first non-white space character
.RE

.sp
.ne 2
.na
\fB\fICR\fR\fR
.ad
.RS 14n
return, same as \fB+\fR
.RE

.sp
.ne 2
.na
\fB\fBdown-arrow\fR\fR
.ad
.br
.na
\fBor \fBj\fR\fR
.ad
.RS 14n
next line, same column
.RE

.sp
.ne 2
.na
\fB\fBup-arrow\fR\fR
.ad
.br
.na
\fBor \fBk\fR\fR
.ad
.RS 14n
previous line, same column
.RE

.SS "Character Positioning"
.sp
.ne 2
.na
\fB^\fR
.ad
.RS 13n
first non-white space character
.RE

.sp
.ne 2
.na
\fB0\fR
.ad
.RS 13n
beginning of line
.RE

.sp
.ne 2
.na
\fB$\fR
.ad
.RS 13n
end of line
.RE

.sp
.ne 2
.na
\fB\fBl\fR or \fB\(->\fR\fR
.ad
.RS 13n
forward
.RE

.sp
.ne 2
.na
\fB\fBh\fR or \fB\(<-\fR\fR
.ad
.RS 13n
backward
.RE

.sp
.ne 2
.na
\fB^H\fR
.ad
.RS 13n
same as \fB\(<-\fR (backspace)
.RE

.sp
.ne 2
.na
\fBspace\fR
.ad
.RS 13n
same as \fB\(->\fR (space bar)
.RE

.sp
.ne 2
.na
\fBf\fIx\fR\fR
.ad
.RS 13n
find next \fIx\fR
.RE

.sp
.ne 2
.na
\fBF\fIx\fR\fR
.ad
.RS 13n
find previous \fIx\fR
.RE

.sp
.ne 2
.na
\fBt\fIx\fR\fR
.ad
.RS 13n
move to character following the next \fIx\fR
.RE

.sp
.ne 2
.na
\fBT\fIx\fR\fR
.ad
.RS 13n
move to character following the previous \fIx\fR
.RE

.sp
.ne 2
.na
\fB;\fR
.ad
.RS 13n
repeat last \fBf\fR, \fBF\fR, \fBt\fR, or \fBT\fR
.RE

.sp
.ne 2
.na
\fB,\fR
.ad
.RS 13n
repeat inverse of last \fBf\fR, \fBF\fR, \fBt\fR, or \fBT\fR
.RE

.sp
.ne 2
.na
\fB\fIn\fR|\fR
.ad
.RS 13n
move to column \fIn\fR
.RE

.sp
.ne 2
.na
\fB%\fR
.ad
.RS 13n
find matching \fB( )\fR or \fB{ }\fR
.RE

.SS "Words, Sentences, Paragraphs"
.sp
.ne 2
.na
\fBw\fR
.ad
.RS 5n
forward a word
.RE

.sp
.ne 2
.na
\fBb\fR
.ad
.RS 5n
back a word
.RE

.sp
.ne 2
.na
\fBe\fR
.ad
.RS 5n
end of word
.RE

.sp
.ne 2
.na
\fB)\fR
.ad
.RS 5n
to next sentence
.RE

.sp
.ne 2
.na
\fB}\fR
.ad
.RS 5n
to next paragraph
.RE

.sp
.ne 2
.na
\fB(\fR
.ad
.RS 5n
back a sentence
.RE

.sp
.ne 2
.na
\fB{\fR
.ad
.RS 5n
back a paragraph
.RE

.sp
.ne 2
.na
\fBW\fR
.ad
.RS 5n
forward a blank-delimited word
.RE

.sp
.ne 2
.na
\fBB\fR
.ad
.RS 5n
back a blank-delimited word
.RE

.sp
.ne 2
.na
\fBE\fR
.ad
.RS 5n
end of a blank-delimited word
.RE

.SS "Corrections During Insert"
.sp
.ne 2
.na
\fB^H\fR
.ad
.RS 16n
erase last character (backspace)
.RE

.sp
.ne 2
.na
\fB^W\fR
.ad
.RS 16n
erase last word
.RE

.sp
.ne 2
.na
\fBerase\fR
.ad
.RS 16n
your erase character, same as \fB^H\fR (backspace)
.RE

.sp
.ne 2
.na
\fBkill\fR
.ad
.RS 16n
your kill character, erase this line of input
.RE

.sp
.ne 2
.na
\fB\e\fR
.ad
.RS 16n
quotes your erase and kill characters
.RE

.sp
.ne 2
.na
\fB\fIESC\fR\fR
.ad
.RS 16n
ends insertion, back to command mode
.RE

.sp
.ne 2
.na
\fBControl\(miC\fR
.ad
.RS 16n
interrupt, suspends insert mode
.RE

.sp
.ne 2
.na
\fB^D\fR
.ad
.RS 16n
backtab one character; reset left margin of \fIautoindent\fR
.RE

.sp
.ne 2
.na
\fB^^D\fR
.ad
.RS 16n
caret (\fB^\fR) followed by control-d (\fB^D\fR); backtab to beginning of line;
do not reset left margin of \fIautoindent\fR
.RE

.sp
.ne 2
.na
\fB0^D\fR
.ad
.RS 16n
backtab to beginning of line; reset left margin of \fIautoindent\fR
.RE

.sp
.ne 2
.na
\fB^V\fR
.ad
.RS 16n
quote non-printable character
.RE

.SS "Insert and Replace"
.sp
.ne 2
.na
\fBa\fR
.ad
.RS 12n
append after cursor
.RE

.sp
.ne 2
.na
\fBA\fR
.ad
.RS 12n
append at end of line
.RE

.sp
.ne 2
.na
\fBi\fR
.ad
.RS 12n
insert before cursor
.RE

.sp
.ne 2
.na
\fBI\fR
.ad
.RS 12n
insert before first non-blank
.RE

.sp
.ne 2
.na
\fBo\fR
.ad
.RS 12n
open line below
.RE

.sp
.ne 2
.na
\fBO\fR
.ad
.RS 12n
open line above
.RE

.sp
.ne 2
.na
\fBr\fIx\fR\fR
.ad
.RS 12n
replace single character with \fIx\fR
.RE

.sp
.ne 2
.na
\fBR\fItext\fR\fIESC\fR\fR
.ad
.RS 12n
replace characters
.RE

.SS "Operators"
.sp
.LP
Operators are followed by a cursor motion and affect all text that would have
been moved over. For example, since \fBw\fR moves over a word, \fBdw\fR deletes
the word that would be moved over. Double the operator, for example \fBdd\fR,
to affect whole lines.
.sp
.ne 2
.na
\fBd\fR
.ad
.RS 5n
delete
.RE

.sp
.ne 2
.na
\fBc\fR
.ad
.RS 5n
change
.RE

.sp
.ne 2
.na
\fBy\fR
.ad
.RS 5n
yank lines to buffer
.RE

.sp
.ne 2
.na
\fB<\fR
.ad
.RS 5n
left shift
.RE

.sp
.ne 2
.na
\fB>\fR
.ad
.RS 5n
right shift
.RE

.sp
.ne 2
.na
\fB!\fR
.ad
.RS 5n
filter through command
.RE

.SS "Miscellaneous Operations"
.sp
.ne 2
.na
\fBC\fR
.ad
.RS 5n
change rest of line (\fBc$\fR)
.RE

.sp
.ne 2
.na
\fBD\fR
.ad
.RS 5n
delete rest of line (\fBd$\fR)
.RE

.sp
.ne 2
.na
\fBs\fR
.ad
.RS 5n
substitute characters (\fBcl\fR)
.RE

.sp
.ne 2
.na
\fBS\fR
.ad
.RS 5n
substitute lines (\fBcc\fR)
.RE

.sp
.ne 2
.na
\fBJ\fR
.ad
.RS 5n
join lines
.RE

.sp
.ne 2
.na
\fBx\fR
.ad
.RS 5n
delete characters (\fBdl\fR)
.RE

.sp
.ne 2
.na
\fBX\fR
.ad
.RS 5n
delete characters before cursor \fBdh\fR)
.RE

.sp
.ne 2
.na
\fBY\fR
.ad
.RS 5n
yank lines (\fByy\fR)
.RE

.SS "Yank and Put"
.sp
.LP
Put inserts the text most recently deleted or yanked; however, if a buffer is
named (using the \fBASCII\fR lower-case letters \fBa\fR - \fBz\fR), the text in
that buffer is put instead.
.sp
.ne 2
.na
\fB3yy\fR
.ad
.RS 7n
yank 3 lines
.RE

.sp
.ne 2
.na
\fB3yl\fR
.ad
.RS 7n
yank 3 characters
.RE

.sp
.ne 2
.na
\fBp\fR
.ad
.RS 7n
put back text after cursor
.RE

.sp
.ne 2
.na
\fBP\fR
.ad
.RS 7n
put back text before cursor
.RE

.sp
.ne 2
.na
\fB\fI"x\fRp\fR
.ad
.RS 7n
put from buffer \fIx\fR
.RE

.sp
.ne 2
.na
\fB"\fIx\fRy\fR
.ad
.RS 7n
yank to buffer \fIx\fR
.RE

.sp
.ne 2
.na
\fB"\fIx\fRd\fR
.ad
.RS 7n
delete into buffer \fIx\fR
.RE

.SS "Undo, Redo, Retrieve"
.sp
.ne 2
.na
\fBu\fR
.ad
.RS 7n
undo last change
.RE

.sp
.ne 2
.na
\fBU\fR
.ad
.RS 7n
restore current line
.RE

.sp
.ne 2
.na
\fB\&.\fR
.ad
.RS 7n
repeat last change
.RE

.sp
.ne 2
.na
\fB"\fId\fRp\fR
.ad
.RS 7n
retrieve \fId\fR'th last delete
.RE

.SH USAGE
.sp
.LP
See \fBlargefile\fR(5) for the description of the behavior of \fBvi\fR and
\fBview\fR when encountering files greater than or equal to 2 Gbyte ( 2^31
bytes).
.SH ENVIRONMENT VARIABLES
.sp
.LP
See \fBenviron\fR(5) for descriptions of the following environment variables
that affect the execution of \fBvi\fR: \fBLANG\fR, \fBLC_ALL\fR,
\fBLC_COLLATE\fR, \fBLC_CTYPE\fR, \fBLC_TIME\fR, \fBLC_MESSAGES\fR,
\fBNLSPATH\fR, \fBPATH\fR, \fBSHELL\fR, and \fBTERM\fR.
.sp
.ne 2
.na
\fB\fBCOLUMNS\fR\fR
.ad
.RS 11n
Override the system-selected horizontal screen size.
.RE

.sp
.ne 2
.na
\fB\fBEXINIT\fR\fR
.ad
.RS 11n
Determine a list of \fBex\fR commands that are executed on editor start-up,
before reading the first file. The list can contain multiple commands by
separating them using a vertical-line (\fB|\fR) character.
.RE

.sp
.ne 2
.na
\fB\fBLINES\fR\fR
.ad
.RS 11n
Override the system-selected vertical screen size, used as the number of lines
in a screenful and the vertical screen size in visual mode.
.RE

.SH FILES
.sp
.ne 2
.na
\fB\fB/var/tmp\fR\fR
.ad
.sp .6
.RS 4n
default directory where temporary work files are placed; it can be changed
using the \fBdirectory\fR option (see the \fBex\fR(1) command)
.RE

.sp
.ne 2
.na
\fB\fB/usr/share/lib/terminfo/?/*\fR\fR
.ad
.sp .6
.RS 4n
compiled terminal description database
.RE

.sp
.ne 2
.na
\fB\fB/usr/lib/.COREterm/?/*\fR\fR
.ad
.sp .6
.RS 4n
subset of compiled terminal description database
.RE

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.SS "/usr/bin/vi, /usr/bin/view, /usr/bin/vedit"
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
CSI	Not enabled
.TE

.SS "/usr/xpg4/bin/vi, /usr/xpg4/bin/view, /usr/xpg4/bin/vedit"
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
CSI	Enabled
_
Interface Stability	Standard
.TE

.SS "/usr/xpg6/bin/vi, /usr/xpg6/bin/view, /usr/xpg6/bin/vedit"
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
CSI	Enabled
_
Interface Stability	Standard
.TE

.SH SEE ALSO
.sp
.LP
\fBIntro\fR(1), \fBctags\fR(1), \fBed\fR(1), \fBedit\fR(1), \fBex\fR(1),
\fBattributes\fR(5), \fBenviron\fR(5), \fBlargefile\fR(5), \fBstandards\fR(5)
.sp
.LP
\fISolaris Advanced User\&'s Guide\fR
.SH AUTHOR
.sp
.LP
\fBvi\fR and \fBex\fR were developed by The University of California, Berkeley
California, Computer Science Division, Department of Electrical Engineering and
Computer Science.
.SH NOTES
.sp
.LP
Two options, although they continue to be supported, have been replaced in the
documentation by options that follow the Command Syntax Standard (see
\fBIntro\fR(1)). An \fB-r\fR option that is not followed with an
option-argument has been replaced by \fB-L\fR and \fB+\fR\fBcommand\fR has been
replaced by \fB-c\fR \fBcommand\fR.
.sp
.LP
The message \fBfile too large to recover with\fR \fB-r\fR \fBoption\fR, which
is seen when a file is loaded, indicates that the file can be edited and saved
successfully, but if the editing session is lost, recovery of the file with the
\fB-r\fR option is not possible.
.sp
.LP
The editing environment defaults to certain configuration options. When an
editing session is initiated, \fBvi\fR attempts to read the \fBEXINIT\fR
environment variable. If it exists, the editor uses the values defined in
\fBEXINIT\fR; otherwise the values set in \fB$HOME/.exrc\fR are used. If
\fB$HOME/.exrc\fR does not exist, the default values are used.
.sp
.LP
To use a copy of \fB\&.exrc\fR located in the current directory other than
\fB$HOME\fR, set the \fIexrc\fR option in \fBEXINIT\fR or \fB$HOME/.exrc\fR.
Options set in \fBEXINIT\fR can be turned off in a local \fB\&.exrc\fR only if
\fIexrc\fR is set in \fBEXINIT\fR or \fB$HOME/.exrc\fR. In order to be used,
\fI\&.exrc\fR in \fB$HOME\fR or the current directory must fulfill these
conditions:
.RS +4
.TP
.ie t \(bu
.el o
It must exist.
.RE
.RS +4
.TP
.ie t \(bu
.el o
It must be owned by the same userid as the real userid of the process, or the
process has appropriate privileges.
.RE
.RS +4
.TP
.ie t \(bu
.el o
It is not writable by anyone other than the owner.
.RE
.sp
.LP
Tampering with entries in \fB/usr/share/lib/terminfo/?/*\fR or
\fB/usr/share/lib/terminfo/?/*\fR (for example, changing or removing an entry)
can affect programs such as \fBvi\fR that expect the entry to be present and
correct. In particular, removing the "dumb" terminal can cause unexpected
problems.
.sp
.LP
Software tabs using \fB^T\fR work only immediately after the \fIautoindent\fR.
.sp
.LP
Left and right shifts on intelligent terminals do not make use of insert and
delete character operations in the terminal.
.sp
.LP
Loading an alternate \fBmalloc()\fR library using the environment variable
\fBLD_PRELOAD\fR can cause problems for \fB/usr/bin/vi\fR.
.sp
.LP
The \fBvi\fR utility currently has the following limitations:
.RS +4
.TP
1.
Lines, including the trailing NEWLINE character, can contain no more than
4096 bytes.
.sp
If a longer line is found, \fBLine too long\fR is displayed in the status line.
.RE
.RS +4
.TP
2.
The editor's temporary work file can be no larger than 128Mb.
.sp
If a larger temporary file is needed, \fBTmp file too large\fR is displayed in
the status line.
.RE