'\" 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" "16 May 2007" "SunOS 5.11" "User Commands" .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 .mk .na \fB\fB\(mi\fR | \fB-s\fR\fR .ad .RS 25n .rt Suppresses all interactive user feedback. This is useful when processing editor scripts. .RE .sp .ne 2 .mk .na \fB\fB-C\fR\fR .ad .RS 25n .rt 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 .mk .na \fB\fB-l\fR\fR .ad .RS 25n .rt Sets up for editing \fBLISP\fR programs. .RE .sp .ne 2 .mk .na \fB\fB-L\fR\fR .ad .RS 25n .rt Lists the name of all files saved as the result of an editor or system crash. .RE .sp .ne 2 .mk .na \fB\fB-r\fR \fIfilename\fR\fR .ad .RS 25n .rt 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 .mk .na \fB\fB-R\fR\fR .ad .RS 25n .rt \fBReadonly\fR mode. The \fBreadonly\fR flag is set, preventing accidental overwriting of the file. .RE .sp .ne 2 .mk .na \fB\fB-S\fR\fR .ad .RS 25n .rt 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 .mk .na \fB\fB-t\fR \fItag\fR\fR .ad .RS 25n .rt 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 .mk .na \fB\fB-v\fR\fR .ad .RS 25n .rt 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 .mk .na \fB\fB-V\fR\fR .ad .RS 25n .rt 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 .mk .na \fB\fB-w\fR\fIn\fR\fR .ad .RS 25n .rt Sets the default window size to \fIn\fR. This is useful when using the editor over a slow speed line. .RE .sp .ne 2 .mk .na \fB\fB-x\fR\fR .ad .RS 25n .rt 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 .mk .na \fB\fB-\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR\fR .ad .RS 25n .rt 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 .mk .na \fB\fIfilename\fR\fR .ad .RS 12n .rt 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 .mk .na \fBCommand\fR .ad .RS 13n .rt 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 .mk .na \fBInput\fR .ad .RS 13n .rt 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 .mk .na \fBLast line\fR .ad .RS 13n .rt 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 .mk .na \fB\(<-, \(->\fR .ad .br .na \fBdown-arrow\fR .ad .br .na \fBup-arrow\fR .ad .RS 14n .rt arrow keys move the cursor .RE .sp .ne 2 .mk .na \fBh j k l\fR .ad .RS 14n .rt same as arrow keys .RE .sp .ne 2 .mk .na \fBi\fItext\fR\fIESC\fR\fR .ad .RS 14n .rt insert \fItext\fR .RE .sp .ne 2 .mk .na \fBcw\fInew\fR\fIESC\fR\fR .ad .RS 14n .rt change word to \fInew\fR .RE .sp .ne 2 .mk .na \fBea\fIs\fR\fIESC\fR\fR .ad .RS 14n .rt pluralize word (end of word; append \fBs\fR; escape from input state) .RE .sp .ne 2 .mk .na \fBx\fR .ad .RS 14n .rt delete a character .RE .sp .ne 2 .mk .na \fBdw\fR .ad .RS 14n .rt delete a word .RE .sp .ne 2 .mk .na \fBdd\fR .ad .RS 14n .rt delete a line .RE .sp .ne 2 .mk .na \fB3dd\fR .ad .RS 14n .rt delete 3 lines .RE .sp .ne 2 .mk .na \fBu\fR .ad .RS 14n .rt undo previous change .RE .sp .ne 2 .mk .na \fBZZ\fR .ad .RS 14n .rt exit \fBvi\fR, saving changes .RE .sp .ne 2 .mk .na \fB:q!\fICR\fR\fR .ad .RS 14n .rt quit, discarding changes .RE .sp .ne 2 .mk .na \fB/\fItext\fR\fICR\fR\fR .ad .RS 14n .rt search for \fItext\fR .RE .sp .ne 2 .mk .na \fB^U ^D\fR .ad .RS 14n .rt scroll up or down .RE .sp .ne 2 .mk .na \fB:\fIcmd\fR\fICR\fR\fR .ad .RS 14n .rt 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 .mk .na \fBline/column number\fR .ad .RS 22n .rt z G | .RE .sp .ne 2 .mk .na \fBscroll amount\fR .ad .RS 22n .rt ^D ^U .RE .sp .ne 2 .mk .na \fBrepeat effect\fR .ad .RS 22n .rt most of the rest .RE .SS "Interrupting, Canceling" .sp .ne 2 .mk .na \fB\fIESC\fR\fR .ad .RS 7n .rt end insert or incomplete command .RE .sp .ne 2 .mk .na \fB\fIDEL\fR\fR .ad .RS 7n .rt (delete or rubout) interrupts .RE .SS "File Manipulation" .sp .ne 2 .mk .na \fBZZ\fR .ad .RS 15n .rt if file modified, write and exit; otherwise, exit .RE .sp .ne 2 .mk .na \fB:w\fICR\fR\fR .ad .RS 15n .rt write back changes .RE .sp .ne 2 .mk .na \fB:w!\fICR\fR\fR .ad .RS 15n .rt forced write, if permission originally not valid .RE .sp .ne 2 .mk .na \fB:q\fICR\fR\fR .ad .RS 15n .rt quit .RE .sp .ne 2 .mk .na \fB:q!\fICR\fR\fR .ad .RS 15n .rt quit, discard changes .RE .sp .ne 2 .mk .na \fB:e \fIname\fR\fICR\fR\fR .ad .RS 15n .rt edit file \fIname\fR .RE .sp .ne 2 .mk .na \fB:e!\fICR\fR\fR .ad .RS 15n .rt reedit, discard changes .RE .sp .ne 2 .mk .na \fB:e + \fIname\fR\fICR\fR\fR .ad .RS 15n .rt edit, starting at end .RE .sp .ne 2 .mk .na \fB:e +\fIn\fR\fICR\fR\fR .ad .RS 15n .rt edit, starting at line \fIn\fR .RE .sp .ne 2 .mk .na \fB:e #\fICR\fR\fR .ad .RS 15n .rt edit alternate file .RE .sp .ne 2 .mk .na \fB:e! #\fICR\fR\fR .ad .RS 15n .rt edit alternate file, discard changes .RE .sp .ne 2 .mk .na \fB:w \fIname\fR\fICR\fR\fR .ad .RS 15n .rt write file \fIname\fR .RE .sp .ne 2 .mk .na \fB:w! \fIname\fR\fICR\fR\fR .ad .RS 15n .rt overwrite file \fIname\fR .RE .sp .ne 2 .mk .na \fB:sh\fICR\fR\fR .ad .RS 15n .rt run shell, then return .RE .sp .ne 2 .mk .na \fB:!\fIcmd\fR\fICR\fR\fR .ad .RS 15n .rt run \fIcmd\fR, then return .RE .sp .ne 2 .mk .na \fB:n\fICR\fR\fR .ad .RS 15n .rt edit next file in arglist .RE .sp .ne 2 .mk .na \fB:n \fIargs\fR\fICR\fR\fR .ad .RS 15n .rt specify new arglist .RE .sp .ne 2 .mk .na \fB^G\fR .ad .RS 15n .rt show current file and line .RE .sp .ne 2 .mk .na \fB:ta \fItag\fR\fICR\fR\fR .ad .RS 15n .rt 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 .mk .na \fBF\fR .ad .RS 14n .rt forward screen .RE .sp .ne 2 .mk .na \fB^B\fR .ad .RS 14n .rt backward screen .RE .sp .ne 2 .mk .na \fB^D\fR .ad .RS 14n .rt scroll down half screen .RE .sp .ne 2 .mk .na \fB^U\fR .ad .RS 14n .rt scroll up half screen .RE .sp .ne 2 .mk .na \fB\fIn\fRG\fR .ad .RS 14n .rt go to the beginning of the specified line (end default), where \fIn\fR is a line number .RE .sp .ne 2 .mk .na \fB/\fIpat\fR\fR .ad .RS 14n .rt next line matching \fIpat\fR .RE .sp .ne 2 .mk .na \fB?\fIpat\fR\fR .ad .RS 14n .rt previous line matching \fIpat\fR .RE .sp .ne 2 .mk .na \fBn\fR .ad .RS 14n .rt repeat last \fB/\fR or \fB?\fR command .RE .sp .ne 2 .mk .na \fBN\fR .ad .RS 14n .rt reverse last \fB/\fR or \fB?\fR command .RE .sp .ne 2 .mk .na \fB/\fIpat\fR/+\fIn\fR\fR .ad .RS 14n .rt \fIn\fRth line after \fIpat\fR .RE .sp .ne 2 .mk .na \fB?\fIpat\fR?\(mi\fIn\fR\fR .ad .RS 14n .rt \fIn\fRth line before \fIpat\fR .RE .sp .ne 2 .mk .na \fB]]\fR .ad .RS 14n .rt next section/function .RE .sp .ne 2 .mk .na \fB[[\fR .ad .RS 14n .rt previous section/function .RE .sp .ne 2 .mk .na \fB(\fR .ad .RS 14n .rt beginning of sentence .RE .sp .ne 2 .mk .na \fB)\fR .ad .RS 14n .rt end of sentence .RE .sp .ne 2 .mk .na \fB{\fR .ad .RS 14n .rt beginning of paragraph .RE .sp .ne 2 .mk .na \fB}\fR .ad .RS 14n .rt end of paragraph .RE .sp .ne 2 .mk .na \fB%\fR .ad .RS 14n .rt find matching \fB( )\fR or \fB{ }\fR .RE .SS "Adjusting the Screen" .sp .ne 2 .mk .na \fB^L\fR .ad .RS 16n .rt clear and redraw window .RE .sp .ne 2 .mk .na \fB^R\fR .ad .RS 16n .rt clear and redraw window if \fB^L\fR is \(-> key .RE .sp .ne 2 .mk .na \fBz\fICR\fR\fR .ad .RS 16n .rt redraw screen with current line at top of window .RE .sp .ne 2 .mk .na \fBz\(mi\fICR\fR\fR .ad .RS 16n .rt redraw screen with current line at bottom of window .RE .sp .ne 2 .mk .na \fBz.\fICR\fR\fR .ad .RS 16n .rt redraw screen with current line at center of window .RE .sp .ne 2 .mk .na \fB/\fIpat\fR/z\(mi\fICR\fR\fR .ad .RS 16n .rt move \fIpat\fR line to bottom of window .RE .sp .ne 2 .mk .na \fBz\fIn\fR.\fICR\fR\fR .ad .RS 16n .rt use \fIn\fR\(miline window .RE .sp .ne 2 .mk .na \fB^E\fR .ad .RS 16n .rt scroll window down one line .RE .sp .ne 2 .mk .na \fB^Y\fR .ad .RS 16n .rt scroll window up one line .RE .SS "Marking and Returning" .sp .ne 2 .mk .na \fB\(ga\(ga\fR .ad .RS 12n .rt move cursor to previous context .RE .sp .ne 2 .mk .na \fBa\'a\'\fR .ad .RS 12n .rt move cursor to first non-white space in line .RE .sp .ne 2 .mk .na \fBm\fIx\fR\fR .ad .RS 12n .rt mark current position with the \fBASCII\fR lower-case letter \fIx\fR .RE .sp .ne 2 .mk .na \fB\(ga\fIx\fR\fR .ad .RS 12n .rt move cursor to mark \fIx\fR .RE .sp .ne 2 .mk .na \fBa\'\fIx\fR\fR .ad .RS 12n .rt move cursor to first non-white space in line marked by \fIx\fR .RE .SS "Line Positioning" .sp .ne 2 .mk .na \fBH\fR .ad .RS 14n .rt top line on screen .RE .sp .ne 2 .mk .na \fBL\fR .ad .RS 14n .rt last line on screen .RE .sp .ne 2 .mk .na \fBM\fR .ad .RS 14n .rt middle line on screen .RE .sp .ne 2 .mk .na \fB+\fR .ad .RS 14n .rt next line, at first non-white space character .RE .sp .ne 2 .mk .na \fB\(mi\fR .ad .RS 14n .rt previous line, at first non-white space character .RE .sp .ne 2 .mk .na \fB\fICR\fR\fR .ad .RS 14n .rt return, same as \fB+\fR .RE .sp .ne 2 .mk .na \fB\fBdown-arrow\fR\fR .ad .br .na \fBor \fBj\fR\fR .ad .RS 14n .rt next line, same column .RE .sp .ne 2 .mk .na \fB\fBup-arrow\fR\fR .ad .br .na \fBor \fBk\fR\fR .ad .RS 14n .rt previous line, same column .RE .SS "Character Positioning" .sp .ne 2 .mk .na \fB^\fR .ad .RS 13n .rt first non-white space character .RE .sp .ne 2 .mk .na \fB0\fR .ad .RS 13n .rt beginning of line .RE .sp .ne 2 .mk .na \fB$\fR .ad .RS 13n .rt end of line .RE .sp .ne 2 .mk .na \fB\fBl\fR or \fB\(->\fR\fR .ad .RS 13n .rt forward .RE .sp .ne 2 .mk .na \fB\fBh\fR or \fB\(<-\fR\fR .ad .RS 13n .rt backward .RE .sp .ne 2 .mk .na \fB^H\fR .ad .RS 13n .rt same as \fB\(<-\fR (backspace) .RE .sp .ne 2 .mk .na \fBspace\fR .ad .RS 13n .rt same as \fB\(->\fR (space bar) .RE .sp .ne 2 .mk .na \fBf\fIx\fR\fR .ad .RS 13n .rt find next \fIx\fR .RE .sp .ne 2 .mk .na \fBF\fIx\fR\fR .ad .RS 13n .rt find previous \fIx\fR .RE .sp .ne 2 .mk .na \fBt\fIx\fR\fR .ad .RS 13n .rt move to character following the next \fIx\fR .RE .sp .ne 2 .mk .na \fBT\fIx\fR\fR .ad .RS 13n .rt move to character following the previous \fIx\fR .RE .sp .ne 2 .mk .na \fB;\fR .ad .RS 13n .rt repeat last \fBf\fR, \fBF\fR, \fBt\fR, or \fBT\fR .RE .sp .ne 2 .mk .na \fB,\fR .ad .RS 13n .rt repeat inverse of last \fBf\fR, \fBF\fR, \fBt\fR, or \fBT\fR .RE .sp .ne 2 .mk .na \fB\fIn\fR|\fR .ad .RS 13n .rt move to column \fIn\fR .RE .sp .ne 2 .mk .na \fB%\fR .ad .RS 13n .rt find matching \fB( )\fR or \fB{ }\fR .RE .SS "Words, Sentences, Paragraphs" .sp .ne 2 .mk .na \fBw\fR .ad .RS 5n .rt forward a word .RE .sp .ne 2 .mk .na \fBb\fR .ad .RS 5n .rt back a word .RE .sp .ne 2 .mk .na \fBe\fR .ad .RS 5n .rt end of word .RE .sp .ne 2 .mk .na \fB)\fR .ad .RS 5n .rt to next sentence .RE .sp .ne 2 .mk .na \fB}\fR .ad .RS 5n .rt to next paragraph .RE .sp .ne 2 .mk .na \fB(\fR .ad .RS 5n .rt back a sentence .RE .sp .ne 2 .mk .na \fB{\fR .ad .RS 5n .rt back a paragraph .RE .sp .ne 2 .mk .na \fBW\fR .ad .RS 5n .rt forward a blank-delimited word .RE .sp .ne 2 .mk .na \fBB\fR .ad .RS 5n .rt back a blank-delimited word .RE .sp .ne 2 .mk .na \fBE\fR .ad .RS 5n .rt end of a blank-delimited word .RE .SS "Corrections During Insert" .sp .ne 2 .mk .na \fB^H\fR .ad .RS 16n .rt erase last character (backspace) .RE .sp .ne 2 .mk .na \fB^W\fR .ad .RS 16n .rt erase last word .RE .sp .ne 2 .mk .na \fBerase\fR .ad .RS 16n .rt your erase character, same as \fB^H\fR (backspace) .RE .sp .ne 2 .mk .na \fBkill\fR .ad .RS 16n .rt your kill character, erase this line of input .RE .sp .ne 2 .mk .na \fB\e\fR .ad .RS 16n .rt quotes your erase and kill characters .RE .sp .ne 2 .mk .na \fB\fIESC\fR\fR .ad .RS 16n .rt ends insertion, back to command mode .RE .sp .ne 2 .mk .na \fBControl\(miC\fR .ad .RS 16n .rt interrupt, suspends insert mode .RE .sp .ne 2 .mk .na \fB^D\fR .ad .RS 16n .rt backtab one character; reset left margin of \fIautoindent\fR .RE .sp .ne 2 .mk .na \fB^^D\fR .ad .RS 16n .rt 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 .mk .na \fB0^D\fR .ad .RS 16n .rt backtab to beginning of line; reset left margin of \fIautoindent\fR .RE .sp .ne 2 .mk .na \fB^V\fR .ad .RS 16n .rt quote non-printable character .RE .SS "Insert and Replace" .sp .ne 2 .mk .na \fBa\fR .ad .RS 12n .rt append after cursor .RE .sp .ne 2 .mk .na \fBA\fR .ad .RS 12n .rt append at end of line .RE .sp .ne 2 .mk .na \fBi\fR .ad .RS 12n .rt insert before cursor .RE .sp .ne 2 .mk .na \fBI\fR .ad .RS 12n .rt insert before first non-blank .RE .sp .ne 2 .mk .na \fBo\fR .ad .RS 12n .rt open line below .RE .sp .ne 2 .mk .na \fBO\fR .ad .RS 12n .rt open line above .RE .sp .ne 2 .mk .na \fBr\fIx\fR\fR .ad .RS 12n .rt replace single character with \fIx\fR .RE .sp .ne 2 .mk .na \fBR\fItext\fR\fIESC\fR\fR .ad .RS 12n .rt 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 .mk .na \fBd\fR .ad .RS 5n .rt delete .RE .sp .ne 2 .mk .na \fBc\fR .ad .RS 5n .rt change .RE .sp .ne 2 .mk .na \fBy\fR .ad .RS 5n .rt yank lines to buffer .RE .sp .ne 2 .mk .na \fB<\fR .ad .RS 5n .rt left shift .RE .sp .ne 2 .mk .na \fB>\fR .ad .RS 5n .rt right shift .RE .sp .ne 2 .mk .na \fB!\fR .ad .RS 5n .rt filter through command .RE .SS "Miscellaneous Operations" .sp .ne 2 .mk .na \fBC\fR .ad .RS 5n .rt change rest of line (\fBc$\fR) .RE .sp .ne 2 .mk .na \fBD\fR .ad .RS 5n .rt delete rest of line (\fBd$\fR) .RE .sp .ne 2 .mk .na \fBs\fR .ad .RS 5n .rt substitute characters (\fBcl\fR) .RE .sp .ne 2 .mk .na \fBS\fR .ad .RS 5n .rt substitute lines (\fBcc\fR) .RE .sp .ne 2 .mk .na \fBJ\fR .ad .RS 5n .rt join lines .RE .sp .ne 2 .mk .na \fBx\fR .ad .RS 5n .rt delete characters (\fBdl\fR) .RE .sp .ne 2 .mk .na \fBX\fR .ad .RS 5n .rt delete characters before cursor \fBdh\fR) .RE .sp .ne 2 .mk .na \fBY\fR .ad .RS 5n .rt 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 .mk .na \fB3yy\fR .ad .RS 7n .rt yank 3 lines .RE .sp .ne 2 .mk .na \fB3yl\fR .ad .RS 7n .rt yank 3 characters .RE .sp .ne 2 .mk .na \fBp\fR .ad .RS 7n .rt put back text after cursor .RE .sp .ne 2 .mk .na \fBP\fR .ad .RS 7n .rt put back text before cursor .RE .sp .ne 2 .mk .na \fB\fI"x\fRp\fR .ad .RS 7n .rt put from buffer \fIx\fR .RE .sp .ne 2 .mk .na \fB"\fIx\fRy\fR .ad .RS 7n .rt yank to buffer \fIx\fR .RE .sp .ne 2 .mk .na \fB"\fIx\fRd\fR .ad .RS 7n .rt delete into buffer \fIx\fR .RE .SS "Undo, Redo, Retrieve" .sp .ne 2 .mk .na \fBu\fR .ad .RS 7n .rt undo last change .RE .sp .ne 2 .mk .na \fBU\fR .ad .RS 7n .rt restore current line .RE .sp .ne 2 .mk .na \fB\&.\fR .ad .RS 7n .rt repeat last change .RE .sp .ne 2 .mk .na \fB"\fId\fRp\fR .ad .RS 7n .rt 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 .mk .na \fB\fBCOLUMNS\fR\fR .ad .RS 11n .rt Override the system-selected horizontal screen size. .RE .sp .ne 2 .mk .na \fB\fBEXINIT\fR\fR .ad .RS 11n .rt 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 .mk .na \fB\fBLINES\fR\fR .ad .RS 11n .rt 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 .mk .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 .mk .na \fB\fB/usr/share/lib/terminfo/?/*\fR\fR .ad .sp .6 .RS 4n compiled terminal description database .RE .sp .ne 2 .mk .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 tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ CSINot enabled .TE .SS "/usr/xpg4/bin/vi, /usr/xpg4/bin/view, /usr/xpg4/bin/vedit" .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ CSIEnabled _ Interface StabilityStandard .TE .SS "/usr/xpg6/bin/vi, /usr/xpg6/bin/view, /usr/xpg6/bin/vedit" .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ CSIEnabled _ Interface StabilityStandard .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