2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)vi.ref 8.19 (Berkeley) 3/18/94
35 .Dt "EX/VI REFERENCE MANUAL" 1
42 is a screen oriented text editor.
44 is a line-oriented text editor.
48 are different interfaces to the same program,
49 and it is possible to switch back and forth during an edit session.
51 is the equivalent of using the
56 This reference manual is the one provided with the
62 are intended as bug-for-bug compatible replacements for the original
63 Fourth Berkeley Software Distribution (4BSD)
68 This reference manual is accompanied by a traditional-style manual page.
69 That manual page describes the functionality found in
71 in far less detail than the description here.
72 In addition, it describes the system interface to
74 e.g. command line options, environmental variables, and similar things.
76 This reference is intended for users already familiar with
78 Anyone else should almost certainly read a good tutorial on the
80 If you're in an unfamiliar environment, and you absolutely have to
81 get work done immediately, see the section entitled FAST STARTUP
83 It's probably enough to get you going.
85 For the rest of this reference,
87 is used only when it's necessary to distinguish it from the historic
90 .Sh ADDITIONAL FEATURES
91 There are a few features in
93 that are not found in historic versions of
95 A list of those features is as follows:
96 .Bl -tag -width indent
97 .It "8-bit clean data, large lines, files"
99 will edit any format file.
100 Line lengths are limited by available memory,
101 and file sizes are limited by available disk space.
103 .Dq "^Vx[0-9A-Fa-f]* ,"
104 in input mode, will insert any
105 legal character value into the text.
108 .Dq ":sp[lit] [file ...]"
109 splits the screen in vi mode.
112 switches between the foreground screens,
115 command can be used to grow or shrink a particular screen.
116 .It "Background and foreground screens"
119 backgrounds the current screen,
122 foregrounds the backgrounded screen
123 that is editing the specified file, or, by default, the first background
126 .Dq ":di[splay] s[creens]"
127 lists the background screens.
130 .Dq ":sc[ript] [file ...]"
131 runs a shell in the screen.
132 Editing is unchanged, with the exception that a <carriage-return>
133 enters the current line (stripped of any prompt) as input to the
136 Tags are now maintained in a stack.
139 returns to the previous tag location.
141 .Dq ":tagpop [number \| file]"
142 returns to the most recent tag
143 location by default, or, optionally to a specific tag number in the
144 tag stack, or the most recent tag from the specified file.
146 .Dq ":di[splay] t[ags]"
147 to view the tags stack.
150 returns to the top of the tag stack.
153 .Dq ":di[splay] b[uffers] \| s[creens] \| t[ags]"
155 used to display, respectively, the current cut buffers,
156 the backgrounded screens, and the tags stack.
158 The changes made during an edit session may be rolled backward and
160 A '.' command immediately after a 'u' command continues either forward
161 or backward depending on whether the 'u' command was an undo or a redo.
162 .It "Usage information"
164 .Dq ":exu[sage] [cmd]"
166 .Dq "viu[sage] [key]"
168 information for all of the ex and vi commands by default, or, optionally,
169 for a specific command or key.
170 .It "Extended regular expressions"
173 command treats search and other command regular
174 expressions as extended (egrep(1) style) regular expressions.
178 searches for the word referenced by the cursor.
179 .It "Number increment"
182 increments the number referenced by the cursor.
186 edits the previous file from the
188 .It "Left-Right scrolling"
193 do left-right screen scrolling, instead of the traditional
197 There is no recovery program for
202 Users may recover any file which they may read, and the superuser
203 may recover any edit session.
205 Edit sessions are backed by files in
206 .Pa /var/tmp/vi.recover ,
211 is a number related to the process id.
212 When a file is first modified, a second file, which contains an
213 email message for the user, is created, and is named
217 is associated with the process id.
218 Both files are removed at the end of a normal edit session,
219 but will remain if the edit session is abnormally terminated
220 or the user enters the ex/vi
225 directory may be changed setting the
227 option in the user's or system startup information.
229 The recovery directory should have the
231 set so that only the owners of files may remove them.
232 If this is not possible on the system, then a pseudo-user should
233 own the recovery directory.
234 The recovery directory must be both read and write-able by
237 The recovery file has all of the necessary information in it to enable the
238 user to recover the edit session.
239 In addition, it has all of the necessary email headers for sendmail.
240 When the system is rebooted, all of the files in
241 .Pa /var/tmp/vi.recover
244 should be sent by email,
247 flag of sendmail (or a similar mechanism in other mailers).
248 A simple way to do this is to insert the following script into your
250 (or other startup) file:
252 .Bd -literal -offset indent -compact
253 # Recover nvi editor files.
254 virecovery=`echo /var/tmp/vi.recover/recover.*`
255 if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
256 echo 'Recovering vi editor sessions'
257 for i in $virecovery; do
265 receives a hangup (SIGHUP) signal, it will email the recovery
266 information to the user itself.
268 If you don't have the sendmail program on your system, the source file
270 will have to be modified to use your local mail delivery programs.
271 .Sh STARTUP INFORMATION
273 interprets one of two possible environmental variables and reads up
274 to three of five possible files during startup.
275 The variables and files are expected to contain
280 In addition, they are interpreted
282 the file to be edited is read, and therefore many
284 commands may not be used.
285 Generally, any command that requires output to the screen or that
286 needs a file upon which to operate, will cause an error if included
287 in a startup file or environmental variable.
292 Second, the environmental variable
298 isn't set) is interpreted.
309 doesn't exist) is read.
316 doesn't exist) is read.
318 Startup files will not be read if they are owned by anyone other
319 than the real user-id of the user running
323 in the case of the file
325 or if they are writable by anyone other than the owner.
326 Home directory startup files (i.e.
330 will not be read if the
332 environmental variable is not set.
333 Local startup files (i.e.
337 will not be read if the
339 option is turned off in the
348 environmental variables.
349 It is not an error for any of the startup environmental variables
350 or files not to exist.
354 command set supported by
356 is a superset of the command set supported by most historical implementations
360 can use the startup files created for the historical implementations,
361 but the converse is often not true.
362 .Sh SIZING THE SCREEN
363 The size of the screen can be set in a number of ways.
365 takes the following steps until values are obtained for both the
366 number of rows and number of columns in the screen.
370 If the environmental variable
372 exists, it is used to specify the number of rows in the screen.
374 If the environmental variable
376 exists, it is used to specify the number of columns in the screen.
380 is attempted on the standard error file descriptor.
382 The termcap entry is checked for the
388 The number of rows is set to 24, and the number of columns is set
392 If a window change size signal (SIGWINCH) is received,
393 the same steps are taken with the exception that the first two steps
395 .Sh REGULAR EXPRESSIONS AND REPLACEMENT STRINGS
396 Regular expressions are used in line addresses,
403 and in search patterns.
405 The regular expressions supported by
409 are, by default, the Basic Regular Expressions (BRE's) described in the
410 IEEE POSIX Standard 1003.2.
413 option causes all regular expressions to be interpreted as the Extended
414 Regular Expressions (ERE's) described by the same standard.
417 for more information.
418 Generally speaking, BRE's are
422 style regular expressions, and ERE's are
424 style regular expressions.)
426 There are some special strings and characters that can be used in
432 is equivalent to the last RE used.
436 matches the beginning of a word.
440 matches the end of a word.
444 matches the replacement part of the last
454 the only characters with special meanings are
456 at the beginning of an RE,
458 at the end of an RE, and the escaping character
466 are treated as ordinary characters unless preceded by a
470 they regain their special meaning.
472 Replacement strings are the second part of a
484 set) in the replacement string stands for the text matched by the RE
485 that's being replaced.
494 set) stands for the replacement part of the previous
502 is an integer value from 1 to 9, stands for the text matched by
503 the portion of the RE enclosed in the #'th set of escaped parentheses,
509 .Dq "s/abc\e(.*\e)def/\e1/"
514 from the matched pattern.
522 can be used to modify the case of elements in the replacement string.
525 causes the next character to be converted to lowercase; the string
527 behaves similarly, but converts to uppercase.
530 causes characters up to the end of the string or the next occurrence of
535 to be converted to lowercase; the string
537 behaves similarly, but converts to uppercase.
541 inserting a <control-M> into the replacement string will cause the
542 matched line to be split into two lines at that point.
544 #include <set.opt.roff>