This commit was generated by cvs2svn to track changes on a CVS vendor
[unix-history] / usr.bin / vi / vi.1
CommitLineData
0d19c241
JH
1.\" Copyright (c) 1994
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
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.
19.\"
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
30.\" SUCH DAMAGE.
31.\"
178c26c5 32.\" @(#)vi.1 8.7 (Berkeley) 1/23/94
0d19c241 33.\"
178c26c5 34.Dd "January 23, 1994"
0d19c241
JH
35.Dt EX/VI 1
36.Os
37.Sh Name
38.Nm ex, vi, view
39.Nd text editors
40.Sh SYNOPSIS
41.Nm vi
42.Op Fl eFlRv
43.Op Fl c Ar command
44.Op Fl r Ar file
45.Op Fl t Ar tag
46.Op Fl w Ar size
47.Op Fl x Ar aw
48.br
49.Nm view
50.Op Fl eFlRv
51.Op Fl c Ar command
52.Op Fl r Ar file
53.Op Fl t Ar tag
54.Op Fl w Ar size
55.Op Fl x Ar aw
56.br
57.Nm ex
58.Op Fl eFlRsv
59.Op Fl c Ar command
60.Op Fl r Ar file
61.Op Fl t Ar tag
62.Op Fl w Ar size
63.Op Fl x Ar aw
64.Sh DESCRIPTION
178c26c5 65.Nm "Ex"
0d19c241
JH
66is a line-oriented text editor.
67.Nm Vi
68is a screen oriented text editor, based on
69.Nm ex .
70.Nm View
71is the same as using the
72.Fl R
73(read-only) option of
74.Nm vi .
178c26c5 75.Nm "Ex"
0d19c241
JH
76and
77.Nm vi
78are really different interfaces to the same program,
79and it is possible to switch back and forth during the same edit session.
80.Pp
81This manual page is the one provided with the
82.Nm nex
83and
84.Nm nvi
85versions of the vi text editors.
86.Nm Nex
87and
88.Nm nvi
89are intended as bug-for-bug compatible replacements for the original
90Fourth Berkeley Software Distribution (4BSD)
91.Nm ex
92and
93.Nm vi
94programs.
95.Pp
96The following options are available:
97.Bl -tag -width indent
98.It Fl c
99Execute
100.Ar command
101immediately after starting the edit session.
102Useful for initial positioning in the file, but
103.Ar command
104is not limited to positioning commands.
105This is the POSIX 1003.2 interface for the historic
178c26c5 106.Dq "+command"
0d19c241
JH
107syntax.
108.Nm Nex/nvi
109supports both the old and new syntax.
110.It Fl e
111Start editing in ex mode, as if the command name was
112.Nm ex .
113.It Fl F
114Don't copy the entire file when first starting to edit.
115(The default is to make a copy in case someone else tries to edit
116the file too.)
117.It Fl l
118List the files that may be recovered using the
119.Fl r
120option of
121.Nm vi .
122This is the new interface for the historic
123.Fl r
124without a file argument syntax.
125.Nm Nex/nvi
126supports both the old and new syntax.
127.It Fl R
128Start editing in read-only mode, as if the command name was
129.Nm view .
130.It Fl r
131Recover the specified file.
132.It Fl s
133Enter batch mode; applicable only to
134.Nm ex
135edit sessions.
136Batch mode is useful when running
137.Nm ex
138scripts.
139Prompts, informative messages and other user oriented things are
140turned off.
141This is the POSIX 1003.2 interface for the historic
142.Fl \-
143syntax.
144.Nm Nex/nvi
145supports both the old and new syntax.
146.It Fl t
147Start editing at the specified tag.
148(See
149.Xr ctags 1 ).
150.It Fl w
151Set the initial window size to the specified number of lines.
152.It Fl v
153Start editing in vi mode, as if the command name was
154.Nm vi
155or
156.Nm view .
157.It Fl x
158Reserved for X11 interfaces.
159Not currently implemented.
160.Sh ADDITIONAL FEATURES
161This manual page is the one distributed with the
162.Nm nvi
163and
164.Nm nex
165reimplementations of
166.Nm ex/vi .
167There are a few additional features in
168.Nm nex/nvi .
169.Bl -tag -width indent
170.It "8-bit clean data, large lines, files"
171.Nm Nvi/nex
172will edit any format file.
173Line lengths are limited by available memory,
174and file sizes are limited by available disk space.
175The command
178c26c5 176.Dq "^Vx[0-9A-Fa-f]* ,"
0d19c241
JH
177in input mode, will insert any
178legal character value into the text.
179.It "Split screens"
180The command
178c26c5 181.Dq ":sp[lit] [file ...]"
0d19c241
JH
182splits the screen in vi mode.
183The key
178c26c5 184.Dq "^W"
0d19c241
JH
185switches between the foreground screens,
186and the
178c26c5 187.Dq ":resize count"
0d19c241
JH
188command can be used to grow or shrink any
189particular screen.
190.It "Background and foreground screens"
191The command
178c26c5 192.Dq ":bg"
0d19c241
JH
193backgrounds the current screen,
194and the command
178c26c5 195.Dq ":fg [file]"
0d19c241
JH
196foregrounds the backgrounded screeen
197that is editing the specified file, or, by default, the first background
198screen on the queue.
199The command
178c26c5 200.Dq ":di[splay] s[creens]"
0d19c241
JH
201lists the background screens.
202.It "Shell screens"
203The command
178c26c5 204.Dq ":sc[ript] [file ...]"
0d19c241
JH
205runs a shell in the screen.
206Editing is unchanged, with the exception that a <carriage-return>
207enters the current line (stripped of any prompt) as input to the
208shell.
209.It "Tag stacks"
210Tags are now maintained in a stack.
211The command
178c26c5 212.Dq "^T"
0d19c241
JH
213returns to the previous tag location.
214The command
178c26c5 215.Dq ":tagpop [number \| file]"
0d19c241
JH
216returns to the most recent tag
217location by default, or, optionally to a specific tag number in the
218tag stack, or the most recent tag from the specified file.
219Use the command
178c26c5 220.Dq ":di[splay] t[ags]"
0d19c241
JH
221to view the tags stack.
222The command
178c26c5 223.Dq ":tagtop"
0d19c241
JH
224returns to the top of the tag stack.
225.It "New displays"
226The command
178c26c5 227.Dq ":di[splay] b[uffers] \| s[creens] \| t[ags]"
0d19c241
JH
228can be
229used to display, respectively, the current cut buffers,
230the backgrounded screens, and the tags stack.
231.It "Infinite undo"
232The changes made during an edit session may be rolled backward and
233forward.
234A '.' command immediately after a 'u' command continues either forward
235or backward depending on whether the 'u' command was an undo or a redo.
236.It "Usage information"
237The command
178c26c5 238.Dq ":exu[sage [cmd]"
0d19c241 239and
178c26c5 240.Dq "viu[sage] [key]"
0d19c241
JH
241provide usage
242information for all of the ex and vi commands by default, or, optionally,
243for a specific command or key.
244.It "Extended regular expressions"
245The
178c26c5 246.Dq ":set extended"
0d19c241
JH
247command treats search and other command regular
248expressions as extended (egrep(1) style) regular expressions.
249.It "Word search"
250The command
178c26c5 251.Dq "^A"
0d19c241
JH
252searches for the word referenced by the cursor.
253.It "Number increment"
254The command
178c26c5 255.Dq "#"
0d19c241
JH
256increments the number referenced by the cursor.
257.It "Previous file"
258The command
178c26c5 259.Dq ":prev[ious][!]"
0d19c241
JH
260edits the previous file from the
261argument list.
262.It "Left-Right scrolling"
263The command
178c26c5 264.Dq ":set leftright"
0d19c241
JH
265makes
266.Nm nvi
267do left-right screen scrolling, instead of the traditional
268.Nm vi
269line wrapping.
270.Sh RECOVERY
271There is no recovery program for nvi, nor does it run setuid.
272Users may recover any file which they may read, and the superuser
273may recover any edit session.
274.Pp
275Edit sessions are backed by files in
276.Pa /var/tmp/vi.recover ,
277and are named
178c26c5 278.Dq "vi.XXXX" ,
0d19c241 279where
178c26c5 280.Dq "XXXX"
0d19c241
JH
281is a number related to the process id.
282When a file is first modified, a second file, which contains an
283email message for the user, is created, and is named
178c26c5 284.Dq "recover.XXXX" ,
0d19c241 285where, again,
178c26c5 286.Dq "XXXX"
0d19c241
JH
287is associated with the process id.
288Both files are removed at the end of a normal edit session,
289but will remain if the edit session is abnormally terminated
290or the user enters the ex/vi
178c26c5 291.Dq "preserve"
0d19c241
JH
292command.
293The use of the
294.Pa /var/tmp
295directory may be changed setting the option
178c26c5 296.Dq "recdir"
0d19c241
JH
297in the user's or system startup information.
298.Pp
299The recovery directory should have the
178c26c5 300.Dq "sticky-bit"
0d19c241
JH
301set so that only the owners of files may remove them.
302If this is not possible on the system, then a pseudo-user should
303own the recovery directory.
304The recovery directory must be both read and write-able by
305any user.
306.Pp
307The recovery file has all of the necessary information in it to enable the
308user to recover the edit session.
309In addition, it has all of the necessary email headers for sendmail.
310When the system is rebooted, all of the files in
311.Pa /var/tmp/vi.recover
312named
178c26c5 313.Dq "recover.XXXX"
0d19c241
JH
314should be sent by email,
315using the
316.Fl t
317flag of sendmail (or a similar mechanism in other mailers).
318A simple way to do this is to insert the following script into your
178c26c5 319rc.local (or other startup) file:
0d19c241
JH
320.sp
321.ne 7v
322.Bd -literal -offset indent -compact
323# Recover nvi editor files.
324virecovery=/var/tmp/vi.recover/recover.*
178c26c5 325if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
0d19c241
JH
326 echo 'Recovering vi editor sessions'
327 for i in $virecovery; do
328 sendmail -t < $i
329 done
178c26c5 330fi
0d19c241
JH
331.Ed
332.Pp
333If
334.Nm nex/nvi
335receives a hangup (SIGHUP) signal, it will email the recovery
336information to the user itself.
337.Pp
338If you don't have the sendmail program on your system, the source file
339.Pa nvi/recover.c
340will have to be modified to use your mail delivery programs.
341.Sh BUGS
342This man page is woefully incomplete.
343.Pp
344Many and varied.
345See the file
178c26c5 346.Pa nvi/docs/bugs.current
0d19c241
JH
347for a list of the known bugs in this version.
348.Sh FILES
349.Bl -tag -width XXXX/var/tmp/vi.recover -compact
350.It Pa /tmp
351Storage for temporary files.
352.It Pa /var/tmp/vi.recover
353Storage for recovery files.
354.El
355.Sh SEE ALSO
356.Xr ctags 1 ,
357.Xr more 1 ,
358.Xr curses 3 ,
359.Xr dbopen 3
360.sp
361The
178c26c5 362.Dq "Vi Quick Reference"
0d19c241
JH
363card.
364.sp
178c26c5 365.Dq "An Introduction to Display Editing with Vi" ,
0d19c241 366found in the
178c26c5 367.Dq "UNIX User's Manual Supplementary Documents" .
0d19c241 368.sp
178c26c5 369.Dq "Edit: A tutorial" ,
0d19c241 370found in the
178c26c5 371.Dq "UNIX User's Manual Supplementary Documents" .
0d19c241 372.sp
178c26c5 373.Dq "Ex Reference Manual (Version 3.7)" ,
0d19c241 374found in the
178c26c5
JH
375.Dq "UNIX User's Manual Supplementary Documents" .
376.Pp
377.Nm Nroff/troff
378source for the previous three documents are distributed with
379.Nm nex/nvi
380in the
381.Pa nvi/docs/USD.doc
382directory of the
383.Nm nex/nvi
384source code.
0d19c241
JH
385.sp
386The files
178c26c5
JH
387.Dq "autowrite" ,
388.Dq "input" ,
0d19c241 389and
178c26c5 390.Dq "quoting" ,
0d19c241
JH
391found in the
392.Pa nvi/docs
393directory of the
394.Nm nex/nvi
395source code.
396.Sh HISTORY
397The
398.Nm nex/nvi
399replacements for
400.Nm ex/vi
401first appeared in 4.4BSD.
402.Sh STANDARDS
403.Nm Nex/nvi
404is fairly close to IEEE Std1003.2 (``POSIX''), but it's
405not there yet.