2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group. In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document. The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
25 .\" This notice shall appear on any product containing this material.
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
43 .\" Copyright 1989 AT&T
44 .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
45 .\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
47 .TH VI 1HAS "May 16, 2007"
49 vi, view, vedit \- screen-oriented (visual) display editor based on ex
53 \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]
54 [\fB-t\fR \fItag\fR] [\fB-v\fR] [\fB-V\fR] [\fB-x\fR] [\fB-w\fR\fIn\fR] [\fB-C\fR]
55 [\fB+\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
60 \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]
61 [\fB-t\fR \fItag\fR] [\fB-v\fR] [\fB-V\fR] [\fB-x\fR] [\fB-w\fR\fIn\fR] [\fB-C\fR]
62 [\fB+\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
67 \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]
68 [\fB-t\fR \fItag\fR] [\fB-v\fR] [\fB-V\fR] [\fB-x\fR] [\fB-w\fR\fIn\fR] [\fB-C\fR]
69 [\fB+\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
74 \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]]
75 [\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]
76 [\fB+\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
81 \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]]
82 [\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]
83 [\fB+\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
88 \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]]
89 [\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]
90 [\fB+\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
95 \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]]
96 [\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]
97 [\fB+\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
102 \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]]
103 [\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]
104 [\fB+\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
109 \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]]
110 [\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]
111 [\fB+\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR] \fIfilename\fR...
117 The \fBvi\fR (visual) utility is a display-oriented text editor based on an
118 underlying line editor \fBex\fR. It is possible to use the command mode of
119 \fBex\fR from within \fBvi\fR and to use the command mode of \fBvi\fR from
120 within \fBex\fR. The visual commands are described on this manual page; how to
121 set options (like automatically numbering lines and automatically starting a
122 new output line when you type carriage return) and all \fBex\fR line editor
123 commands are described on the \fBex\fR(1) manual page.
126 When using \fBvi\fR, changes you make to the file are reflected in what you see
127 on your terminal screen. The position of the cursor on the screen indicates the
128 position within the file.
131 The \fBview\fR invocation is the same as \fBvi\fR except that the
132 \fBreadonly\fR flag is set.
135 The \fBvedit\fR invocation is intended for beginners. It is the same as
136 \fBvi\fR except that the \fBreport\fR flag is set to \fB1\fR, the
137 \fBshowmode\fR and \fBnovice\fR flags are set, and \fBmagic\fR is turned off.
138 These defaults make it easier to learn how to use \fBvi\fR.
142 The following options are supporrted:
143 .SS "Invocation Options"
146 The following invocation options are interpreted by \fBvi\fR (previously
147 documented options are discussed under NOTES):
151 \fB\fB\(mi\fR | \fB-s\fR\fR
154 Suppresses all interactive user feedback. This is useful when processing editor
164 Encryption option. Same as the \fB-x\fR option, except that \fBvi\fR simulates
165 the \fBC\fR command of \fBex\fR. The \fBC\fR command is like the \fBX\fR
166 command of \fBex\fR, except that all text read in is assumed to have been
176 Sets up for editing \fBLISP\fR programs.
185 Lists the name of all files saved as the result of an editor or system crash.
191 \fB\fB-r\fR \fIfilename\fR\fR
194 Edits \fIfilename\fR after an editor or system crash. (Recovers the version of
195 \fIfilename\fR that was in the buffer when the crash occurred.)
204 \fBReadonly\fR mode. The \fBreadonly\fR flag is set, preventing accidental
205 overwriting of the file.
214 This option is used in conjunction with the \fB-t\fR \fItag\fR option to tell
215 \fBvi\fR that the tags file can not be sorted and that, if the binary search
216 (which relies on a sorted tags file) for \fItag\fR fails to find it, the much
217 slower linear search should also be done. Since the linear search is slow,
218 users of large tags files should ensure that the tags files are sorted rather
219 than use this flag. Creation of tags files normally produces sorted tags files.
220 See \fBctags\fR(1) for more information on tags files.
226 \fB\fB-t\fR \fItag\fR\fR
229 Edits the file containing \fItag\fR and position the editor at its definition.
230 It is an error to specify more than one \fB-t\fR option.
239 Starts up in display editing state, using \fBvi\fR. You can achieve the same
240 effect by typing the \fBvi\fR command itself.
249 Verbose. When \fBex\fR commands are read by means of standard input, the input
250 is echoed to standard error. This can be useful when processing \fBex\fR
251 commands within shell scripts.
257 \fB\fB-w\fR\fIn\fR\fR
260 Sets the default window size to \fIn\fR. This is useful when using the editor
261 over a slow speed line.
270 Encryption option. When used, \fBvi\fR simulates the \fBX\fR command of
271 \fBex\fR and prompts the user for a key. This key is used to encrypt and
272 decrypt text using the algorithm of the \fBcrypt\fR command. The \fBX\fR
273 command makes an educated guess to determine whether text read in is encrypted
274 or not. The temporary buffer file is encrypted also, using a transformed
275 version of the key typed in for the \fB-x\fR option. If an empty encryption
276 key is entered (that is, if the return key is pressed right after the prompt),
277 the file is not encrypted. This is a good way to decrypt a file erroneously
278 encrypted with a mistyped encryption key, such as a backspace or undo key.
284 \fB\fB-\fR\fIcommand\fR | \fB-c\fR \fIcommand\fR\fR
287 Begins editing by executing the specified editor \fIcommand\fR (usually a
288 search or positioning command).
291 .SS "/usr/xpg4/bin/vi and /usr/xpg6/bin/vi"
294 If both the \fB-t\fR \fItag\fR and the \fB-c\fR \fIcommand\fR options are
295 given, the \fB-t\fR \fItag\fR optionis processed first. That is, the file
296 containing \fItag\fR is selected by \fB-t\fR and then the command is executed.
300 The following operands are supported:
313 The \fBvi\fR command modes are summarized in this section.
321 Normal and initial mode. Other modes return to command mode upon completion.
322 \fIESC\fR (escape) is used to cancel a partial command.
331 Entered by setting any of the following options:
335 a A i I o O c C s S R
340 Arbitrary text can then be entered. Input mode is normally terminated with the
341 \fIESC\fR character, or, abnormally, with an interrupt.
350 Reading input for \fB: / ?\fR or \fB!\fR. Terminate by typing a carriage
351 return. An interrupt cancels termination.
354 .SS "Sample Commands"
357 In the descriptions, \fICR\fR stands for carriage return and \fIESC\fR stands
373 arrow keys move the cursor
388 \fBi\fItext\fR\fIESC\fR\fR
397 \fBcw\fInew\fR\fIESC\fR\fR
400 change word to \fInew\fR
406 \fBea\fIs\fR\fIESC\fR\fR
409 pluralize word (end of word; append \fBs\fR; escape from input state)
463 exit \fBvi\fR, saving changes
472 quit, discarding changes
478 \fB/\fItext\fR\fICR\fR\fR
481 search for \fItext\fR
496 \fB:\fIcmd\fR\fICR\fR\fR
499 any \fBex\fR or \fBed\fR command
502 .SS "Counts Before vi Commands"
505 Numbers can be typed as a prefix to some commands. They are interpreted in one
510 \fBline/column number\fR
534 .SS "Interrupting, Canceling"
541 end insert or incomplete command
550 (delete or rubout) interrupts
553 .SS "File Manipulation"
560 if file modified, write and exit; otherwise, exit
578 forced write, if permission originally not valid
596 quit, discard changes
602 \fB:e \fIname\fR\fICR\fR\fR
614 reedit, discard changes
620 \fB:e + \fIname\fR\fICR\fR\fR
623 edit, starting at end
629 \fB:e +\fIn\fR\fICR\fR\fR
632 edit, starting at line \fIn\fR
650 edit alternate file, discard changes
656 \fB:w \fIname\fR\fICR\fR\fR
659 write file \fIname\fR
665 \fB:w! \fIname\fR\fICR\fR\fR
668 overwrite file \fIname\fR
677 run shell, then return
683 \fB:!\fIcmd\fR\fICR\fR\fR
686 run \fIcmd\fR, then return
695 edit next file in arglist
701 \fB:n \fIargs\fR\fICR\fR\fR
713 show current file and line
719 \fB:ta \fItag\fR\fICR\fR\fR
722 position cursor to \fItag\fR
727 In general, any \fBex\fR or \fBed\fR command (such as \fIsubstitute\fR or
728 \fIglobal\fR) can be typed, preceded by a colon and followed by a carriage
730 .SS "Positioning Within a File"
755 scroll down half screen
764 scroll up half screen
773 go to the beginning of the specified line (end default), where \fIn\fR is a
783 next line matching \fIpat\fR
792 previous line matching \fIpat\fR
801 repeat last \fB/\fR or \fB?\fR command
810 reverse last \fB/\fR or \fB?\fR command
816 \fB/\fIpat\fR/+\fIn\fR\fR
819 \fIn\fRth line after \fIpat\fR
825 \fB?\fIpat\fR?\(mi\fIn\fR\fR
828 \fIn\fRth line before \fIpat\fR
837 next section/function
846 previous section/function
855 beginning of sentence
873 beginning of paragraph
891 find matching \fB( )\fR or \fB{ }\fR
894 .SS "Adjusting the Screen"
901 clear and redraw window
910 clear and redraw window if \fB^L\fR is \(-> key
919 redraw screen with current line at top of window
928 redraw screen with current line at bottom of window
937 redraw screen with current line at center of window
943 \fB/\fIpat\fR/z\(mi\fICR\fR\fR
946 move \fIpat\fR line to bottom of window
952 \fBz\fIn\fR.\fICR\fR\fR
955 use \fIn\fR\(miline window
964 scroll window down one line
973 scroll window up one line
976 .SS "Marking and Returning"
983 move cursor to previous context
992 move cursor to first non-white space in line
1001 mark current position with the \fBASCII\fR lower-case letter \fIx\fR
1010 move cursor to mark \fIx\fR
1019 move cursor to first non-white space in line marked by \fIx\fR
1022 .SS "Line Positioning"
1047 middle line on screen
1056 next line, at first non-white space character
1065 previous line, at first non-white space character
1074 return, same as \fB+\fR
1080 \fB\fBdown-arrow\fR\fR
1087 next line, same column
1093 \fB\fBup-arrow\fR\fR
1100 previous line, same column
1103 .SS "Character Positioning"
1110 first non-white space character
1134 \fB\fBl\fR or \fB\(->\fR\fR
1143 \fB\fBh\fR or \fB\(<-\fR\fR
1155 same as \fB\(<-\fR (backspace)
1164 same as \fB\(->\fR (space bar)
1182 find previous \fIx\fR
1191 move to character following the next \fIx\fR
1200 move to character following the previous \fIx\fR
1209 repeat last \fBf\fR, \fBF\fR, \fBt\fR, or \fBT\fR
1218 repeat inverse of last \fBf\fR, \fBF\fR, \fBt\fR, or \fBT\fR
1227 move to column \fIn\fR
1236 find matching \fB( )\fR or \fB{ }\fR
1239 .SS "Words, Sentences, Paragraphs"
1309 forward a blank-delimited word
1318 back a blank-delimited word
1327 end of a blank-delimited word
1330 .SS "Corrections During Insert"
1337 erase last character (backspace)
1355 your erase character, same as \fB^H\fR (backspace)
1364 your kill character, erase this line of input
1373 quotes your erase and kill characters
1382 ends insertion, back to command mode
1391 interrupt, suspends insert mode
1400 backtab one character; reset left margin of \fIautoindent\fR
1409 caret (\fB^\fR) followed by control-d (\fB^D\fR); backtab to beginning of line;
1410 do not reset left margin of \fIautoindent\fR
1419 backtab to beginning of line; reset left margin of \fIautoindent\fR
1428 quote non-printable character
1431 .SS "Insert and Replace"
1447 append at end of line
1456 insert before cursor
1465 insert before first non-blank
1492 replace single character with \fIx\fR
1498 \fBR\fItext\fR\fIESC\fR\fR
1507 Operators are followed by a cursor motion and affect all text that would have
1508 been moved over. For example, since \fBw\fR moves over a word, \fBdw\fR deletes
1509 the word that would be moved over. Double the operator, for example \fBdd\fR,
1510 to affect whole lines.
1535 yank lines to buffer
1562 filter through command
1565 .SS "Miscellaneous Operations"
1572 change rest of line (\fBc$\fR)
1581 delete rest of line (\fBd$\fR)
1590 substitute characters (\fBcl\fR)
1599 substitute lines (\fBcc\fR)
1617 delete characters (\fBdl\fR)
1626 delete characters before cursor \fBdh\fR)
1635 yank lines (\fByy\fR)
1641 Put inserts the text most recently deleted or yanked; however, if a buffer is
1642 named (using the \fBASCII\fR lower-case letters \fBa\fR - \fBz\fR), the text in
1643 that buffer is put instead.
1668 put back text after cursor
1677 put back text before cursor
1686 put from buffer \fIx\fR
1695 yank to buffer \fIx\fR
1704 delete into buffer \fIx\fR
1707 .SS "Undo, Redo, Retrieve"
1723 restore current line
1741 retrieve \fId\fR'th last delete
1747 See \fBlargefile\fR(5) for the description of the behavior of \fBvi\fR and
1748 \fBview\fR when encountering files greater than or equal to 2 Gbyte ( 2^31
1750 .SH ENVIRONMENT VARIABLES
1753 See \fBenviron\fR(5) for descriptions of the following environment variables
1754 that affect the execution of \fBvi\fR: \fBLANG\fR, \fBLC_ALL\fR,
1755 \fBLC_COLLATE\fR, \fBLC_CTYPE\fR, \fBLC_TIME\fR, \fBLC_MESSAGES\fR,
1756 \fBNLSPATH\fR, \fBPATH\fR, \fBSHELL\fR, and \fBTERM\fR.
1763 Override the system-selected horizontal screen size.
1772 Determine a list of \fBex\fR commands that are executed on editor start-up,
1773 before reading the first file. The list can contain multiple commands by
1774 separating them using a vertical-line (\fB|\fR) character.
1783 Override the system-selected vertical screen size, used as the number of lines
1784 in a screenful and the vertical screen size in visual mode.
1791 \fB\fB/var/tmp\fR\fR
1795 default directory where temporary work files are placed; it can be changed
1796 using the \fBdirectory\fR option (see the \fBex\fR(1) command)
1802 \fB\fB/usr/share/lib/terminfo/?/*\fR\fR
1806 compiled terminal description database
1812 \fB\fB/usr/lib/.COREterm/?/*\fR\fR
1816 subset of compiled terminal description database
1822 See \fBattributes\fR(5) for descriptions of the following attributes:
1823 .SS "/usr/bin/vi, /usr/bin/view, /usr/bin/vedit"
1831 ATTRIBUTE TYPE ATTRIBUTE VALUE
1836 .SS "/usr/xpg4/bin/vi, /usr/xpg4/bin/view, /usr/xpg4/bin/vedit"
1844 ATTRIBUTE TYPE ATTRIBUTE VALUE
1848 Interface Stability Standard
1851 .SS "/usr/xpg6/bin/vi, /usr/xpg6/bin/view, /usr/xpg6/bin/vedit"
1859 ATTRIBUTE TYPE ATTRIBUTE VALUE
1863 Interface Stability Standard
1869 \fBIntro\fR(1), \fBctags\fR(1), \fBed\fR(1), \fBedit\fR(1), \fBex\fR(1),
1870 \fBattributes\fR(5), \fBenviron\fR(5), \fBlargefile\fR(5), \fBstandards\fR(5)
1873 \fISolaris Advanced User\&'s Guide\fR
1877 \fBvi\fR and \fBex\fR were developed by The University of California, Berkeley
1878 California, Computer Science Division, Department of Electrical Engineering and
1883 Two options, although they continue to be supported, have been replaced in the
1884 documentation by options that follow the Command Syntax Standard (see
1885 \fBIntro\fR(1)). An \fB-r\fR option that is not followed with an
1886 option-argument has been replaced by \fB-L\fR and \fB+\fR\fBcommand\fR has been
1887 replaced by \fB-c\fR \fBcommand\fR.
1890 The message \fBfile too large to recover with\fR \fB-r\fR \fBoption\fR, which
1891 is seen when a file is loaded, indicates that the file can be edited and saved
1892 successfully, but if the editing session is lost, recovery of the file with the
1893 \fB-r\fR option is not possible.
1896 The editing environment defaults to certain configuration options. When an
1897 editing session is initiated, \fBvi\fR attempts to read the \fBEXINIT\fR
1898 environment variable. If it exists, the editor uses the values defined in
1899 \fBEXINIT\fR; otherwise the values set in \fB$HOME/.exrc\fR are used. If
1900 \fB$HOME/.exrc\fR does not exist, the default values are used.
1903 To use a copy of \fB\&.exrc\fR located in the current directory other than
1904 \fB$HOME\fR, set the \fIexrc\fR option in \fBEXINIT\fR or \fB$HOME/.exrc\fR.
1905 Options set in \fBEXINIT\fR can be turned off in a local \fB\&.exrc\fR only if
1906 \fIexrc\fR is set in \fBEXINIT\fR or \fB$HOME/.exrc\fR. In order to be used,
1907 \fI\&.exrc\fR in \fB$HOME\fR or the current directory must fulfill these
1919 It must be owned by the same userid as the real userid of the process, or the
1920 process has appropriate privileges.
1926 It is not writable by anyone other than the owner.
1930 Tampering with entries in \fB/usr/share/lib/terminfo/?/*\fR or
1931 \fB/usr/share/lib/terminfo/?/*\fR (for example, changing or removing an entry)
1932 can affect programs such as \fBvi\fR that expect the entry to be present and
1933 correct. In particular, removing the "dumb" terminal can cause unexpected
1937 Software tabs using \fB^T\fR work only immediately after the \fIautoindent\fR.
1940 Left and right shifts on intelligent terminals do not make use of insert and
1941 delete character operations in the terminal.
1944 Loading an alternate \fBmalloc()\fR library using the environment variable
1945 \fBLD_PRELOAD\fR can cause problems for \fB/usr/bin/vi\fR.
1948 The \fBvi\fR utility currently has the following limitations:
1952 Lines, including the trailing NEWLINE character, can contain no more than
1955 If a longer line is found, \fBLine too long\fR is displayed in the status line.
1960 The editor's temporary work file can be no larger than 128Mb.
1962 If a larger temporary file is needed, \fBTmp file too large\fR is displayed in