nvi/nex 1.11beta from bostic.

This commit is contained in:
cgd 1994-03-28 02:52:06 +00:00
parent e075c679c6
commit 6f5fcc76ef
19 changed files with 5730 additions and 521 deletions

View File

@ -1,12 +1,13 @@
# @(#)README 8.42 (Berkeley) 1/23/94
# @(#)README 8.54 (Berkeley) 3/24/94
This is the README for version 1.03 of nvi, a freely redistributable
replacement for the vi and ex text editors. It can be retrieved via
anonymous ftp from ftp.uu.net, or from ftp.cs.berkeley.edu. In the
latter, it is in the directory ucb/4bsd, and is named nvi.tar.Z.
This is the README for version 1.11 of nex/nvi, a freely redistributable
replacement for the Berkeley ex and vi text editors. The compressed tar
archive can be retrieved by anonymous ftp from ftp.cs.berkeley.edu, from
the file ucb/4bsd/nvi.tar.Z. There is a gzip'd tar archive, nvi.tar.z,
in the same directory.
If you have any questions or problems with nvi, please send them to
me by electronic mail at one of the following addresses:
If you have any questions about nvi, or problems making it work, please
contact me by electronic mail at one of the following addresses:
uunet!bostic
bostic@cs.berkeley.edu
@ -16,12 +17,12 @@ Keith Bostic
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
o Redistribution:
Nvi is copyrighted by the The Regents of the University of California,
but may be freely redistributed (or used to line your birdcage) under
the following conditions:
This software is copyrighted by the The Regents of the University of
California, but may be freely redistributed (or sold, or used to line
your birdcage) under the following conditions:
/*-
* Copyright (c) 1994
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -77,99 +78,82 @@ o From the original vi acknowledgements, by William Joy and Mark Horton:
work on a large number of terminals and Unix systems.
o And...
The financial support of UUNET Communications Services is gratefully
acknowledged.
=-=-=-=-=-=-=-=-=-=-=
o Comments:
o Status:
This software is beta software, although it's pretty stable. Almost
of the necessary functionality for ex/vi is in it, the only missing
pieces are fairly obscure.
Code fixes are very much appreciated, of course, but if you can't
provide them, please send me as much information as you can as to how
to reproduce the bug, and I'll try to fix it here. In particular, the
screen routines are nasty stuff, and you probably don't want to mess
with them. Stack traces of core dumps are sometimes helpful, but an
example file with a set of keystrokes that causes the problem is far
better.
This software is in beta test, and it's believed to be pretty stable.
Almost all of the historic functionality in ex/vi is there, the missing
pieces are fairly obscure. In particular, the edcompatible, hardtabs*,
lisp*, optimize*, redraw*, and slowopen* options are recognized, but not
implemented.
Nvi is mostly 8-bit clean. This isn't difficult to fix, and was left in
during initial development to make things easier. Wide character support
will be integrated at the same time it is made fully 8-bit clean.
=-=-=-=-=-=-=-=-=-=-=
o New features:
There aren't a lot of new features in nex/nvi, but there are a few things
you might like:
o 8-bit clean data, practically infinite lines/files.
^Vx[0-9A-Fa-f]* in input mode will insert any
legal character value.
o Split screens:
:sp[lit] [file ...] splits the screen.
^W switches between screens.
:resize count grows/shrinks the current screen.
o Background/foreground screens
:bg backgrounds the current screen.
:di[splay] s[creens] lists the hidden screens.
:fg [file] foregrounds the specified (or next) screen.
o Shell screens:
:sc[ript] [file ...] runs a shell in the screen.
Carriage return sends a line to the shell.
o Buffer, screens, tags display:
:di[splay] b[uffers] displays the current cut buffers.
:di[splay] s[creens] displays the hidden screen names.
:di[splay] t[ags] displays the current tags stack.
o Tag stacks:
^T returns to previous tag location.
:tagpop [number | file] returns to previous tag location,
or, optionally tag #N, or the tag in a specific file.
:tagtop returns to first tag location.
o Infinite undo:
A '.' command immediately after a 'u' command continues
either forward or backward depending on whether the 'u'
command was an undo or a redo.
o Usage information:
:exu[sage] [cmd] for ex commands.
:viu[sage] [key] for vi commands.
:help
o Extended RE expressions:
:set extended turns on extended RE's, so you can
do "/in|or" and search for the next occurrence of
more than one expression.
o Word search:
^A searches for the word referenced by the cursor.
o Number increment:
# increments the number referenced by the cursor.
o Previous file:
:prev[ious][!] edits the previous file from the
argument list.
you might like. See the "ADDITIONAL FEATURES" section of the manual page
(docs/vi.0.txt, docs/vi.0.ps) for a list.
=-=-=-=-=-=-=-=-=-=-=
o Porting information:
The directory PORT has directories per machine/OS combination, with
V7-style Makefiles which build nvi. See the file PORT/README for
more detailed information.
The directory PORT has directories per OS/machine combination, with
V7-style Makefiles which build nex/nvi. See the file PORT/README for
detailed information.
=-=-=-=-=-=-=-=-=-=-=
o Directories:
o Bug reports:
The main directory, nvi, contains source files for pieces of code that
are shared by all the editors, like searching and logging code or code
translating line numbers into requests to the dbopen(3) database code.
It also has the code for adding, deleting, and changing "records" in
the underlying database.
Code fixes are appreciated, of course, but if you can't provide them,
please email me as much information as you can as to how to reproduce
the bug, and I'll try to fix it locally. In particular, the screen
routines are nasty stuff, and you probably don't want to mess with them.
Stack traces of core dumps are sometimes helpful, but an example file
with a set of keystrokes that causes the problem is far better. Also,
make sure that you include the dimensions of the screen on which the
problem occurred, your startup files (.exrc, .nexrc), and the environment
variable (EXINIT, NEXINIT) values.
=-=-=-=-=-=-=-=-=-=-=
o Layout:
nvi:
Source files for pieces of code that are shared by all the
editors, like searching and logging code or code translating
line numbers into requests to the dbopen(3) database code.
It also has the code for adding, deleting, and changing "records"
in the underlying database.
nvi/PORT:
Porting directories, one per OS/architecture combination. See
nvi/PORT/README for porting information.
nvi/docs:
The nvi/docs directory has technical information about data
structures and some of the trickier parts of vi like quoting,
key mapping, input queues, and executing buffers, and a
description of how nvi does edit session recovery.
The nvi/docs directory has all of the nvi documentation:
README -- Nvi main README file.
USD.doc -- Historic vi documentation (in roff source form).
bugs.current -- Known bugs in the current nvi implementation.
changelog -- Log of changes from version to version.
features -- Todo list, suggested features list.
internals/
autowrite -- Vi autowrite option discussion.
gdb.script -- GDB debugging scripts.
input -- Vi maps, executable buffers, and input discussion.
quoting -- Vi quoting discussion.
structures -- Nvi internal structure description.
spell.ok -- Misspellings list for README, vi.1.
tutorial -- Historic vi tutorial
vi.0.ps -- PostScript of vi.1.
vi.0.txt -- Flat text of vi.1.
vi.1 -- Nvi man page (in roff source form).
vi.ref -- Nvi reference (in roff source form).
vi.ref.ps -- PostScript of vi.ref.
vi.ref.txt -- Flat text of vi.ref.
nvi/ex:
The nvi/ex directory is the ex source code. Because vi has the

View File

@ -1,5 +1,9 @@
List of known bugs:
+ Large numbers of matches (e.g. %, g or v commands), with the
ignorecase option set, triggers a memory corruption bug in the
regex routines.
+ Autoindent doesn't work in the ex editor.
+ ^C isn't passed to the shell in the script windows as an interrupt
@ -14,7 +18,8 @@ List of known bugs:
+ The options edcompatible, hardtabs*, lisp*, optimize*, redraw*,
and slowopen* are recognized, but not implemented. Options with
an asterisk are unlikely to ever be implemented, so if you want
them you might want to say something!
them you might want to say something! I will implement lisp if
anyone ever documents how it really worked.
+ Screen repainting over slow lines, for some screen changes, is not
as good as the historic vi's.
@ -25,13 +30,9 @@ List of known bugs:
+ If the ex append command is used from vi, the input command buffer
is overwritten by the ex_append function, causing random errors.
+ The "b" command stops at every empty line.
+ Colon commands longer than a single line cause the display to be
incorrect.
+ Left-right scrolling is currently broken.
+ When switching files in a small screen (O_WINDOW) with :e, the status
message isn't displayed.

View File

@ -1,4 +1,95 @@
1.01 -> 1.03:
1.10 -> 1.11: Thu Mar 24 16:07:45 EST 1994
+ Change H, M, and L to set the absolute mark, historical practice.
+ Fix bug in stepping through multiple tags files.
+ Add "remapmax" option that turns off map counts so you can remap
infinitely. If it's off, term_key() can be interrupted from the
keyboard, which will cause the buffers to flush. I also dropped
the default max number of remaps to 50. (Only Dave Hitz's TM
macros and maze appear to go over that limit.)
+ Change :mkexrc to not dump w{300,1200,9600}, lisp options.
+ Fix backward search within a line bug.
+ Change all the includes of "pathnames.h" to use <>'s so that the
PORT versions can use -I. to replace it with their own versions.
+ Make reads and writes interruptible. Rework code that enters and
leaves ex for '!' and filter commands, rework all interrupt and
timer code.
+ Fix core dump when user displayed option in .exrc file.
+ Fix bug where writing empty files didn't update the saved
modification time.
+ Fix bug where /pattern/ addressing was always a backward search.
+ Fix bug triggered by autoindent of more than 32 characters, where
nvi wasn't checking the right TEXT length.
+ Fix bug where joining only empty lines caused a core dump.
1.09 -> 1.10: Sat Mar 19 15:40:29 EST 1994
+ Fix "set all" core dump.
1.08 -> 1.09: Sat Mar 19 10:11:14 EST 1994
+ If the tag's file path is relative, and it doesn't exist, check
relative to the tag file location.
+ Fix ~ command to free temporary buffer on error return.
+ Create vi.ref, a first cut at a reference document for vi.
The manual page and the reference document only document the
set options, so far.
+ Fix 1G bug not always going to the first non-blank.
+ Upgrade PORT/regex to release alpha3.4, from Henry Spencer.
+ Add MKS vi's "cdpath" option, supporting a cd search path.
+ Handle if search as a motion was discarded, i.e. "d/<erase>".
+ Change nvi to not create multiple recovery files if modifying
a recovered file.
+ Decide to ignore that the cursor is before the '$' when inserting
in list mode. It's too hard to fix.
1.07 -> 1.08: Wed Mar 16 07:37:36 EST 1994
+ Leftright and big line scrolling fixes. This meant more changes
to the screen display code, so there may be new problems.
+ Don't permit search-style addresses until a file has been read.
+ "c[Ww]" command incorrectly handled the "in whitespace" case.
+ Fix key space allocation bug triggered by cut/paste under SunOS.
+ Ex move command got the final cursor position wrong.
+ Delete "optimize option not implemented" message.
+ Make the literal-next character turn off mapping for the next
character in text input mode.
1.06 -> 1.07: Mon Mar 14 11:10:33 EST 1994
+ The "wire down" change in 1.05 broke ex command parsing, there
wasn't a corresponding change to handle multiple K_VLNEXT chars.
+ Fix final position for vi's 't' command.
1.05 -> 1.06: Sun Mar 13 16:12:52 EST 1994
+ Wire down ^D, ^H, ^W, and ^V, regardless of the user's termios
values.
+ Add ^D as the ex scroll command.
+ Support ^Q as a literal-next character.
+ Rework abbreviations to be delimited by any !inword() character.
+ Add options description to the manual page.
+ Minor screen cache fix for svi_get.c.
+ Rework beautify option support to match historical practice.
+ Exit immediately if not reading from a tty and a command fails.
+ Default the SunOS 4.* ports to the distributed curses, not SMI's.
1.04 -> 1.05: Thu Mar 24 16:07:45 EST 1994
+ Make cursor keys work in input mode.
+ Rework screen column code in vi curses screen. MAJOR CHANGE --
after this, we'll be debugging curses screen presentation from
scratch.
+ Explode include files in vi.h into the source files.
1.03 -> 1.04: Sun Mar 6 14:14:16 EST 1994
+ Make the ex move command keep the marks on the moved lines.
+ Change resize semantics so you can set the screen size to a
specific value. A couple of screen fixes for the resize code.
+ Fixes for foreground/background due to SIGWINCH.
+ Complete rework of all of vi's cursor movements. The underlying
assumption in the old code was that the starting cursor position
was part of the range of lines cut or deleted. The command
"d[[" is an example where this isn't true. Change it so that all
motion component commands set the final cursor position separately
from the range, as it can't be done correctly later. This is a
MAJOR CHANGE -- after this change, we'll be debugging the cursor
positioning from scratch.
+ Rewrite the B, b, E, e commands to use vi's getc() interface
instead of rolling their own.
+ Add a second MARK structure, LMARK, which is the larger mark
needed by the logging and mark queue code. Everything else uses
the reworked MARK structure, which is simply a line/column pair.
+ Rework cut/delete to not expect 1-past-the-end in the range, but
to act on text to the end of the range, inclusive.
+ Sync on write's, to force NFS to flush.
1.01 -> 1.03: Sun Jan 23 17:50:35 EST 1994 (PUBLICLY AVAILABLE VERSION)
+ Tag stack fixes, was returning to the tag, not the position from
which the user tagged.
+ Only use from the cursor to the end of the word in cursor word
@ -11,17 +102,37 @@
+ Fix for multiple error messages if no screen displayed.
+ Fix :read to set alternate file name as in historical practice.
+ Fix cut to rotate the numeric buffers if line mode flag set.
1.00 -> 1.01
1.00 -> 1.01: Wed Jan 12 13:37:18 EST 1994
+ Don't put cut items into numeric buffers if cutting less than
parts of two lines.
0.94 -> 1.00
0.94 -> 1.00: Mon Jan 10 02:27:27 EST 1994
+ Read-ahead not there; BSD tty driver problem, SunOS curses
problem.
+ Global command could error if it deleted the last line of
the file.
+ Change '.' to only apply to the 'u' if entered immediately
after the 'u' command. "1pu.u.u. is still broken.
after the 'u' command. "1pu.u.u. is still broken, but I
expect that it's going to be sacrificed for multiple undo.
+ If backward motion on a command, now move to the point; get
yank cursor positioning correct.
+ Rework cut buffers to match historic practice -- yank/delete
numeric buffers redone sensibly, ignoring historic practice.
0.92 -> 0.93: Mon Dec 20 19:52:14 EST 1993
+ Christos Zoulas reimplemented the script windows using pty's,
which means that they now work reasonably. The down side of
this is that almost all ports other than 4.4BSD need to include
two new files, login_tty.c and pty.c from the PORT/clib directory.
I've added them to the Makefiles.
+ All calloc/malloc/realloc functions now cast their pointers, for
SunOS -- there should be far fewer warning messages, during the
build. The remaining messages are where CHAR_T's meet char *'s,
i.e. where 8-bit clean meets strcmp.
+ The user's argument list handling has been reworked so that there
is always a single consistent position for use by :next, :prev and
:rewind.
+ All of the historical options are now at least accepted, although
not all of them are implemented. (Edcompatible, hardtabs, lisp,
optimize, redraw, and slowopen aren't implemented.)
+ The RE's have been reworked so that matches of length 0 are handled
in the same way as vi used to handle them.
+ Several more mapping fixes and ex parser addressing fixes.

47
usr.bin/vi/docs/features Normal file
View File

@ -0,0 +1,47 @@
List of things that should be added at some point:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ X11 interface.
+ Forms editing package; use RE's to verify field contents.
+ Internationalization, including wide character support.
+ Make db, curses real libraries that we load against instead of
compiling directly.
+ Add a ":resize =N" command, that sets the window to a specific
size.
List of suggested features:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ Change tags to also attempt to find the file using the directory
where it found the tags file.
+ Add versioning based on a "set version" variable, that would
create backup copies when the file was written back, i.e. the
":w" and autowrite's would copy the original.
+ Add "set searchdir" for a list of directories to look in for
files to edit. The semantic is that ":e foo" is replaced with
the file name that is found, so there's no confusion as to
which file is written.
+ Change
:di[splay] tags -> :tags
:di[splay] screens -> :screens
:di[splay] buffers -> :buffers
+ A macro record function. Add the ability to record a sequence
of keystrokes into a named buffer for later use. Handy when
you're trying to build a semi-complex macro.
+ Put multiple messages on a single line if they fit in their entirety,
so that ":n" with autowrite set doesn't force users to hit return to
get see both the "written" and "new file status" messages.
+ The semantics of :split, :bg, and :fg aren't right. Someone needs to
rethink how they should interact. The main problem arises when users
want to get a window into a new file. Currently, the necessary sequence
is ":split newfile|^W|:bg". It would be nice if you could simply
background the current screen and edit a new one.

View File

@ -0,0 +1,88 @@
# @(#)autowrite 8.2 (Berkeley) 9/28/93
Vi autowrite behavior, the fields with *'s are "don't cares".
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Commands that are affected only by autowrite:
Command File Autowrite? Action:
modified?
-----------------------------------------------
^Z Y Y Write file and suspend.
^Z Y N Suspend.
^Z N * Suspend.
# This behavior is NOT identical to :edit.
^ Y Y Write file and jump.
^ Y N Error.
^ N * Jump.
# The new nvi command ^T (:tagpop) behaves identically to ^].
# This behavior is identical to :tag, :tagpop, and :tagpush with
# force always set to N.
^] Y Y Write file and jump.
^] Y N Error.
^] N * Jump.
# There's no way to specify a force flag to the '!' command.
:! Y Y Write file and execute.
:! Y N Warn (if warn option) and execute.
:! N * Execute.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Commands that are affected by both autowrite and force:
NOTE: the "force" flag is never passed on, i.e. the write
to the file caused by the autowrite flag is never forced.
Command File Autowrite? Force? Action:
modified? (!)
-------------------------------------------------------
# The first rule (YYY) is historic practice, but seems wrong.
# In nvi, :next and :prev commands behave identically to :rewind.
:next Y Y Y Write changes and jump.
:next Y Y N Write changes and jump.
:next Y N Y Abandon changes and jump.
:next Y N N Error.
:next N * * Jump.
:rewind Y Y Y Abandon changes and jump.
:rewind Y Y N Write changes and jump.
:rewind Y N Y Abandon changes and jump.
:rewind Y N N Error.
:rewind N * * Jump.
# The new nvi commands, :tagpop and :tagtop, behave identically to :tag.
# Note, this behavior is the same as :rewind and friends, as well.
:tag Y Y Y Abandon changes and jump.
:tag Y Y N Write changes and jump.
:tag Y N Y Abandon changes and jump.
:tag Y N N Error.
:tag N * * Jump.
# The command :suspend behaves identically to :stop.
:stop Y Y Y Suspend.
:stop Y Y N Write changes and suspend.
:stop Y N Y Suspend.
:stop Y N N Suspend.
:stop N * * Suspend.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Commands that might be affected by autowrite, but aren't:
Command File Autowrite? Force? Action:
modified? (!)
-------------------------------------------------------
#:ex, and :vi (executed while in vi mode) behave identically to :edit.
:edit Y * Y Abandon changes and jump.
:edit Y * N Error.
:edit N * * Jump.
:quit Y * Y Quit.
:quit Y * N Error.
:quit N * * Quit.
:shell * * * Execute shell.
:xit Y * * Write changes and exit.
:xit N * * Exit.

View File

@ -0,0 +1,68 @@
# @(#)gdb.script 8.2 (Berkeley) 9/29/93
# display the SVI screen map
# usage dmap(sp)
define dmap
set $h = ((SVI_PRIVATE *)$arg0->svi_private)->h_smap
set $t = ((SVI_PRIVATE *)$arg0->svi_private)->t_smap
while ($h <= $t)
printf "lno: %d; off %d ", (int)$h->lno, (int)$h->off
if ($h->c_ecsize == 0)
printf "flushed\n"
else
printf "\n\tsboff %d; scoff %d\n", \
(int)$h->c_sboff, (int)$h->c_scoff
printf "\teboff %d; eclen %d; ecsize %d\n", \
(int)$h->c_eboff, (int)$h->c_eclen, \
(int)$h->c_ecsize
end
set $h = $h + 1
end
end
# display the tail of the SVI screen map
define tmap
set $h = ((SVI_PRIVATE *)$arg0->svi_private)->h_smap
set $t = ((SVI_PRIVATE *)$arg0->svi_private)->t_smap
while ($t >= $h)
printf "lno: %d; off %d ", (int)$t->lno, (int)$t->off
if ($t->c_ecsize == 0)
printf "flushed\n"
else
printf "\n\tsboff %d; scoff %d\n", \
(int)$t->c_sboff, (int)$t->c_scoff
printf "\teboff %d; eclen %d; ecsize %d\n", \
(int)$t->c_eboff, (int)$t->c_eclen, \
(int)$t->c_ecsize
end
set $t = $t - 1
end
end
# display the SVI private structure
define svp
print *((SVI_PRIVATE *)sp->svi_private)
end
# display the marks
define markp
set $h = sp->ep->marks.next
set $t = &sp->ep->marks
while ($h != 0 && $h != $t)
printf "key %c lno: %d cno: %d flags: %x\n", \
((MARK *)$h)->name, ((MARK *)$h)->lno, \
((MARK *)$h)->cno, ((MARK *)$h)->flags
set $h = ((MARK *)$h)->next
end
end
# display the tags
define tagp
set $h = sp->taghdr.next
set $t = &sp->taghdr
while ($h != 0 && $h != $t)
printf "tag: %s lno %d cno %d\n", ((TAG *)$h)->frp->fname, \
((TAG *)$h)->lno, ((TAG *)$h)->cno
set $h= ((TAG *)$h)->next
end
end

View File

@ -0,0 +1,314 @@
# @(#)input 5.4 (Berkeley) 8/26/93
MAPS, EXECUTABLE BUFFERS AND INPUT IN EX/VI:
The basic rule is that input in ex/vi is a stack. Every time a key which
gets expanded is encountered, it is expanded and the expansion is treated
as if it were input from the user. So, maps and executable buffers are
simply pushed onto the stack from which keys are returned. The exception
is that if the "remap" option is turned off, only a single map expansion
is done. I intend to be fully backward compatible with this.
Historically, if the mode of the editor changed (ex to vi or vice versa),
any queued input was silently discarded. I don't see any reason to either
support or not support this semantic. I intend to retain the queued input,
mostly because it's simpler than throwing it away.
Historically, neither the initial command on the command line (the + flag)
or the +cmd associated with the ex and edit commands was subject to mapping.
Also, while the +cmd appears to be subject to "@buffer" expansion, once
expanded it doesn't appear to work correctly. I don't see any reason to
either support or not support these semantics, so, for consistency, I intend
to pass both the initial command and the command associated with ex and edit
commands through the standard mapping and @ buffer expansion.
One other difference between the historic ex/vi and nex/nvi is that nex
displays the executed buffers as it executes them. This means that if
the file is:
set term=xterm
set term=yterm
set term=yterm
the user will see the following during a typical edit session:
nex testfile
testfile: unmodified: line 3
:1,$yank a
:@a
:set term=zterm
:set term=yterm
:set term=xterm
:q!
This seems like a feature and unlikely to break anything, so I don't
intend to match historic practice in this area.
The rest of this document is a set of conclusions as to how I believe
the historic maps and @ buffers work. The summary is as follows:
1: For buffers that are cut in "line mode", or buffers that are not cut
in line mode but which contain portions of more than a single line, a
trailing <newline> character appears in the input for each line in the
buffer when it is executed. For buffers not cut in line mode and which
contain portions of only a single line, no additional characters
appear in the input.
2: Executable buffers that execute other buffers don't load their
contents until they execute them.
3: Maps and executable buffers are copied when they are executed --
they can be modified by the command but that does not change their
actions.
4: Historically, executable buffers are discarded if the editor
switches between ex and vi modes.
5: Executable buffers inside of map commands are expanded normally.
Maps inside of executable buffers are expanded normally.
6: If an error is encountered while executing a mapped command or buffer,
the rest of the mapped command/buffer is discarded. No user input
characters are discarded.
Individual test cases follow. Note, in the test cases, control characters
are not literal and will have to be replaced to make the test cases work.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1: For buffers that are cut in "line mode", or buffers that are not cut
in line mode but which contain portions of more than a single line, a
trailing <newline> character appears in the input for each line in the
buffer when it is executed. For buffers not cut in line mode and which
contain portions of only a single line, no additional characters
appear in the input.
=== test file ===
3Gw
w
line 1 foo bar baz
line 2 foo bar baz
line 3 foo bar baz
=== end test file ===
If the first line is loaded into 'a' and executed:
1G"ayy@a
The cursor ends up on the '2', a result of pushing "3Gw^J" onto
the stack.
If the first two lines are loaded into 'a' and executed:
1G2"ayy@a
The cursor ends up on the 'f' in "foo" in the fifth line of the
file, a result of pushing "3Gw^Jw^J" onto the stack.
If the first line is loaded into 'a', but not using line mode,
and executed:
1G"ay$@a
The cursor ends up on the '1', a result of pushing "3Gw" onto
the stack
If the first two lines are loaded into 'a', but not using line mode,
and executed:
1G2"ay$@a
The cursor ends up on the 'f' in "foo" in the fifth line of the
file, a result of pushing "3Gw^Jw^J" onto the stack.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
2: Executable buffers that execute other buffers don't load their
contents until they execute them.
=== test file ===
cwLOAD B^[
line 1 foo bar baz
line 2 foo bar baz
line 3 foo bar baz
@a@b
"byy
=== end test file ===
The command is loaded into 'e', and then executed. 'e' executes
'a', which loads 'b', then 'e' executes 'b'.
5G"eyy6G"ayy1G@e
The output should be:
=== output file ===
cwLOAD B^[
LOAD B 1 foo bar baz
line 2 foo bar baz
line 3 foo bar baz
@a@b
"byy
=== end output file ===
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
3: Maps and executable buffers are copied when they are executed --
they can be modified by the command but that does not change their
actions.
Executable buffers:
=== test file ===
line 1 foo bar baz
line 2 foo bar baz
line 3 foo bar baz
@a@b
"eyy
cwEXECUTE B^[
=== end test file ===
4G"eyy5G"ayy6G"byy1G@eG"ep
The command is loaded into 'e', and then executed. 'e' executes
'a', which loads 'e', then 'e' executes 'b' anyway.
The output should be:
=== output file ===
line 1 foo bar baz
EXECUTE B 2 foo bar baz
line 3 foo bar baz
@a@b
"eyy
cwEXECUTE B^[
line 1 foo bar baz
=== end output file ===
Maps:
=== test file ===
Cine 1 foo bar baz
line 2 foo bar baz
line 3 foo bar baz
=== end test file ===
Entering the command ':map = :map = rB^V^MrA^M1G==' shows that
the first time the '=' is entered the '=' map is set and the
character is changed to 'A', the second time the character is
changed to 'B'.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
4: Historically, executable buffers are discarded if the editor
switches between ex and vi modes.
=== test file ===
line 1 foo bar baz
line 2 foo bar baz
line 3 foo bar baz
cwCHANGE^[Q:set
set|visual|1Gwww
=== end test file ===
vi testfile
4G"ayy@a
ex testfile
$p
yank a
@a
In vi, the command is loaded into 'a' and then executed. The command
subsequent to the 'Q' is (historically, silently) discarded.
In ex, the command is loaded into 'a' and then executed. The command
subsequent to the 'visual' is (historically, silently) discarded. The
first set command is output by ex, although refreshing the screen usually
causes it not to be seen.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
5: Executable buffers inside of map commands are expanded normally.
Maps inside of executable buffers are expanded normally.
Buffers inside of map commands:
=== test file ===
line 1 foo bar baz
line 2 foo bar baz
line 3 foo bar baz
cwREPLACE BY A^[
=== end test file ===
4G"ay$:map x @a
1Gx
The output should be:
=== output file ===
REPLACE BY A 1 foo bar baz
line 2 foo bar baz
line 3 foo bar baz
cwREPLACE BY A^[
=== end output file ===
Maps commands inside of executable buffers:
=== test file ===
line 1 foo bar baz
line 2 foo bar baz
line 3 foo bar baz
X
=== end test file ===
:map X cwREPLACE BY XMAP^[
4G"ay$1G@a
The output should be:
=== output file ===
REPLACE BY XMAP 1 foo bar baz
line 2 foo bar baz
line 3 foo bar baz
X
=== end output file ===
Here's a test that does both, repeatedly.
=== test file ===
line 1 foo bar baz
line 2 foo bar baz
line 3 foo bar baz
X
Y
cwREPLACED BY C^[
blank line
=== end test file ===
:map x @a
4G"ay$
:map X @b
5G"by$
:map Y @c
6G"cy$
1Gx
The output should be:
=== output file ===
REPLACED BY C 1 foo bar baz
line 2 foo bar baz
line 3 foo bar baz
X
Y
cwREPLACED BY C^[
blank line
=== end output file ===
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6: If an error is encountered while executing a mapped command or
a buffer, the rest of the mapped command/buffer is discarded. No
user input characters are discarded.
=== test file ===
line 1 foo bar baz
line 2 foo bar baz
line 3 foo bar baz
:map = 10GcwREPLACMENT^V^[^[
=== end test file ===
The above mapping fails, however, if the 10G is changed to 1, 2,
or 3G, it will succeed.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

View File

@ -0,0 +1,219 @@
# @(#)quoting 5.4 (Berkeley) 8/20/93
QUOTING IN EX/VI:
There are two escape characters in historic ex/vi, ^V (or whatever
character the user specified as their literal next character) and
backslashes. There are two different areas in ex/vi where escaping
is interesting: the command and text input modes, and within the ex
commands themselves. In the examples below, ^V is used as the
typical literal next character.
1: Escaping characters in ex and vi command and text input modes.
The set of characters that users might want to escape are as
follows:
vi text input mode (a, i, o, etc.):
carriage return (^M)
escape (^[)
autoindent characters
(^D, 0, ^, ^T)
erase, word erase, and line erase
(^H, ^W, ^U)
newline (^J) (not historic practice)
suspend (^Z) (not historic practice)
repaint (^L) (not historic practice)
vi command line (:colon commands):
carriage return (^M)
escape (^[)
erase, word erase, and line erase
(^H, ^W, ^U)
newline (^J) (not historic practice)
suspend (^Z) (not historic practice)
repaint (^L) (not historic practice)
ex text input mode (a, i, o, etc.):
carriage return (^M)
erase, word erase, and line erase
(^H, ^W, ^U)
newline (^J) (not historic practice)
ex command line:
carriage return (^M)
erase, word erase, and line erase
(^H, ^W, ^U)
newline (^J) (not historic practice)
suspend (^Z)
I intend to follow historic practice for all of these cases, which
was that ^V was the only way to escape any of these characters, and
that whatever character followed the ^V was taken literally, i.e.
^V^V is a single ^V.
The historic ex/vi disallowed the insertion of various control
characters (^D, ^T, whatever) during various different modes, or,
permitted the insertion of only a single one, or lots of other random
behaviors (you can use ^D to enter a command in ex). I have
regularized this behavior in nvi, there are no characters that cannot
be entered or which have special meaning other than the ones listed
above.
One comment regarding the autoindent characters. In historic vi,
if you entered "^V0^D" autoindent erasure was still triggered,
although it wasn't if you entered "0^V^D". In nvi, if you escape
either character, autoindent erasure is not triggered.
This doesn't permit whitespace in command names, but that wasn't
historic practice and doesn't seem worth doing.
Fun facts to know and tell:
The historic vi implementation for the 'r' command requires
*three* ^V's to replace a single character with ^V.
2: Ex commands:
Ex commands are delimited by '|' or newline characters. Within
the commands, whitespace characters delimit the arguments.
I intend to treat ^V, followed by any character, as that literal
character.
This is historic behavior in vi, although there are special
cases where it's impossible to escape a character, generally
a whitespace character.
3: Escaping characters in file names in ex commands:
:cd [directory] (directory)
:chdir [directory] (directory)
:edit [+cmd] [file] (file)
:ex [+cmd] [file] (file)
:file [file] (file)
:next [file ...] (file ...)
:read [!cmd | file] (file)
:source [file] (file)
:write [!cmd | file] (file)
:wq [file] (file)
:xit [file] (file)
I intend to treat a backslash in a file name, followed by any
character, as that literal character.
This is historic behavior in vi.
In addition, since file names are also subject to word expansion,
the rules for escape characters in section 3 of this document also
apply. This is NOT historic behavior in vi, making it impossible
to insert a whitespace, newline or carriage return character into
a file name. This change could cause a problem if there were files
with ^V's in their names, but I think that's unlikely.
4: Escaping characters in non-file arguments in ex commands:
:abbreviate word string (word, string)
* :edit [+cmd] [file] (+cmd)
* :ex [+cmd] [file] (+cmd)
:k key (key)
:map word string (word, string)
:mark key (key)
* :set [option ...] (option)
* :tag string (string)
:unabbreviate word (word)
:unmap word (word)
These commands use whitespace to delimit their arguments, and use
^V to escape those characters. The exceptions are starred in the
above list, and are discussed below.
In general, I intend to treat a ^V in any argument, followed by
any character, as that literal character. This will permit
editing of files name "foo|", for example, by using the string
"foo\^V|", where the literal next character protects the pipe
from the ex command parser and the backslash protects it from the
shell expansion.
This is backward compatible with historical vi, although there
were a number of special cases where vi wasn't consistent.
4.1: The edit/ex commands:
The edit/ex commands are a special case because | symbols may
occur in the "+cmd" field, for example:
:edit +10|s/abc/ABC/ file.c
In addition, the edit and ex commands have historically ignored
literal next characters in the +cmd string, so that the following
command won't work.
:edit +10|s/X/^V / file.c
I intend to handle the literal next character in edit/ex consistently
with how it is handled in other commands.
More fun facts to know and tell:
The acid test for the ex/edit commands:
date > file1; date > file2
vi
:edit +1|s/./XXX/|w file1| e file2|1 | s/./XXX/|wq
No version of vi, of which I'm aware, handles it.
4.2: The set command:
The set command treats ^V's as literal characters, so the following
command won't work. Backslashes do work in this case, though, so
the second version of the command does work.
set tags=tags_file1^V tags_file2
set tags=tags_file1\ tags_file2
I intend to continue permitting backslashes in set commands, but
to also permit literal next characters to work as well. This is
backward compatible, but will also make set consistent with the
other commands. I think it's unlikely to break any historic
.exrc's, given that there are probably very few files with ^V's
in their name.
4.3: The tag command:
The tag command ignores ^V's and backslashes; there's no way to
get a space into a tag name.
I think this is a don't care, and I don't intend to fix it.
5: Regular expressions:
:global /pattern/ command
:substitute /pattern/replace/
:vglobal /pattern/ command
I intend to treat a backslash in the pattern, followed by the
delimiter character or a backslash, as that literal character.
This is historic behavior in vi. It would get rid of a fairly
hard-to-explain special case if we could just use the character
immediately following the backslash in all cases, or, if we
changed nvi to permit using the literal next character as a
pattern escape character, but that would probably break historic
scripts.
There is an additional escaping issue for regular expressions.
Within the pattern and replacement, the '|' character did not
delimit ex commands. For example, the following is legal.
:substitute /|/PIPE/|s/P/XXX/
This is a special case that I will support.
6: Ending anything with an escape character:
In all of the above rules, an escape character (either ^V or a
backslash) at the end of an argument or file name is not handled
specially, but used as a literal character.

View File

@ -0,0 +1,61 @@
# @(#)structures 5.2 (Berkeley) 11/1/93
There are three major data structures in this package. The first is a
single global structure (named GS) which contains information common to
all files and screens. It's really pretty tiny, and functions more as a
single place to hang things than anything else.
The second and third structures are the file structures (named EXF) and
the screen structures (named SCR). They contain information theoretically
unique to a screen or file, respectively. Each SCR structure has a set
of functions which update the screen and/or return information about the
screen from the underlying screen package.
The GS structure contains linked lists SCR structures. The structures
can also be classed by persistence. The GS structure never goes away
and the SCR structure persists over instances of files.
File names have different properties than files themselves, so the name
information for a file is held in an FREF structure which is chained from
the SCR structure.
In general, functions are always passed an SCR structure and often an EXF
structure as well. The SCR structure is necessary for any routine that
wishes to talk to the screen, the EXF structure is necessary for any
routine that wants to modify the file. The relationship between an SCR
structure and its underlying EXF structure is not fixed, and although you
can translate from an SCR to the underlying EXF, it is discouraged. If
this becomes too onerous, I suspect I'll just stop passing around the EXF
in the future.
The naming of the structures is consistent across the program. (Macros
even depend on it, so don't try and change it!) The global structure is
"gp", the screen structure is "sp", and the file structure is "ep".
A few other data structures:
TEXT In nvi/cut.h. This structure describes a portion of a line,
and is used by the input routines and as the "line" part of a
cut buffer.
CB In nvi/cut.h. A cut buffer. A cut buffer is a place to
hang a list of TEXT structures.
MARK In nvi/mark.h. A cursor position, consisting of a line number
and a column number.
MSG In nvi/msg.h. A chain of messages for the user.
SEQ In nvi/seq.h. An abbreviation or a map entry.
EXCMDARG
In nvi/ex/excmd.h.stub. The structure that gets passed around
to the functions that implement the ex commands. (The main
ex command loop (see nvi/ex/ex.c) builds this up and then passes
it to the ex functions.)
VICMDARG
In nvi/vi/vcmd.h. The structure that gets passed around to the
functions that implement the vi commands. (The main vi command
loop (see nvi/vi/vi.c) builds this up and then passes it to the
vi functions.)

1065
usr.bin/vi/docs/set.opt.roff Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,67 +1,163 @@
Amir
Autoprint
BRE's
Bostic
Ds
ERE's
EXINIT
Englar
Ev
Fa
Fl
HUnhsh
IPLPPPQPP
Kirkendall
LIpplpipbp
LaA
Li
Makefiles
NEXINIT
NHSHH
Nex
Nvi
OS
POSIX
PostScript
RE's
README
SIGHUP
SIGWINCH
Se
Std1003.2
Sy
TANDARDS
TIOCGWINSZ
TMPDIR
Todo
USD.doc
UUNET
Vx
XXCOLUMNS
XXXX
ags
ai
altwerase
autoindent
autoprint
autowrite
aw
bf
bostic
bugs.current
carat
changelog
cmd
creens
cs.berkeley.edu
db
dbopen
def
di
dir
docs
eFlRsv
eFlRv
eb
edcompatible
elvis
email
enum
errorbells
esc
exrc
exu
fi
ftp.cs.berkeley.edu
ftp.uu.net
gdb
gdb.script
gzip'd
hangup
hardtabs
ht
ic
ifdef
ignorecase
ious
keystroke
keystrokes
keytime
leftright
li
libc.tags
lowercase
matchtime
meta
modeful
modeline
modelines
nex
nexrc
nomagic
nvi
nvi.tar.Z
nvi.tar.z
para
pathname
rc.local
readonly
recdir
recover.XXXX
recover.c
ript
ro
roff
sc
scr
screeen
set.opt.roff
shiftwidth
showmatch
showmode
sidescroll
slowopen
sm
sourceany
sp
spell.ok
svi
sw
tabstop
taglength
tagpop
tagtop
th
tl
tmp
ts
ttytype
ttywerase
ucb
uffers
uppercase
uunet
var
vglobal
vi.0.ps
vi.0.txt
vi.1
vi.XXXX
vi.exrc
vi.recover
virecovery
viu
wa
wi
wm
wrapmargin
wrapscan
writeany
ws
xaw
xit
yy

View File

@ -1,13 +1,13 @@
%!PS-Adobe-3.0
%%Creator: groff version 1.08
%%DocumentNeededResources: font Times-Bold
%%DocumentNeededResources: font Times-Roman
%%+ font Times-Bold
%%+ font Courier-Bold
%%+ font Times-Roman
%%+ font Courier-Oblique
%%+ font Courier
%%+ font Symbol
%%+ font Times-Italic
%%DocumentSuppliedResources: procset grops 1.08 0
%%Pages: 3
%%Pages: 7
%%PageOrder: Ascend
%%Orientation: Portrait
%%EndComments
@ -165,12 +165,12 @@ pop
setpacking
}if
%%EndResource
%%IncludeResource: font Times-Roman
%%IncludeResource: font Times-Bold
%%IncludeResource: font Courier-Bold
%%IncludeResource: font Times-Roman
%%IncludeResource: font Courier-Oblique
%%IncludeResource: font Courier
%%IncludeResource: font Symbol
%%IncludeResource: font Times-Italic
grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72 def/PL
792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron/scaron/zcaron
/Ydieresis/trademark/quotesingle/.notdef/.notdef/.notdef/.notdef/.notdef
@ -196,256 +196,473 @@ grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72 def/PL
/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla/egrave/eacute
/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis/eth/ntilde/ograve
/oacute/ocircumflex/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex
/udieresis/yacute/thorn/ydieresis]def/Courier@0 ENC0/Courier RE
/Courier-Oblique@0 ENC0/Courier-Oblique RE/Times-Roman@0 ENC0/Times-Roman RE
/udieresis/yacute/thorn/ydieresis]def/Times-Italic@0 ENC0/Times-Italic RE
/Courier@0 ENC0/Courier RE/Courier-Oblique@0 ENC0/Courier-Oblique RE
/Courier-Bold@0 ENC0/Courier-Bold RE/Times-Bold@0 ENC0/Times-Bold RE
/Times-Roman@0 ENC0/Times-Roman RE
%%EndProlog
%%Page: 1 1
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Bold@0 SF(Name)72 24 Q/F1 10/Courier-Bold@0 SF(ex, vi, view)102 36
Q/F2 10/Times-Roman@0 SF 2.5<ad74>2.5 G -.15(ex)187.42 36 S 2.5(te).15 G
(ditors)206.43 36 Q F0(SYNOPSIS)72 60 Q F1(vi)102 72 Q F2([)3.333 E F1
(\255eFlRv)2.499 E F2 3.333(][).833 G F1<ad63>-.834 E/F3 10/Courier-Oblique@0
SF(command)6 E F2 3.333(][).833 G F1<ad72>-.834 E F3(file)6 E F2 3.333(][).833
G F1<ad74>-.834 E F3(tag)6 E F2 3.333(][).833 G F1<ad77>-.834 E F3(size)6 E F2
3.333(][).833 G F1<ad78>-.834 E F3(aw)6 E F2(]).833 E F1(view)102 84 Q F2([)
3.333 E F1(\255eFlRv)2.499 E F2 3.333(][).833 G F1<ad63>-.834 E F3(command)6 E
F2 3.333(][).833 G F1<ad72>-.834 E F3(file)6 E F2 3.333(][).833 G F1<ad74>-.834
E F3(tag)6 E F2 3.333(][).833 G F1<ad77>-.834 E F3(size)6 E F2 3.333(][).833 G
F1<ad78>-.834 E F3(aw)6 E F2(]).833 E F1(ex)102 96 Q F2([)3.333 E F1
(\255eFlRsv)2.499 E F2 3.333(][).833 G F1<ad63>-.834 E F3(command)6 E F2 3.333
(][).833 G F1<ad72>-.834 E F3(file)6 E F2 3.333(][).833 G F1<ad74>-.834 E F3
(tag)6 E F2 3.333(][).833 G F1<ad77>-.834 E F3(size)6 E F2 3.333(][).833 G F1
<ad78>-.834 E F3(aw)6 E F2(]).833 E F0(DESCRIPTION)72 120 Q F1(Ex)102 132 Q F2
.298(is a line-oriented te)2.798 F .298(xt editor)-.15 F(.)-.55 E F1(Vi)5.298 E
F2 .298(is a screen oriented te)2.798 F .298(xt editor)-.15 F 2.798(,b)-.4 G
.297(ased on)381.914 132 R F1(ex)2.797 E F2(.)A F1(View)2.797 E F2 .297
(is the same as using)2.797 F(the)102 144 Q F1<ad52>4.243 E F2 .077
(\(read-only\) option of)2.577 F F1(vi)2.577 E F2(.)A F1(Ex)2.577 E F2(and)
2.578 E F1(vi)2.578 E F2 .078(are really dif)2.578 F .078(ferent interf)-.25 F
.078(aces to the same program, and it is pos-)-.1 F
(sible to switch back and forth during the same edit session.)102 156 Q .686
(This manual page is the one pro)102 174 R .686(vided with the)-.15 F F1(nex)
3.186 E F2(and)3.186 E F1(nvi)3.185 E F2 -.15(ve)3.185 G .685
(rsions of the vi te).15 F .685(xt editors.)-.15 F F1(Nex)5.685 E F2(and)3.185
E F1(nvi)3.185 E F2 .55(are intended as b)102 186 R(ug-for)-.2 E(-b)-.2 E .55
(ug compatible replacements for the original F)-.2 F .55(ourth Berk)-.15 F(ele)
-.1 E 3.05(yS)-.15 G(oftw)458.37 186 Q .55(are Distrib)-.1 F(ution)-.2 E
(\(4BSD\))102 198 Q F1(ex)2.5 E F2(and)2.5 E F1(vi)2.5 E F2(programs.)2.5 E
(The follo)102 216 Q(wing options are a)-.25 E -.25(va)-.2 G(ilable:).25 E F1
<ad63>103.666 234 Q F2(Ex)143 234 Q(ecute)-.15 E F3(command)2.834 E F2 .334
(immediately after starting the edit session.)2.834 F .334
(Useful for initial positioning in the)5.334 F .075(\214le, b)143 246 R(ut)-.2
E F3(command)2.575 E F2 .075(is not limited to positioning commands.)2.575 F
.076(This is the POSIX 1003.2 interf)5.075 F .076(ace for)-.1 F(the historic `)
143 258 Q(`+command')-.74 E 2.5('s)-.74 G(yntax.)253.53 258 Q F1(Nex/nvi)5 E F2
(supports both the old and ne)2.5 E 2.5(ws)-.25 G(yntax.)454.16 258 Q F1<ad65>
103.666 276 Q F2(Start editing in e)143 276 Q 2.5(xm)-.15 G
(ode, as if the command name w)224.52 276 Q(as)-.1 E F1(ex)2.5 E F2(.)A F1
<ad46>103.666 294 Q F2(Don')143 294 Q 2.946(tc)-.18 G(op)173.536 294 Q 2.946
(yt)-.1 G .446(he entire \214le when \214rst starting to edit.)194.162 294 R
.446(\(The def)5.446 F .446(ault is to mak)-.1 F 2.946(ea)-.1 G(cop)-.001 E
2.945(yi)-.1 G 2.945(nc)487.46 294 S .445(ase some-)499.845 294 R
(one else tries to edit the \214le too.\))143 306 Q F1<ad6c>103.666 324 Q F2
.867(List the \214les that may be reco)143 324 R -.15(ve)-.15 G .867
(red using the).15 F F1<ad72>5.034 E F2 .868(option of)3.368 F F1(vi)3.368 E F2
3.368(.T)C .868(his is the ne)414.062 324 R 3.368(wi)-.25 G(nterf)477.284 324 Q
.868(ace for the)-.1 F(historic)143 336 Q F1<ad72>4.166 E F2
(without a \214le ar)2.5 E(gument syntax.)-.18 E F1(Nex/nvi)5 E F2
(supports both the old and ne)2.5 E 2.5(ws)-.25 G(yntax.)491.556 336 Q F1<ad52>
103.666 354 Q F2(Start editing in read-only mode, as if the command name w)143
354 Q(as)-.1 E F1(view)2.5 E F2(.)A F1<ad72>103.666 372 Q F2(Reco)143 372 Q
-.15(ve)-.15 G 2.5(rt).15 G(he speci\214ed \214le.)181.3 372 Q F1<ad73>103.666
390 Q F2 1.221(Enter batch mode; applicable only to)143 390 R F1(ex)3.721 E F2
1.221(edit sessions.)3.721 F 1.22(Batch mode is useful when running)6.221 F F1
(ex)3.72 E F2 3.307(scripts. Prompts,)143 402 R(informati)3.307 E 1.108 -.15
(ve m)-.25 H .808(essages and other user oriented things are turned of).15 F
3.308(f. This)-.25 F .808(is the)3.308 F .189(POSIX 1003.2 interf)143 414 R
.189(ace for the historic)-.1 F F1<adad>4.355 E F2(syntax.)2.689 E F1(Nex/nvi)
5.189 E F2 .189(supports both the old and ne)2.689 F 2.688(ws)-.25 G(yn-)526.67
414 Q(tax.)143 426 Q F1<ad74>103.666 444 Q F2
(Start editing at the speci\214ed tag.)143 444 Q(\(See)5 E/F4 10/Courier@0 SF
(ctags)2.5 E F2(\(1\)\).)A F1<ad77>103.666 462 Q F2(Set the initial windo)143
462 Q 2.5(ws)-.25 G(ize to the speci\214ed number of lines.)237.2 462 Q F1
<ad76>103.666 480 Q F2(Start editing in vi mode, as if the command name w)143
480 Q(as)-.1 E F1(vi)2.5 E F2(or)2.5 E F1(view)2.5 E F2(.)A F1<ad78>103.666 498
Q F2(Reserv)143 498 Q(ed for X11 interf)-.15 E 2.5(aces. Not)-.1 F
(currently implemented.)2.5 E F0(ADDITION)72 522 Q 1.666(AL FEA)-.2 F(TURES)
-.95 E F2 .031(This manual page is the one distrib)102 534 R .032
(uted with the)-.2 F F1(nvi)2.532 E F2(and)2.532 E F1(nex)2.532 E F2 .032
(reimplementations of)2.532 F F1(ex/vi)2.532 E F2 2.532(.T)C .032
(here are a fe)483.804 534 R(w)-.25 E(additional features in)102 546 Q F1
(nex/nvi)2.5 E F2(.)A(8-bit clean data, lar)102 564 Q(ge lines, \214les)-.18 E
F1(Nvi/nex)143 576 Q F2 .864(will edit an)3.364 F 3.364(yf)-.15 G .864
(ormat \214le.)246.636 576 R .863(Line lengths are limited by a)5.863 F -.25
(va)-.2 G .863(ilable memory).25 F 3.363(,a)-.65 G .863(nd \214le sizes)491.054
576 R .511(are limited by a)143 588 R -.25(va)-.2 G .511(ilable disk space.).25
F .512(The command `)5.511 F(`^Vx[0-9A-F)-.74 E(a-f])-.15 E/F5 10/Symbol SF(*)A
F2 -.74('')C 3.012(,i).74 G 3.012(ni)439.892 588 S .512(nput mode, will insert)
450.684 588 R(an)143 600 Q 2.5(yl)-.15 G -2.25 -.15(eg a)162.57 600 T 2.5(lc)
.15 G(haracter v)185.97 600 Q(alue into the te)-.25 E(xt.)-.15 E(Split screens)
102 618 Q .036(The command `)143 630 R .036(`:sp[lit] [\214le ...]')-.74 F
2.536('s)-.74 G .036(plits the screen in vi mode.)280.01 630 R .035(The k)5.035
F .335 -.15(ey `)-.1 H(`^W')-.59 E 2.535('s)-.74 G .035(witches between the)
458.84 630 R(fore)143 642 Q .09(ground screens, and the `)-.15 F .09
(`:resize count')-.74 F 2.591('c)-.74 G .091(ommand can be used to gro)326.011
642 R 2.591(wo)-.25 G 2.591(rs)451.287 642 S .091(hrink an)461.098 642 R 2.591
(yp)-.15 G(articular)506.68 642 Q(screen.)143 654 Q(Background and fore)102 672
Q(ground screens)-.15 E .921(The command `)143 684 R(`:bg')-.74 E 3.421('b)-.74
G .921(ackgrounds the current screen, and the command `)237.873 684 R .92
(`:fg [\214le]')-.74 F 3.42('f)-.74 G(ore)495.16 684 Q(grounds)-.15 E 1.79
(the backgrounded screeen that is editing the speci\214ed \214le, or)143 696 R
4.29(,b)-.4 G 4.29(yd)412.68 696 S(ef)426.97 696 Q 1.79
(ault, the \214rst background)-.1 F(screen on the queue.)143 708 Q
(The command `)5 E(`:di[splay] s[creens]')-.74 E 2.5('l)-.74 G
(ists the background screens.)383.67 708 Q(Shell screens)102 726 Q .128
(The command `)143 738 R .128(`:sc[ript] [\214le ...]')-.74 F 2.628('r)-.74 G
.128(uns a shell in the screen.)284.9 738 R .127
(Editing is unchanged, with the e)5.127 F(xcep-)-.15 E
(tion that a <carriage-return> enters the current line \(stripped of an)143 750
Q 2.5(yp)-.15 G(rompt\) as input to the shell.)418.78 750 Q -.8(Ta)102 768 S
2.5(gs).8 G(tacks)123.14 768 Q -.8(Ta)143 780 S .234(gs are no).8 F 2.734(wm)
-.25 G .234(aintained in a stack.)206.802 780 R .234(The command `)5.234 F
(`^T')-.74 E 2.734('r)-.74 G .235(eturns to the pre)379.97 780 R .235
(vious tag location.)-.25 F(The)5.235 E .251(command `)143 792 R .251
(`:tagpop [number)-.74 F(\214le]')7.168 E 2.751('r)-.74 G .251
(eturns to the most recent tag location by def)293.021 792 R .251(ault, or)-.1
F 2.75(,o)-.4 G(ptional-)508.89 792 Q EP
/F0 10/Times-Roman@0 SF -.834(EX/VI \( 1 \))72 48 R(BSD Reference Manual)
258.235 48 Q -.834(EX/VI \( 1 \))496.682 48 R/F1 10/Times-Bold@0 SF -.2(NA)72
108 S(ME).2 E/F2 10/Courier-Bold@0 SF(ex, vi, view)102 120 Q F0 2.5<ad74>2.5 G
-.15(ex)187.42 120 S 2.5(te).15 G(ditors)206.43 120 Q F1(SYNOPSIS)72 144 Q F2
(ex)102 156 Q F0([)3.333 E F2(\255eFlRsv)2.499 E F0 3.333(][).833 G F2<ad63>
-.834 E/F3 10/Courier-Oblique@0 SF(cmd)6 E F0 3.333(][).833 G F2<ad72>-.834 E
F3(file)6 E F0 3.333(][).833 G F2<ad74>-.834 E F3(tag)6 E F0 3.333(][).833 G F2
<ad77>-.834 E F3(size)6 E F0 3.333(][).833 G F2<ad78>-.834 E F3(aw)6 E F0 3.333
(][).833 G F3(file ...)429.446 156 Q F0(]).833 E F2(vi)102 168 Q F0([)3.333 E
F2(\255eFlRv)2.499 E F0 3.333(][).833 G F2<ad63>-.834 E F3(cmd)6 E F0 3.333(][)
.833 G F2<ad72>-.834 E F3(file)6 E F0 3.333(][).833 G F2<ad74>-.834 E F3(tag)6
E F0 3.333(][).833 G F2<ad77>-.834 E F3(size)6 E F0 3.333(][).833 G F2<ad78>
-.834 E F3(aw)6 E F0 3.333(][).833 G F3(file ...)423.446 168 Q F0(]).833 E F2
(view)102 180 Q F0([)3.333 E F2(\255eFlRv)2.499 E F0 3.333(][).833 G F2<ad63>
-.834 E F3(cmd)6 E F0 3.333(][).833 G F2<ad72>-.834 E F3(file)6 E F0 3.333(][)
.833 G F2<ad74>-.834 E F3(tag)6 E F0 3.333(][).833 G F2<ad77>-.834 E F3(size)6
E F0 3.333(][).833 G F2<ad78>-.834 E F3(aw)6 E F0 3.333(][).833 G F3(file ...)
435.446 180 Q F0(]).833 E F1(DESCRIPTION)72 204 Q F2(Vi)102 216 Q F0 .176
(is a screen oriented te)2.676 F .176(xt editor)-.15 F(.)-.55 E F2(Ex)5.176 E
F0 .176(is a line-oriented te)2.676 F .175(xt editor)-.15 F(.)-.55 E F2(Ex)
5.175 E F0(and)2.675 E F2(vi)2.675 E F0 .175(are dif)2.675 F .175
(ferent interf)-.25 F .175(aces to the)-.1 F .56(same program, and it is possi\
ble to switch back and forth during an edit session.)102 228 R F2(View)5.561 E
F0 .561(is the equi)3.061 F -.25(va)-.25 G .561(lent of).25 F(using the)102 240
Q F2<ad52>4.166 E F0(\(read-only\) option of)2.5 E F2(vi)2.5 E F0(.)A .216
(This manual page is the one pro)102 258 R .215(vided with the)-.15 F F2
(nex/nvi)2.715 E F0 -.15(ve)2.715 G .215(rsions of the).15 F F2(ex/vi)2.715 E
F0(te)2.715 E .215(xt editors.)-.15 F F2(Nex/nvi)5.215 E F0(are)2.715 E 1.937
(intended as b)102 270 R(ug-for)-.2 E(-b)-.2 E 1.937
(ug compatible replacements for the original F)-.2 F 1.938(ourth Berk)-.15 F
(ele)-.1 E 4.438(yS)-.15 G(oftw)456.982 270 Q 1.938(are Distrib)-.1 F(ution)-.2
E(\(4BSD\))102 282 Q F2(ex)3.008 E F0(and)3.008 E F2(vi)3.008 E F0 3.008
(programs. F)3.008 F .508(or the rest of this manual page,)-.15 F F2(nex/nvi)
3.008 E F0 .507(is used only when it')3.008 F 3.007(sn)-.55 G(ecessary)506.13
282 Q(to distinguish it from the historic implementations of)102 294 Q F2
(ex/vi)2.5 E F0(.)A .961(This manual page is intended for users already f)102
312 R .961(amiliar with)-.1 F F2(ex/vi)3.461 E F0 3.462(.A)C -.15(ny)397.982
312 S .962(one else should almost certainly).15 F .582
(read a good tutorial on the editor before this manual page.)102 324 R .582
(If you')5.582 F .581(re in an unf)-.5 F .581(amiliar en)-.1 F .581
(vironment, and you)-.4 F 1.111(absolutely ha)102 336 R 1.411 -.15(ve t)-.2 H
3.611(og).15 G 1.111(et w)185.253 336 R 1.111(ork done immediately)-.1 F 3.611
(,r)-.65 G 1.111(ead the section near the end of this manual page, entitled)
301.987 336 R -.74(FA)102 348 S(ST ST).74 E(AR)-.93 E(TUP)-.6 E 5(.I)-1.11 G
(t')180.85 348 Q 2.5(sp)-.55 G(robably enough to get you going.)197.8 348 Q
(The follo)102 366 Q(wing options are a)-.25 E -.25(va)-.2 G(ilable:).25 E F2
<ad63>103.666 384 Q F0(Ex)137 384 Q(ecute)-.15 E F3(cmd)2.675 E F0 .175
(immediately after starting the edit session.)2.675 F -.15(Pa)5.175 G .174
(rticularly useful for initial positioning in).15 F .624(the \214le, ho)137 396
R(we)-.25 E -.15(ve)-.25 G(r).15 E F3(cmd)3.124 E F0 .625
(is not limited to positioning commands.)3.124 F .625
(This is the POSIX 1003.2 interf)5.625 F(ace)-.1 E(for the historic `)137 408 Q
(`+cmd')-.74 E 2.5('s)-.74 G(yntax.)239.47 408 Q F2(Nex/nvi)5 E F0
(supports both the old and ne)2.5 E 2.5(ws)-.25 G(yntax.)440.1 408 Q F2<ad65>
103.666 426 Q F0(Start editing in e)137 426 Q 2.5(xm)-.15 G
(ode, as if the command name were)218.52 426 Q F2(ex)2.5 E F0(.)A F2<ad46>
103.666 444 Q F0(Don')137 444 Q 2.677(tc)-.18 G(op)167.267 444 Q 2.677(yt)-.1 G
.177(he entire \214le when \214rst starting to edit.)187.624 444 R .177
(\(The def)5.177 F .177(ault is to mak)-.1 F 2.677(eac)-.1 G(op)456.532 444 Q
2.676(yi)-.1 G 2.676(nc)476.888 444 S .176(ase someone)489.004 444 R
(else modi\214es the \214le during your edit session.\))137 456 Q F2<ad6c>
103.666 474 Q F0 .249(List the \214les that may be reco)137 474 R -.15(ve)-.15
G .249(red using the).15 F F2<ad72>4.415 E F0 .249(option of)2.749 F F2(vi)
2.749 E F0 2.749(.T)C .249(his is the ne)400.023 474 R 2.75(wi)-.25 G(nterf)
460.77 474 Q .25(ace for the his-)-.1 F 1.181(toric syntax of the)137 486 R F2
<ad72>5.347 E F0 1.181(option without a \214le ar)3.681 F(gument.)-.18 E F2
(Nex/nvi)6.181 E F0 1.181(supports both the old and ne)3.681 F(w)-.25 E
(syntax.)137 498 Q F2<ad52>103.666 516 Q F0 .184
(Start editing in read-only mode, as if the command name w)137 516 R(as)-.1 E
F2(view)2.685 E F0 2.685(,o)C 2.685(rt)421.415 516 S .185(he readonly option w)
430.21 516 R .185(as set.)-.1 F F2<ad72>103.666 534 Q F0(Reco)137 534 Q -.15
(ve)-.15 G 2.5(rt).15 G(he speci\214ed \214le.)175.3 534 Q F2<ad73>103.666 552
Q F0 1.621(Enter batch mode; applicable only to)137 552 R F2(ex)4.121 E F0
1.621(edit sessions.)4.121 F 1.62(Batch mode is useful when running)6.621 F F2
(ex)4.12 E F0 2.647(scripts. Prompts,)137 564 R(informati)2.647 E .447 -.15
(ve m)-.25 H .147(essages and other user oriented message are turned of).15 F
.148(f, and no start-)-.25 F .067(up \214les or en)137 576 R .067
(vironmental v)-.4 F .066(ariables are read.)-.25 F .066
(This is the POSIX 1003.2 interf)5.066 F .066(ace for the historic `)-.1 F
(`\255')-.74 E(')-.74 E(ar)137 588 Q(gument.)-.18 E F2(Nex/nvi)5 E F0
(supports both the old and ne)2.5 E 2.5(ws)-.25 G(yntax.)353 588 Q F2<ad74>
103.666 606 Q F0(Start editing at the speci\214ed tag.)137 606 Q(\(See)5 E/F4
10/Courier@0 SF(ctags)2.5 E F0(\(1\)\).)A F2<ad77>103.666 624 Q F0
(Set the initial windo)137 624 Q 2.5(ws)-.25 G
(ize to the speci\214ed number of lines.)231.2 624 Q F2<ad76>103.666 642 Q F0
(Start editing in vi mode, as if the command name w)137 642 Q(as)-.1 E F2(vi)
2.5 E F0(or)2.5 E F2(view)2.5 E F0(.)A F2<ad78>103.666 660 Q F0(Reserv)137 660
Q(ed for X11 interf)-.15 E(aces.)-.1 E/F5 10/Times-Italic@0 SF
(No X11 support is curr)5 E(ently implemented.)-.37 E F2(Ex/vi)102 678 Q F0
-.15(ex)2.5 G(it 0 on success, and greater than 0 if an error occurs.).15 E
167.75(4.4BSD March)72 750 R(19, 1994)2.5 E(1)535 750 Q EP
%%Page: 2 2
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF .45(ly to a speci\214c tag number in the tag stack, or\
the most recent tag from the speci\214ed \214le.)143 12 R .45(Use the)5.45 F
.186(command `)143 24 R .186(`:di[splay] t[ags]')-.74 F 2.686('t)-.74 G 2.686
(ov)266.218 24 S(ie)278.904 24 Q 2.686(wt)-.25 G .185(he tags stack.)298.56 24
R .185(The command `)5.185 F(`:tagtop')-.74 E 2.685('r)-.74 G .185
(eturns to the top of)463.71 24 R(the tag stack.)143 36 Q(Ne)102 54 Q 2.5(wd)
-.25 G(isplays)128.13 54 Q 1.268(The command `)143 66 R 1.268(`:di[splay] b[uf)
-.74 F 6.702(fers] s[creens] t[ags]')-.25 F 3.768('c)-.74 G 1.269
(an be used to display)379.666 66 R 3.769(,r)-.65 G(especti)477.571 66 Q -.15
(ve)-.25 G(ly).15 E 3.769(,t)-.65 G(he)530.56 66 Q(current cut b)143 78 Q(uf)
-.2 E(fers, the backgrounded screens, and the tags stack.)-.25 E
(In\214nite undo)102 96 Q 1.052
(The changes made during an edit session may be rolled backw)143 108 R 1.051
(ard and forw)-.1 F 3.551(ard. A)-.1 F('.)3.551 E 3.551('c)-.7 G(ommand)505 108
Q .369(immediately after a 'u' command continues either forw)143 120 R .369
(ard or backw)-.1 F .37(ard depending on whether the)-.1 F('u' command w)143
132 Q(as an undo or a redo.)-.1 E(Usage information)102 150 Q .668
(The command `)143 162 R(`:e)-.74 E .668(xu[sage [cmd]')-.15 F 3.168('a)-.74 G
.668(nd `)288.992 162 R .668(`viu[sage] [k)-.74 F -.15(ey)-.1 G(]').15 E 3.168
('p)-.74 G(ro)383.396 162 Q .667(vide usage information for all of the)-.15 F
.3 -.15(ex a)143 174 T(nd vi commands by def).15 E(ault, or)-.1 E 2.5(,o)-.4 G
(ptionally)290.94 174 Q 2.5(,f)-.65 G(or a speci\214c command or k)334.18 174 Q
-.15(ey)-.1 G(.)-.5 E(Extended re)102 192 Q(gular e)-.15 E(xpressions)-.15 E
.811(The `)143 204 R .811(`:set e)-.74 F(xtended')-.15 E 3.311('c)-.74 G .812
(ommand treats search and other command re)234.603 204 R .812(gular e)-.15 F
.812(xpressions as e)-.15 F(xtended)-.15 E(\(e)143 216 Q(grep\(1\) style\) re)
-.15 E(gular e)-.15 E(xpressions.)-.15 E -.8(Wo)102 234 S(rd search).8 E
(The command `)143 246 Q(`^A')-.74 E 2.5('s)-.74 G(earches for the w)231.77 246
Q(ord referenced by the cursor)-.1 E(.)-.55 E(Number increment)102 264 Q
(The command `)143 276 Q(`#')-.74 E 2.5('i)-.74 G
(ncrements the number referenced by the cursor)225.11 276 Q(.)-.55 E(Pre)102
294 Q(vious \214le)-.25 E(The command `)143 306 Q(`:pre)-.74 E(v[ious][!]')-.25
E 2.5('e)-.74 G(dits the pre)275.39 306 Q(vious \214le from the ar)-.25 E
(gument list.)-.18 E(Left-Right scrolling)102 324 Q .734(The command `)143 336
R .733(`:set leftright')-.74 F 3.233('m)-.74 G(ak)276.653 336 Q(es)-.1 E/F1 10
/Courier-Bold@0 SF(nvi)3.233 E F0 .733
(do left-right screen scrolling, instead of the traditional)3.233 F F1(vi)143
348 Q F0(line wrapping.)2.5 E/F2 10/Times-Bold@0 SF(RECO)72 372 Q(VER)-.5 E(Y)
-.35 E F0 1.079(There is no reco)102 384 R -.15(ve)-.15 G 1.079
(ry program for n).15 F 1.079(vi, nor does it run setuid.)-.4 F 1.079
(Users may reco)6.079 F -.15(ve)-.15 G 3.579(ra).15 G 1.379 -.15(ny \214)
444.324 384 T 1.079(le which the).15 F 3.579(ym)-.15 G(ay)530.56 384 Q
(read, and the superuser may reco)102 396 Q -.15(ve)-.15 G 2.5(ra).15 G .3 -.15
(ny e)253.03 396 T(dit session.).15 E 2.995(Edit sessions are back)102 414 R
2.994(ed by \214les in)-.1 F/F3 10/Courier@0 SF(/var/tmp/vi.recover)5.494 E F0
5.494(,a)C 2.994(nd are named `)391.224 414 R(`vi.XXXX')-.74 E 2.994(', where)
-.74 F -.74(``)102 426 S(XXXX').74 E 3.104('i)-.74 G 3.104(san)148.604 426 S
.605(umber related to the process id.)168.142 426 R .605
(When a \214le is \214rst modi\214ed, a second \214le, which contains)5.605 F
.185(an email message for the user)102 438 R 2.685(,i)-.4 G 2.685(sc)229.07 438
S .185(reated, and is named `)240.085 438 R(`reco)-.74 E -.15(ve)-.15 G -.55
(r.).15 G(XXXX').55 E .185(', where, ag)-.74 F .185(ain, `)-.05 F(`XXXX')-.74 E
2.685('i)-.74 G 2.685(sa)505.655 438 S(ssoci-)516.67 438 Q .098
(ated with the process id.)102 450 R .098(Both \214les are remo)5.098 F -.15
(ve)-.15 G 2.599(da).15 G 2.599(tt)302.273 450 S .099
(he end of a normal edit session, b)310.432 450 R .099
(ut will remain if the ed-)-.2 F 2.248
(it session is abnormally terminated or the user enters the e)102 462 R 2.248
(x/vi `)-.15 F(`preserv)-.74 E(e')-.15 E 4.748('c)-.74 G 4.748(ommand. The)
431.578 462 R 2.248(use of the)4.748 F F3(/var/tmp)102 474 Q F0 .028
(directory may be changed setting the option `)2.528 F(`recdir')-.74 E 2.529
('i)-.74 G 2.529(nt)371.226 474 S .029(he user')381.535 474 R 2.529(so)-.55 G
2.529(rs)424.363 474 S .029(ystem startup information.)434.112 474 R .144
(The reco)102 492 R -.15(ve)-.15 G .144(ry directory should ha).15 F .444 -.15
(ve t)-.2 H .144(he `).15 F(`stick)-.74 E(y-bit')-.15 E 2.643('s)-.74 G .143
(et so that only the o)317.617 492 R .143(wners of \214les may remo)-.25 F .443
-.15(ve t)-.15 H 2.643(hem. If).15 F .106
(this is not possible on the system, then a pseudo-user should o)102 504 R .106
(wn the reco)-.25 F -.15(ve)-.15 G .106(ry directory).15 F 5.106(.T)-.65 G .106
(he reco)467.348 504 R -.15(ve)-.15 G .106(ry direc-).15 F
(tory must be both read and write-able by an)102 516 Q 2.5(yu)-.15 G(ser)288.76
516 Q(.)-.55 E .601(The reco)102 534 R -.15(ve)-.15 G .601(ry \214le has all o\
f the necessary information in it to enable the user to reco).15 F -.15(ve)-.15
G 3.101(rt).15 G .601(he edit session.)464.037 534 R(In)5.601 E .322
(addition, it has all of the necessary email headers for sendmail.)102 546 R
.322(When the system is rebooted, all of the \214les)5.322 F(in)102 558 Q F3
(/var/tmp/vi.recover)2.695 E F0 .195(named `)2.695 F(`reco)-.74 E -.15(ve)-.15
G -.55(r.).15 G(XXXX').55 E 2.695('s)-.74 G .195
(hould be sent by email, using the)337.46 558 R F1<ad74>4.36 E F0 .194
(\215ag of send-)2.694 F .335
(mail \(or a similar mechanism in other mailers\).)102 570 R 2.835(As)5.335 G
.335(imple w)311.935 570 R .335(ay to do this is to insert the follo)-.1 F .335
(wing script into)-.25 F(your rc.local \(or other startup\) \214le:)102 582 Q
F3 6(#R)132 618 S(ecover nvi editor files.)150 618 Q
(virecovery=/var/tmp/vi.recover/recover.)132 630 Q/F4 10/Symbol SF(*)A F3
(if [ "$virecovery" != "/var/tmp/vi.recover/recover.)132 642 Q F4(*)A F3 6("])C
6(;t)461 642 S(hen)479 642 Q(echo 'Recovering vi editor sessions')177 654 Q
(for i in $virecovery; do)177 666 Q(sendmail -t < $i)222 678 Q(done)177 690 Q
(fi)132 702 Q F0(If)102 720 Q F1(nex/nvi)2.5 E F0(recei)2.5 E -.15(ve)-.25 G
2.5(sah).15 G(angup \(SIGHUP\) signal, it will email the reco)202.46 720 Q -.15
(ve)-.15 G(ry information to the user itself.).15 E .774(If you don')102 738 R
3.274(th)-.18 G -2.25 -.2(av e)159.412 738 T .774
(the sendmail program on your system, the source \214le)3.474 F F3
(nvi/recover.c)3.273 E F0 .773(will ha)3.273 F 1.073 -.15(ve t)-.2 H 3.273(ob)
.15 G(e)535.56 738 Q(modi\214ed to use your mail deli)102 750 Q -.15(ve)-.25 G
(ry programs.).15 E EP
/F0 10/Times-Roman@0 SF -.834(EX/VI \( 1 \))72 48 R(BSD Reference Manual)
258.235 48 Q -.834(EX/VI \( 1 \))496.682 48 R/F1 10/Times-Bold@0 SF(ENVIR)72 96
Q(ONMENT)-.3 E 1.666(AL V)-.9 F(ARIABLES)-1.35 E/F2 10/Courier@0 SF(COLUMNS)102
108 Q F0 .036(The number of columns on the screen.)131 120 R .036(This v)5.036
F .036(alue o)-.25 F -.15(ve)-.15 G .036(rrides an).15 F 2.536(ys)-.15 G .037
(ystem or terminal speci\214c v)394.256 120 R 2.537(alues. If)-.25 F .211
(the COLUMNS en)131 132 R .211(vironmental v)-.4 F .211
(ariable is not set when)-.25 F/F3 10/Courier-Bold@0 SF(ex/vi)2.711 E F0 .211
(runs, or the)2.711 F F1(columns)2.71 E F0 .21(option is e)2.71 F(xplic-)-.15 E
(itly reset by the user)131 144 Q(,)-.4 E F3(ex/vi)2.5 E F0(enters the v)2.5 E
(alue into the en)-.25 E(vironment.)-.4 E F2(EXINIT)102 156 Q F0 2.5(Al)131 168
S(ist of)143.5 168 Q F3(ex)2.5 E F0(startup commands, read if the v)2.5 E
(ariable)-.25 E F2(NEXINIT)2.5 E F0(is not set.)2.5 E F2(HOME)102 180 Q F0
1.562(The user')5 F 4.062(sh)-.55 G 1.562(ome directory)183.004 180 R 4.062(,u)
-.65 G 1.562(sed as the initial directory path for the startup)251.298 180 R F2
($HOME/.nexrc)4.063 E F0(and)4.063 E F2($HOME/.exrc)131 192 Q F0 2.5
(\214les. This)2.5 F -.25(va)2.5 G(lue is also used as the def).25 E
(ault directory for the)-.1 E F3(vi)2.5 E F1(cd)2.5 E F0(command.)2.5 E F2
(LINES)102 204 Q F0 .033(The number of ro)131 216 R .033(ws on the screen.)-.25
F .033(This v)5.033 F .033(alue o)-.25 F -.15(ve)-.15 G .033(rrides an).15 F
2.533(ys)-.15 G .033(ystem or terminal speci\214c v)379.523 216 R 2.533
(alues. If)-.25 F(the)2.532 E .666(LINES en)131 228 R .666(vironmental v)-.4 F
.666(ariable is not set when)-.25 F F3(ex/vi)3.166 E F0 .666(runs, or the)3.166
F F1(lines)3.166 E F0 .667(option is e)3.166 F .667(xplicitly reset by)-.15 F
(the user)131 240 Q(,)-.4 E F3(ex/vi)2.5 E F0(enters the v)2.5 E
(alue into the en)-.25 E(vironment.)-.4 E F2(NEXINIT)102 252 Q F0 2.5(Al)131
264 S(ist of)143.5 264 Q F3(ex)2.5 E F0(startup commands.)2.5 E F2(SHELL)102
276 Q F0(The user')131 288 Q 2.5(ss)-.55 G(hell of choice \(see also the)178.77
288 Q F1(shell)2.5 E F0(option\).)2.5 E F2(TERM)102 300 Q F0 .252(The user')5 F
2.752(st)-.55 G .252(erminal type.)178.164 300 R .252(The def)5.252 F .251
(ault is the type `)-.1 F(`unkno)-.74 E(wn')-.25 E .251('. If the TERM en)-.74
F .251(vironmental v)-.4 F .251(ariable is)-.25 F .578(not set when)131 312 R
F3(ex/vi)3.078 E F0 .578(runs, or the)3.078 F F1(term)3.078 E F0 .578
(option is e)3.078 F .578(xplicitly reset by the user)-.15 F(,)-.4 E F3(ex/vi)
3.079 E F0 .579(enters the v)3.079 F(alue)-.25 E(into the en)131 324 Q
(vironment.)-.4 E F2(TMPDIR)102 336 Q F0
(The location used to stored temporary \214les \(see also the)131 348 Q F1(dir)
2.5 E(ectory)-.18 E F0(option\).)2.5 E F1 1.666(SET OPTIONS)72 372 R F0 .519
(There are a lar)102 384 R .518
(ge number of options that may be set \(or unset\) to change the editor')-.18 F
3.018(sb)-.55 G(eha)453.614 384 Q(vior)-.2 E 5.518(.T)-.55 G .518(his section)
496.982 384 R(describes the options, their abbre)102 396 Q
(viations and their def)-.25 E(ault v)-.1 E(alues.)-.25 E .095
(In each entry belo)102 414 R 1.395 -.65(w, t)-.25 H .095
(he \214rst part of the tag line is the full name of the option, follo).65 F
.095(wed by an)-.25 F 2.595(ye)-.15 G(qui)487.915 414 Q -.25(va)-.25 G .095
(lent ab-).25 F(bre)102 426 Q 3.034(viations. The)-.25 F .534
(part in square brack)3.034 F .533(ets is the def)-.1 F .533(ault v)-.1 F .533
(alue of the option.)-.25 F .533(Most of the options are boolean,)5.533 F
(i.e. the)102 438 Q 2.5(ya)-.15 G(re either on or of)140.73 438 Q
(f, and do not ha)-.25 E .3 -.15(ve a)-.2 H 2.5(na).15 G(ssociated v)298.14 438
Q(alue.)-.25 E(Options apply to both)102 456 Q F3(ex)2.5 E F0(and)2.5 E F3(vi)
2.5 E F0(modes, unless otherwise speci\214ed.)2.5 E F2(altwerase [off])102 468
Q F3(Vi)131 480 Q F0(only)2.5 E 5(.S)-.65 G(elect an alternate w)175.69 480 Q
(ord erase algorithm.)-.1 E F2(autoindent, ai [off])102 492 Q F0
(Automatically indent ne)131 504 Q 2.5(wl)-.25 G(ines.)239.91 504 Q F2
(autoprint, ap [off])102 516 Q F3(Ex)131 528 Q F0(only)2.5 E 5(.D)-.65 G
(isplay the current line automatically)177.35 528 Q(.)-.65 E F2
(autowrite, aw [off])102 540 Q F0
(Write modi\214ed \214les automatically when changing \214les.)131 552 Q F2
(beautify, bf [off])102 564 Q F0(Discard control characters.)131 576 Q F2
(cdpath [environment variable CDPATH, or ``.''])102 588 Q F0
(The directory paths used as path pre\214x)131 600 Q(es for the)-.15 E F1(cd)
2.5 E F0(command.)2.5 E F2(columns, co [80])102 612 Q F0
(Set the number of columns in the screen.)131 624 Q F2(comment [off])102 636 Q
F3(Vi)131 648 Q F0(only)2.5 E 5(.S)-.65 G(kip leading comments in \214les.)
175.69 648 Q F2(directory, dir [environment variable TMPDIR, or /tmp])102 660 Q
F0(The directory where temporary \214les are created.)131 672 Q F2
(edcompatible, ed [off])102 684 Q F0(Modify the beha)131 696 Q
(vior of certain suf)-.2 E(\214ces for the)-.25 E F3(ex)2.5 E F1(substitute)2.5
E F0(command.)2.5 E 167.75(4.4BSD March)72 750 R(19, 1994)2.5 E(2)535 750 Q EP
%%Page: 3 3
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Bold@0 SF -.1(BU)72 12 S(GS).1 E/F1 10/Times-Roman@0 SF
(This man page is w)102 24 Q(oefully incomplete.)-.1 E(Man)102 42 Q 2.5(ya)-.15
G(nd v)132.12 42 Q 2.5(aried. See)-.25 F(the \214le)2.5 E/F2 10/Courier@0 SF
(nvi/docs/bugs.current)2.5 E F1(for a list of the kno)2.5 E(wn b)-.25 E
(ugs in this v)-.2 E(ersion.)-.15 E F0(FILES)72 66 Q F2(/tmp)102 78 Q F1
(Storage for temporary \214les.)245 78 Q F2(/var/tmp/vi.recover)102 90 Q F1
(Storage for reco)245 90 Q -.15(ve)-.15 G(ry \214les.).15 E F0 1.666(SEE ALSO)
72 114 R F2(ctags)102 126 Q F1(\(1\),)A F2(more)5 E F1(\(1\),)A F2(curses)5 E
F1(\(3\),)A F2(dbopen)5 E F1(\(3\))A(The `)102 150 Q(`V)-.74 E 2.5(iQ)-.6 G
(uick Reference')145.09 150 Q 2.5('c)-.74 G(ard.)218.2 150 Q -.74(``)102 174 S
/F0 10/Times-Roman@0 SF -.834(EX/VI \( 1 \))72 48 R(BSD Reference Manual)
258.235 48 Q -.834(EX/VI \( 1 \))496.682 48 R/F1 10/Times-Italic@0 SF
(This option is not yet implemented.)131 96 Q/F2 10/Courier@0 SF
(errorbells, eb [off])102 108 Q/F3 10/Courier-Bold@0 SF(Ex)131 120 Q F0(only)
2.5 E 5(.P)-.65 G(recede error messages with a bell.)175.69 120 Q F1
(This option is not yet implemented.)131 132 Q F2(exrc, ex [off])102 144 Q F0
(Ne)131 156 Q -.15(ve)-.25 G 2.5(rr).15 G
(ead startup \214les in the local directory)160.86 156 Q(.)-.65 E F2
(extended [off])102 168 Q F0(Re)131 180 Q(gular e)-.15 E(xpressions are e)-.15
E(xtended \(i.e.)-.15 E F2(egrep)5 E F0(\(1\) style\) e)A(xpressions.)-.15 E F2
(flash [on])102 192 Q F0(Flash the screen instead of beeping the k)131 204 Q
-.15(ey)-.1 G(board on error).15 E(.)-.55 E F2(hardtabs, ht [8])102 216 Q F0
(Set the spacing between hardw)131 228 Q(are tab settings.)-.1 E F2
(ignorecase, ic [off])102 240 Q F0(Ignore case dif)131 252 Q(ferences in re)
-.25 E(gular e)-.15 E(xpressions.)-.15 E F2(keytime [6])102 264 Q F0(The 10th')
131 276 Q 2.5(so)-.55 G 2.5(fas)181 276 S(econd)197.66 276 Q F3(ex/vi)2.5 E F0
-.1(wa)2.5 G(its for a subsequent k).1 E .3 -.15(ey t)-.1 H 2.5(oc).15 G
(omplete a k)379.5 276 Q .3 -.15(ey m)-.1 H(apping.).15 E F2(leftright [off])
102 288 Q F3(Vi)131 300 Q F0(only)2.5 E 5(.D)-.65 G 2.5(ol)177.35 300 S
(eft-right scrolling.)187.63 300 Q F2(lines, li [24])102 312 Q F3(Vi)131 324 Q
F0(only)2.5 E 5(.S)-.65 G(et the number of lines in the screen.)175.69 324 Q F2
(lisp [off])102 336 Q F3(Vi)131 348 Q F0(only)2.5 E 5(.M)-.65 G(odify v)179.02
348 Q(arious search commands and options to w)-.25 E(ork with Lisp.)-.1 E F1
(This option is not yet implemented.)131 360 Q F2(list [off])102 372 Q F0
(Display lines in an unambiguous f)131 384 Q(ashion.)-.1 E F2(magic [on])102
396 Q F0 -.35(Tr)131 408 S(eat certain characters specially in re).35 E
(gular e)-.15 E(xpressions.)-.15 E F2(matchtime [7])102 420 Q F3(Vi)131 432 Q
F0(only)2.884 E 5.384(.T)-.65 G .384(he 10th')177.008 432 R 2.884(so)-.55 G
2.884(fas)221.666 432 S(econd)239.094 432 Q F3(ex/vi)2.884 E F0 .385
(pauses on the matching character when the)2.884 F/F4 10/Times-Bold@0 SF(sho)
2.885 E(wmatch)-.1 E F0(op-)2.885 E(tion is set.)131 444 Q F2(mesg [on])102 456
Q F0(Permit messages from other users.)131 468 Q F2(modelines, modeline [off])
102 480 Q F0(Read the \214rst and last fe)131 492 Q 2.5(wl)-.25 G
(ines of each \214le for)240.18 492 Q F3(ex)2.5 E F0(commands.)2.5 E F1
(This option will ne)131 504 Q(ver be implemented.)-.15 E F2(number, nu [off])
102 516 Q F0(Precede each line displayed with its current line number)131 528 Q
(.)-.55 E F2(open [on])102 540 Q F3(Ex)131 552 Q F0(only)2.5 E 5(.I)-.65 G 2.5
(ft)173.46 552 S(his option is not set, the)182.07 552 Q F4(open)2.5 E F0(and)
2.5 E F4(visual)2.5 E F0(commands are disallo)2.5 E(wed.)-.25 E F2
(optimize, opt [on])102 564 Q F3(Vi)131 576 Q F0(only)2.5 E 5(.O)-.65 G
(ptimize te)177.35 576 Q(xt throughput to dumb terminals.)-.15 E F1
(This option is not yet implemented.)131 588 Q F2
(paragraphs, para [IPLPPPQPP LIpplpipbp])102 600 Q F3(Vi)131 612 Q F0(only)2.5
E 5(.D)-.65 G(e\214ne additional paragraph boundaries for the)177.35 612 Q F4
({)2.5 E F0(and)2.5 E F4(})2.5 E F0(commands.)2.5 E F2(prompt [on])102 624 Q F3
(Ex)131 636 Q F0(only)2.5 E 5(.D)-.65 G(isplay a command prompt.)177.35 636 Q
F2(readonly, ro [off])102 648 Q F0(Mark the \214le as read-only)131 660 Q(.)
-.65 E F2(recdir [/var/tmp/vi.recover])102 672 Q F0 167.75(4.4BSD March)72 750
R(19, 1994)2.5 E(3)535 750 Q EP
%%Page: 4 4
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF -.834(EX/VI \( 1 \))72 48 R(BSD Reference Manual)
258.235 48 Q -.834(EX/VI \( 1 \))496.682 48 R(The directory where reco)131 96 Q
-.15(ve)-.15 G(ry \214les are stored.).15 E/F1 10/Courier@0 SF
(redraw, re [off])102 108 Q/F2 10/Courier-Bold@0 SF(Vi)131 120 Q F0(only)2.5 E
5(.S)-.65 G(imulate an intelligent terminal on a dumb one.)175.69 120 Q/F3 10
/Times-Italic@0 SF(This option is not yet implemented.)131 132 Q F1(remap [on])
102 144 Q F0(Remap k)131 156 Q -.15(ey)-.1 G 2.5(su).15 G(ntil resolv)187.41
156 Q(ed.)-.15 E F1(remapmax [on])102 168 Q F0(Limit the number of times a k)
131 180 Q .3 -.15(ey m)-.1 H(ay be remapped.).15 E F1(report [5])102 192 Q F0
(Set the number of lines about which the editor reports changes.)131 204 Q F1
(ruler [off])102 216 Q F2(Vi)131 228 Q F0(only)2.5 E 5(.D)-.65 G(isplay a ro)
177.35 228 Q(w/column ruler on the colon command line.)-.25 E F1
(scroll, scr [window / 2])102 240 Q F0(Set the number of lines scrolled.)131
252 Q F1(sections, sect [NHSHH HUnhsh])102 264 Q F2(Vi)131 276 Q F0(only)2.5 E
5(.D)-.65 G(e\214ne additional section boundaries for the)177.35 276 Q/F4 10
/Times-Bold@0 SF([[)2.5 E F0(and)2.5 E F4(]])2.5 E F0(commands.)2.5 E F1
(shell, sh [environment variable SHELL, or /bin/sh])102 288 Q F0
(Select the shell used by the editor)131 300 Q(.)-.55 E F1(shiftwidth, sw [8])
102 312 Q F0(Set the autoindent and shift command indentation width.)131 324 Q
F1(showdirty [off])102 336 Q F2(Vi)131 348 Q F0(only)2.5 E 5(.D)-.65 G(isplay \
an asterisk on the colon command line if the \214le has been modi\214ed.)177.35
348 Q F1(showmatch, sm [off])102 360 Q F2(Vi)131 372 Q F0(only)2.5 E 5(.N)-.65
G(ote matching `)177.35 372 Q(`{')-.74 E 2.5('a)-.74 G(nd `)255.37 372 Q(`\(')
-.74 E 2.5('f)-.74 G(or `)288.87 372 Q(`}')-.74 E 2.5('a)-.74 G(nd `)323.28 372
Q(`\)')-.74 E 2.5('c)-.74 G(haracters.)357.89 372 Q F1(showmode [off])102 384 Q
F2(Vi)131 396 Q F0(only)2.5 E 5(.D)-.65 G
(isplay the current editor mode \(command or input\).)177.35 396 Q F1
(sidescroll [16])102 408 Q F2(Vi)131 420 Q F0(only)2.5 E 5(.S)-.65 G
(et the amount a left-right scroll will shift.)175.69 420 Q F1
(slowopen, slow [off])102 432 Q F0(Delay display updating during te)131 444 Q
(xt input.)-.15 E F3(This option is not yet implemented.)131 456 Q F1
(sourceany [off])102 468 Q F0(Read startup \214les not o)131 480 Q
(wned by the current user)-.25 E(.)-.55 E F3(This option will ne)131 492 Q
(ver be implemented.)-.15 E F1(tabstop, ts [8])102 504 Q F0
(This option sets tab widths for the editor display)131 516 Q(.)-.65 E F1
(taglength, tl [0])102 528 Q F0
(Set the number of signi\214cant characters in tag names.)131 540 Q F1
(tags, tag [tags /var/db/libc.tags /sys/kern/tags])102 552 Q F0
(Set the list of tags \214les.)131 564 Q F1
(term, ttytype, tty [environment variable TERM])102 576 Q F0
(Set the terminal type.)131 588 Q F1(terse [off])102 600 Q F0 .76
(This option has historically made editor messages less v)131 612 R 3.259
(erbose. It)-.15 F .759(has no ef)3.259 F .759(fect in this implementa-)-.25 F
(tion.)131 624 Q F1(timeout, to [on])102 636 Q F0 -.35(Ti)131 648 S
(me out on k).35 E -.15(ey)-.1 G 2.5(sw).15 G(hich may be mapped.)209.84 648 Q
F1(ttywerase [off])102 660 Q F2(Vi)131 672 Q F0(only)2.5 E 5(.S)-.65 G
(elect an alternate erase algorithm.)175.69 672 Q F1(verbose [off])102 684 Q F0
167.75(4.4BSD March)72 750 R(19, 1994)2.5 E(4)535 750 Q EP
%%Page: 5 5
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF -.834(EX/VI \( 1 \))72 48 R(BSD Reference Manual)
258.235 48 Q -.834(EX/VI \( 1 \))496.682 48 R(only)131 96 Q 5(.D)-.65 G
(isplay an error message for e)162.85 96 Q -.15(ve)-.25 G(ry error).15 E(.)-.55
E/F1 10/Courier@0 SF(w300 [no default])102 108 Q/F2 10/Courier-Bold@0 SF(Vi)131
120 Q F0(only)2.5 E 5(.S)-.65 G(et the windo)175.69 120 Q 2.5(ws)-.25 G
(ize if the baud rate is less than 1200 baud.)238.49 120 Q F1
(w1200 [no default])102 132 Q F2(Vi)131 144 Q F0(only)2.5 E 5(.S)-.65 G
(et the windo)175.69 144 Q 2.5(ws)-.25 G
(ize if the baud rate is equal to 1200 baud.)238.49 144 Q F1
(w9600 [no default])102 156 Q F2(Vi)131 168 Q F0(only)2.5 E 5(.S)-.65 G
(et the windo)175.69 168 Q 2.5(ws)-.25 G
(ize if the baud rate is greater than 1200 baud.)238.49 168 Q F1(warn [on])102
180 Q F2(Ex)131 192 Q F0(only)2.978 E 5.478(.T)-.65 G .479
(his option causes a w)177.196 192 R .479
(arning message to the terminal if the \214le has been modi\214ed, since it)-.1
F -.1(wa)131 204 S 2.5(sl).1 G(ast written, before a)151.73 204 Q/F3 10
/Times-Bold@0 SF(!)2.5 E F0(command.)2.5 E F1
(window, w, wi [environment variable LINES])102 216 Q F0(Set the windo)131 228
Q 2.5(ws)-.25 G(ize for the screen.)199.36 228 Q F1(wrapmargin, wm [0])102 240
Q F2(Vi)131 252 Q F0(only)2.5 E 5(.B)-.65 G(reak lines automatically when the)
176.8 252 Q 2.5(yr)-.15 G(each the right-hand mar)321.9 252 Q(gin.)-.18 E F1
(wrapscan, ws [on])102 264 Q F0(Set searches to wrap around the end or be)131
276 Q(ginning of the \214le.)-.15 E F1(writeany, wa [off])102 288 Q F0 -.45(Tu)
131 300 S(rn of).45 E 2.5<668c>-.25 G(le-o)171.96 300 Q -.15(ve)-.15 G
(rwriting checks.).15 E F3 -.9(FA)72 324 S 1.666(ST ST).9 F(AR)-.9 E(TUP)-.4 E
F0 .467(This section will tell you the minimum amount that you need to do simp\
le editing tasks using)102 336 R F2(vi)2.966 E F0 2.966(.I)C 2.966(fy)506.584
336 S(ou')517.88 336 Q -.15(ve)-.5 G(ne)102 348 Q -.15(ve)-.25 G 3.453(ru).15 G
.953(sed an)132.263 348 R 3.453(ys)-.15 G .953(creen editor before, you')
170.679 348 R .953(re lik)-.5 F .953(ely to ha)-.1 F 1.253 -.15(ve p)-.2 H .953
(roblems e).15 F -.15(ve)-.25 G 3.453(nw).15 G .953
(ith this simple introduction.)412.286 348 R(In)5.954 E
(that case you should \214nd someone that already kno)102 360 Q(ws)-.25 E F2
(vi)2.5 E F0(and ha)2.5 E .3 -.15(ve t)-.2 H(hem w).15 E
(alk you through this section.)-.1 E F2(Vi)102 378 Q F0 .294
(is a screen editor)2.794 F 5.294(.T)-.55 G .294(his means that it tak)198.51
378 R .293
(es up almost the entire screen, displaying part of the \214le on each)-.1 F
.001(screen line, e)102 390 R .001(xcept for the last line of the screen.)-.15
F .002(The last line of the screen is used for you to gi)5.001 F .302 -.15
(ve c)-.25 H(ommands).15 E(to)102 402 Q F2(vi)2.5 E F0 2.5(,a)C(nd for)133.72
402 Q F2(vi)2.5 E F0(to gi)2.5 E .3 -.15(ve i)-.25 H(nformation to you.).15 E
.585(The other f)102 420 R .585(act that you need to understand is that)-.1 F
F2(vi)3.085 E F0 .585(is a modeful editor)3.085 F 3.085(,i)-.4 G .584
(.e. you are either entering te)406.125 420 R .584(xt or)-.15 F .836(you are e)
102 432 R -.15(xe)-.15 G .836(cuting commands, and you ha).15 F 1.137 -.15
(ve t)-.2 H 3.337(ob).15 G 3.337(ei)301.062 432 S 3.337(nt)311.619 432 S .837
(he right mode to do one or the other)322.736 432 R 5.837(.Y)-.55 G .837
(ou will be in)487.209 432 R 1.094
(command mode when you \214rst start editing a \214le.)102 444 R 1.093
(There are commands that switch you into input mode.)6.094 F .084
(There is only one k)102 456 R .384 -.15(ey t)-.1 H .085(hat tak).15 F .085
(es you out of input mode, and that is the <escape> k)-.1 F -.15(ey)-.1 G 5.085
(.\()-.5 G -2.15 -.25(Ke y)449.895 456 T .085(names are written)2.835 F 1.473
(using less-than and greater)102 468 R 1.473(-than signs, e.g.)-.2 F 1.473
(<escape> means the `)6.473 F(`escape')-.74 E 3.973('k)-.74 G -.15(ey)420.59
468 S 3.973(,u)-.5 G 1.473(sually labeled `)440.703 468 R(`esc')-.74 E 3.972
('o)-.74 G(n)535 468 Q .553(your terminal')102 480 R 3.053(sk)-.55 G -.15(ey)
171.336 480 S 3.053(board.\) If).15 F(you')3.053 E .554(re e)-.5 F -.15(ve)-.25
G 3.054(rc).15 G .554(onfused as to which mode you')277.45 480 R .554(re in, k)
-.5 F .554(eep entering the <escape>)-.1 F -.1(ke)102 492 S 2.615(yu)-.05 G
(ntil)123.805 492 Q F2(vi)2.615 E F0 .115(beeps at you.)2.615 F(\(Generally)
5.115 E(,)-.65 E F2(vi)2.615 E F0 .115
(will beep at you if you try and do something that')2.615 F 2.614(sn)-.55 G
.114(ot allo)484.472 492 R 2.614(wed. It)-.25 F
(will also display error messages.\))102 504 Q 2.057 -.8(To s)102 522 T .457
(tart editing a \214le, enter the command `).8 F(`)-.74 E F1 .458
(vi file_name<carriage-return>)B F0 -.74('')C 2.958(.T).74 G .458
(he command you)470.204 522 R .333
(should enter as soon as you start editing is `)102 534 R(`)-.74 E F1 .333
(:set verbose showmode<carriage-return>)B F0 -.74('')C 2.833(.T).74 G(his)
528.33 534 Q 1.441(will mak)102 546 R 3.941(et)-.1 G 1.441(he editor gi)149.782
546 R 1.741 -.15(ve y)-.25 H 1.441(ou v).15 F 1.441
(erbose error messages and display the current mode at the bottom of the)-.15 F
(screen.)102 558 Q(The commands to mo)102 576 Q .3 -.15(ve a)-.15 H
(round the \214le are:).15 E F3(h)102 588 Q F0(Mo)131 588 Q .3 -.15(ve t)-.15 H
(he cursor left one character).15 E(.)-.55 E F3(j)102 600 Q F0(Mo)131 600 Q .3
-.15(ve t)-.15 H(he cursor do).15 E(wn one line.)-.25 E F3(k)102 612 Q F0(Mo)
131 612 Q .3 -.15(ve t)-.15 H(he cursor up one line.).15 E F3(l)102 624 Q F0
(Mo)131 624 Q .3 -.15(ve t)-.15 H(he cursor right one character).15 E(.)-.55 E
F3(<cursor)102 636 Q(-arr)-.37 E -.1(ow)-.18 G(s>).1 E F0(The cursor arro)131
648 Q 2.5(wk)-.25 G -.15(ey)207.01 648 S 2.5(ss).15 G(hould w)226.58 648 Q
(ork, too.)-.1 E F3(/text<carriage-r)102 660 Q(etur)-.18 E(n>)-.15 E F0
(Search for the string `)131 672 Q(`te)-.74 E(xt')-.15 E 2.5('i)-.74 G 2.5(nt)
246.84 672 S(he \214le, and mo)257.12 672 Q .3 -.15(ve t)-.15 H
(he cursor to its \214rst character).15 E(.)-.55 E 167.75(4.4BSD March)72 750 R
(19, 1994)2.5 E(5)535 750 Q EP
%%Page: 6 6
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF -.834(EX/VI \( 1 \))72 48 R(BSD Reference Manual)
258.235 48 Q -.834(EX/VI \( 1 \))496.682 48 R(The commands to enter ne)102 96 Q
2.5(wt)-.25 G -.15(ex)220.34 96 S 2.5(ta).15 G(re:)239.35 96 Q/F1 10
/Times-Bold@0 SF(a)102 108 Q F0(Append ne)131 108 Q 2.5(wt)-.25 G -.15(ex)
186.85 108 S(t,).15 E/F2 10/Times-Italic@0 SF(after)2.5 E F0(the cursor)2.5 E
(.)-.55 E F1(i)102 120 Q F0(Insert ne)131 120 Q 2.5(wt)-.25 G -.15(ex)177.96
120 S(t,).15 E F2(befor)2.5 E(e)-.37 E F0(the cursor)2.5 E(.)-.55 E F1(o)102
132 Q F0(Open a ne)131 132 Q 2.5(wl)-.25 G(ine belo)183.79 132 Q 2.5(wt)-.25 G
(he line the cursor is on, and start entering te)227.98 132 Q(xt.)-.15 E F1(O)
102 144 Q F0(Open a ne)131 144 Q 2.5(wl)-.25 G(ine abo)183.79 144 Q .3 -.15
(ve t)-.15 H(he line the cursor is on, and start entering te).15 E(xt.)-.15 E
F1(<escape>)102 156 Q F0 .744(Once you')131 168 R 1.044 -.15(ve e)-.5 H .744
(ntered input mode using the one of the).15 F F1(a)3.244 E F0(,)A F1(i)3.244 E
F0(,)A F1(O)3.244 E F0 3.244(,o)C(r)390.542 168 Q F1(o)3.243 E F0 .743
(commands, use)3.243 F F1(<escape>)3.243 E F0 .743(to quit)3.243 F(entering te)
131 180 Q(xt and return to command mode.)-.15 E(The commands to cop)102 198 Q
2.5(yt)-.1 G -.15(ex)200.78 198 S 2.5(ta).15 G(re:)219.79 198 Q F1(yy)102 210 Q
F0(Cop)131 210 Q 2.5(yt)-.1 G(he line the cursor is on.)157.85 210 Q F1(p)102
222 Q F0(Append the copied line after the line the cursor is on.)131 222 Q
(The commands to delete te)102 240 Q(xt are:)-.15 E F1(dd)102 252 Q F0
(Delete the line the cursor is on.)131 252 Q F1(x)102 264 Q F0
(Delete the character the cursor is on.)131 264 Q
(The commands to write the \214le are:)102 282 Q F1(:w<carriage-r)102 294 Q
(etur)-.18 E(n>)-.15 E F0 .528(Write the \214le back to the \214le with the na\
me that you originally used as an ar)131 306 R .528(gument on the)-.18 F/F3 10
/Courier-Bold@0 SF(vi)3.028 E F0(com-)3.028 E(mand line.)131 318 Q F1
(:w \214le_name<carriage-r)102 330 Q(etur)-.18 E(n>)-.15 E F0
(Write the \214le back to the \214le with the name `)131 342 Q(`\214le_name')
-.74 E('.)-.74 E(The commands to quit editing and e)102 360 Q
(xit the editor are:)-.15 E F1(:q<carriage-r)102 372 Q(etur)-.18 E(n>)-.15 E F0
.848(Quit editing and lea)131 384 R 1.148 -.15(ve v)-.2 H 3.348(i\().15 G .848
(if you')239.6 384 R 1.148 -.15(ve m)-.5 H .848(odi\214ed the \214le, b).15 F
.848(ut not sa)-.2 F -.15(ve)-.2 G 3.348(dy).15 G .848(our changes,)415.454 384
R F3(vi)3.347 E F0 .847(will refuse to)3.347 F(quit\).)131 396 Q F1
(:q!<carriage-r)102 408 Q(etur)-.18 E(n>)-.15 E F0(Quit, discarding an)131 420
Q 2.5(ym)-.15 G(odi\214cations that you may ha)222.51 420 Q .3 -.15(ve m)-.2 H
(ade.).15 E .686(One \214nal caution.)102 438 R .686
(Unusual characters can tak)5.686 F 3.187(eu)-.1 G 3.187(pm)302.483 438 S .687
(ore than one column on the screen, and long lines can)318.45 438 R(tak)102 450
Q 3.129(eu)-.1 G 3.129(pm)126.689 450 S .629(ore than a single screen line.)
142.598 450 R .629(The abo)5.629 F .929 -.15(ve c)-.15 H .629(ommands w).15 F
.629(ork on `)-.1 F(`ph)-.74 E(ysical')-.05 E 3.129('c)-.74 G .628
(haracters and lines, i.e.)446.476 450 R(the)102 462 Q 2.74(ya)-.15 G -.25(ff)
126.25 462 S .24(ect the entire line no matter ho).25 F 2.74(wm)-.25 G(an)
273.79 462 Q 2.74(ys)-.15 G .241(creen lines it tak)294.71 462 R .241
(es up and the entire character no matter ho)-.1 F(w)-.25 E(man)102 474 Q 2.5
(ys)-.15 G(creen columns it tak)130.46 474 Q(es up.)-.1 E F1 -.1(BU)72 498 S
(GS).1 E F0(See the \214le)102 510 Q/F4 10/Courier@0 SF(nvi/docs/bugs.current)
2.5 E F0(for a list of the kno)2.5 E(wn b)-.25 E(ugs in this v)-.2 E(ersion.)
-.15 E F1(FILES)72 534 Q F4(/bin/sh)102 546 Q F0(The def)221 546 Q
(ault user shell.)-.1 E F4(/etc/vi.exrc)102 558 Q F0
(System-wide vi startup \214le.)221 558 Q F4(/tmp)102 570 Q F0 -.7(Te)221 570 S
(mporary \214le directory).7 E(.)-.65 E F4(/var/tmp/vi.recover)102 582 Q F0
(Reco)5 E -.15(ve)-.15 G(ry \214le directory).15 E(.)-.65 E F4($HOME/.nexrc)102
594 Q F0(1st choice for user')221 594 Q 2.5(sh)-.55 G
(ome directory startup \214le.)308.76 594 Q F4($HOME/.exrc)102 606 Q F0
(2nd choice for user')221 606 Q 2.5(sh)-.55 G(ome directory startup \214le.)
312.09 606 Q F4(.nexrc)102 618 Q F0
(1st choice for local directory startup \214le.)221 618 Q F4(.exrc)102 630 Q F0
(2nd choice for local directory startup \214le.)221 630 Q F1 1.666(SEE ALSO)72
654 R F4(ctags)102 666 Q F0(\(1\),)A F4(more)5 E F0(\(1\),)A F4(curses)5 E F0
(\(3\),)A F4(dbopen)5 E F0(\(3\))A(The `)102 690 Q(`V)-.74 E 2.5(iQ)-.6 G
(uick Reference')145.09 690 Q 2.5('c)-.74 G(ard.)218.2 690 Q 167.75
(4.4BSD March)72 750 R(19, 1994)2.5 E(6)535 750 Q EP
%%Page: 7 7
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF -.834(EX/VI \( 1 \))72 48 R(BSD Reference Manual)
258.235 48 Q -.834(EX/VI \( 1 \))496.682 48 R -.74(``)102 96 S
(Introduction to Display Editing with V).74 E(i')-.6 E(', found in the `)-.74 E
(`UNIX User')-.74 E 2.5(sM)-.55 G(anual Supplementary Documents')397.48 174 Q
('.)-.74 E -.74(``)102 198 S(Edit: A tutorial').74 E(', found in the `)-.74 E
(`UNIX User')-.74 E 2.5(sM)-.55 G(anual Supplementary Documents')300.58 198 Q
('.)-.74 E -.74(``)102 222 S(Ex Reference Manual \(V).74 E(ersion 3.7\)')-1.11
(`UNIX User')-.74 E 2.5(sM)-.55 G(anual Supplementary Documents')397.48 96 Q
('.)-.74 E -.74(``)102 120 S(Edit: A tutorial').74 E(', found in the `)-.74 E
(`UNIX User')-.74 E 2.5(sM)-.55 G(anual Supplementary Documents')300.58 120 Q
('.)-.74 E -.74(``)102 144 S(Ex Reference Manual \(V).74 E(ersion 3.7\)')-1.11
E(', found in the `)-.74 E(`UNIX User')-.74 E 2.5(sM)-.55 G
(anual Supplementary Documents')381.92 222 Q('.)-.74 E/F3 10/Courier-Bold@0 SF
(Nroff/troff)102 240 Q F1(source for the pre)2.5 E
(vious three documents are distrib)-.25 E(uted with)-.2 E F3(nex/nvi)2.5 E F1
(in the)2.5 E F2(nvi/docs/USD.doc)102 252 Q F1(directory of the)2.5 E F3
(nex/nvi)2.5 E F1(source code.)2.5 E(The \214les `)102 276 Q(`auto)-.74 E
(write')-.25 E(', `)-.74 E(`input')-.74 E(', and `)-.74 E(`quoting')-.74 E
(', found in the)-.74 E F2(nvi/docs)2.5 E F1(directory of the)2.5 E F3(nex/nvi)
2.5 E F1(source)2.5 E(code.)102 288 Q F0(HIST)72 312 Q(OR)-.18 E(Y)-.35 E F1
(The)102 324 Q F3(nex/nvi)2.5 E F1(replacements for)2.5 E F3(ex/vi)2.5 E F1
(\214rst appeared in 4.4BSD.)2.5 E F0(ST)72 348 Q(AND)-.9 E(ARDS)-.35 E F3
(Nex/nvi)102 360 Q F1(is f)2.5 E(airly close to IEEE Std1003.2 \(`)-.1 E
(`POSIX')-.74 E('\), b)-.74 E(ut it')-.2 E 2.5(sn)-.55 G(ot there yet.)367.76
360 Q EP
(anual Supplementary Documents')381.92 144 Q('.)-.74 E/F1 10/Courier-Bold@0 SF
(Nroff/troff)102 162 Q F0(source for the pre)2.5 E
(vious three documents are distrib)-.25 E(uted with)-.2 E F1(nex/nvi)2.5 E F0
(in the)2.5 E/F2 10/Courier@0 SF(nvi/docs/USD.doc)102 174 Q F0
(directory of the)2.5 E F1(nex/nvi)2.5 E F0(source code.)2.5 E(The \214les `)
102 198 Q(`auto)-.74 E(write')-.25 E(', `)-.74 E(`input')-.74 E(', `)-.74 E
(`quoting')-.74 E(', and `)-.74 E(`structures')-.74 E(', found in the)-.74 E F2
(nvi/docs/internals)2.5 E F0(direc-)2.5 E(tory of the)102 210 Q F1(nex/nvi)2.5
E F0(source code.)2.5 E/F3 10/Times-Bold@0 SF(HIST)72 234 Q(OR)-.18 E(Y)-.35 E
F0(The)102 246 Q F1(nex/nvi)2.5 E F0(replacements for the)2.5 E F1(ex/vi)2.5 E
F0(editor \214rst appeared in 4.4BSD.)2.5 E F3(ST)72 270 Q(AND)-.9 E(ARDS)-.35
E F1(Nex/nvi)102 282 Q F0 .1(is close to IEEE Std1003.2 \(`)2.6 F(`POSIX')-.74
E 2.6('\). That)-.74 F .1(document dif)2.6 F .1(fers from historical)-.25 F F1
(ex/vi)2.6 E F0 .1(practice in)2.6 F(se)102 294 Q -.15(ve)-.25 G
(ral places; there are changes to be made on both sides.).15 E 167.75
(4.4BSD March)72 750 R(19, 1994)2.5 E(7)535 750 Q EP
%%Trailer
end
%%EOF

View File

@ -1,188 +1,372 @@
EX/VI(1) BSD Reference Manual EX/VI(1)
NNaammee
NNAAMMEE
eexx,, vvii,, vviieeww - text editors
SSYYNNOOPPSSIISS
vvii [--eeFFllRRvv] [--cc _c_o_m_m_a_n_d] [--rr _f_i_l_e] [--tt _t_a_g] [--ww _s_i_z_e] [--xx _a_w]
vviieeww [--eeFFllRRvv] [--cc _c_o_m_m_a_n_d] [--rr _f_i_l_e] [--tt _t_a_g] [--ww _s_i_z_e] [--xx _a_w]
eexx [--eeFFllRRssvv] [--cc _c_o_m_m_a_n_d] [--rr _f_i_l_e] [--tt _t_a_g] [--ww _s_i_z_e] [--xx _a_w]
eexx [--eeFFllRRssvv] [--cc _c_m_d] [--rr _f_i_l_e] [--tt _t_a_g] [--ww _s_i_z_e] [--xx _a_w] [_f_i_l_e _._._.]
vvii [--eeFFllRRvv] [--cc _c_m_d] [--rr _f_i_l_e] [--tt _t_a_g] [--ww _s_i_z_e] [--xx _a_w] [_f_i_l_e _._._.]
vviieeww [--eeFFllRRvv] [--cc _c_m_d] [--rr _f_i_l_e] [--tt _t_a_g] [--ww _s_i_z_e] [--xx _a_w] [_f_i_l_e _._._.]
DDEESSCCRRIIPPTTIIOONN
EExx is a line-oriented text editor. VVii is a screen oriented text editor,
based on eexx. VViieeww is the same as using the --RR (read-only) option of vvii.
EExx and vvii are really different interfaces to the same program, and it is
possible to switch back and forth during the same edit session.
VVii is a screen oriented text editor. EExx is a line-oriented text editor.
EExx and vvii are different interfaces to the same program, and it is possi-
ble to switch back and forth during an edit session. VViieeww is the equiva-
lent of using the --RR (read-only) option of vvii.
This manual page is the one provided with the nneexx and nnvvii versions of the
vi text editors. NNeexx and nnvvii are intended as bug-for-bug compatible re-
This manual page is the one provided with the nneexx//nnvvii versions of the
eexx//vvii text editors. NNeexx//nnvvii are intended as bug-for-bug compatible re-
placements for the original Fourth Berkeley Software Distribution (4BSD)
eexx and vvii programs.
eexx and vvii programs. For the rest of this manual page, nneexx//nnvvii is used
only when it's necessary to distinguish it from the historic implementa-
tions of eexx//vvii.
This manual page is intended for users already familiar with eexx//vvii. Any-
one else should almost certainly read a good tutorial on the editor be-
fore this manual page. If you're in an unfamiliar environment, and you
absolutely have to get work done immediately, read the section near the
end of this manual page, entitled FAST STARTUP. It's probably enough to
get you going.
The following options are available:
--cc Execute _c_o_m_m_a_n_d immediately after starting the edit session.
Useful for initial positioning in the file, but _c_o_m_m_a_n_d is not
limited to positioning commands. This is the POSIX 1003.2 inter-
face for the historic ``+command'' syntax. NNeexx//nnvvii supports both
the old and new syntax.
--cc Execute _c_m_d immediately after starting the edit session. Partic-
ularly useful for initial positioning in the file, however _c_m_d is
not limited to positioning commands. This is the POSIX 1003.2
interface for the historic ``+cmd'' syntax. NNeexx//nnvvii supports
both the old and new syntax.
--ee Start editing in ex mode, as if the command name was eexx.
--ee Start editing in ex mode, as if the command name were eexx.
--FF Don't copy the entire file when first starting to edit. (The de-
fault is to make a copy in case someone else tries to edit the
file too.)
fault is to make a copy in case someone else modifies the file
during your edit session.)
--ll List the files that may be recovered using the --rr option of vvii.
This is the new interface for the historic --rr without a file ar-
gument syntax. NNeexx//nnvvii supports both the old and new syntax.
This is the new interface for the historic syntax of the --rr op-
tion without a file argument. NNeexx//nnvvii supports both the old and
new syntax.
--RR Start editing in read-only mode, as if the command name was vviieeww.
--RR Start editing in read-only mode, as if the command name was vviieeww,
or the readonly option was set.
--rr Recover the specified file.
--ss Enter batch mode; applicable only to eexx edit sessions. Batch
mode is useful when running eexx scripts. Prompts, informative
messages and other user oriented things are turned off. This is
the POSIX 1003.2 interface for the historic ---- syntax. NNeexx//nnvvii
messages and other user oriented message are turned off, and no
startup files or environmental variables are read. This is the
POSIX 1003.2 interface for the historic ``-'' argument. NNeexx//nnvvii
supports both the old and new syntax.
--tt Start editing at the specified tag. (See ctags(1)).
--ww Set the initial window size to the specified number of lines.
--vv Start editing in vi mode, as if the command name was vvii or vviieeww.
--xx Reserved for X11 interfaces. Not currently implemented.
--xx Reserved for X11 interfaces. _N_o _X_1_1 _s_u_p_p_o_r_t _i_s _c_u_r_r_e_n_t_l_y
_i_m_p_l_e_m_e_n_t_e_d_.
AADDDDIITTIIOONNAALL FFEEAATTUURREESS
This manual page is the one distributed with the nnvvii and nneexx reimplemen-
tations of eexx//vvii. There are a few additional features in nneexx//nnvvii.
EExx//vvii exit 0 on success, and greater than 0 if an error occurs.
8-bit clean data, large lines, files
NNvvii//nneexx will edit any format file. Line lengths are limited by
available memory, and file sizes are limited by available disk
space. The command ``^Vx[0-9A-Fa-f]*'', in input mode, will in-
EENNVVIIRROONNMMEENNTTAALL VVAARRIIAABBLLEESS
COLUMNS
The number of columns on the screen. This value overrides any sys-
tem or terminal specific values. If the COLUMNS environmental
variable is not set when eexx//vvii runs, or the ccoolluummnnss option is ex-
plicitly reset by the user, eexx//vvii enters the value into the envi-
ronment.
EXINIT
A list of eexx startup commands, read if the variable NEXINIT is not
set.
HOME The user's home directory, used as the initial directory path for
the startup _$_H_O_M_E_/_._n_e_x_r_c and _$_H_O_M_E_/_._e_x_r_c files. This value is also
used as the default directory for the vvii ccdd command.
LINES
The number of rows on the screen. This value overrides any system
or terminal specific values. If the LINES environmental variable
is not set when eexx//vvii runs, or the lliinneess option is explicitly reset
by the user, eexx//vvii enters the value into the environment.
NEXINIT
A list of eexx startup commands.
SHELL
The user's shell of choice (see also the sshheellll option).
TERM The user's terminal type. The default is the type ``unknown''. If
the TERM environmental variable is not set when eexx//vvii runs, or the
tteerrmm option is explicitly reset by the user, eexx//vvii enters the value
into the environment.
TMPDIR
The location used to stored temporary files (see also the ddiirreeccttoorryy
option).
SSEETT OOPPTTIIOONNSS
There are a large number of options that may be set (or unset) to change
the editor's behavior. This section describes the options, their abbre-
viations and their default values.
In each entry below, the first part of the tag line is the full name of
the option, followed by any equivalent abbreviations. The part in square
brackets is the default value of the option. Most of the options are
boolean, i.e. they are either on or off, and do not have an associated
value.
Options apply to both eexx and vvii modes, unless otherwise specified.
altwerase [off]
VVii only. Select an alternate word erase algorithm.
autoindent, ai [off]
Automatically indent new lines.
autoprint, ap [off]
EExx only. Display the current line automatically.
autowrite, aw [off]
Write modified files automatically when changing files.
beautify, bf [off]
Discard control characters.
cdpath [environment variable CDPATH, or ``.'']
The directory paths used as path prefixes for the ccdd command.
columns, co [80]
sert any legal character value into the text.
Set the number of columns in the screen.
comment [off]
VVii only. Skip leading comments in files.
directory, dir [environment variable TMPDIR, or /tmp]
The directory where temporary files are created.
edcompatible, ed [off]
Modify the behavior of certain suffices for the eexx ssuubbssttiittuuttee com-
mand.
_T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_.
errorbells, eb [off]
EExx only. Precede error messages with a bell.
_T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_.
exrc, ex [off]
Never read startup files in the local directory.
extended [off]
Regular expressions are extended (i.e. egrep(1) style) expres-
sions.
flash [on]
Flash the screen instead of beeping the keyboard on error.
hardtabs, ht [8]
Set the spacing between hardware tab settings.
ignorecase, ic [off]
Ignore case differences in regular expressions.
keytime [6]
The 10th's of a second eexx//vvii waits for a subsequent key to complete
a key mapping.
leftright [off]
VVii only. Do left-right scrolling.
lines, li [24]
VVii only. Set the number of lines in the screen.
lisp [off]
VVii only. Modify various search commands and options to work with
Lisp.
_T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_.
list [off]
Display lines in an unambiguous fashion.
magic [on]
Treat certain characters specially in regular expressions.
matchtime [7]
VVii only. The 10th's of a second eexx//vvii pauses on the matching char-
acter when the sshhoowwmmaattcchh option is set.
mesg [on]
Permit messages from other users.
modelines, modeline [off]
Read the first and last few lines of each file for eexx commands.
_T_h_i_s _o_p_t_i_o_n _w_i_l_l _n_e_v_e_r _b_e _i_m_p_l_e_m_e_n_t_e_d_.
number, nu [off]
Precede each line displayed with its current line number.
open [on]
EExx only. If this option is not set, the ooppeenn and vviissuuaall commands
are disallowed.
optimize, opt [on]
VVii only. Optimize text throughput to dumb terminals.
_T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_.
paragraphs, para [IPLPPPQPP LIpplpipbp]
VVii only. Define additional paragraph boundaries for the {{ and }}
commands.
prompt [on]
EExx only. Display a command prompt.
readonly, ro [off]
Mark the file as read-only.
recdir [/var/tmp/vi.recover]
The directory where recovery files are stored.
redraw, re [off]
VVii only. Simulate an intelligent terminal on a dumb one.
Split screens
The command ``:sp[lit] [file ...]'' splits the screen in vi mode.
The key ``^W'' switches between the foreground screens, and the
``:resize count'' command can be used to grow or shrink any par-
ticular screen.
_T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_.
remap [on]
Remap keys until resolved.
remapmax [on]
Limit the number of times a key may be remapped.
report [5]
Set the number of lines about which the editor reports changes.
ruler [off]
VVii only. Display a row/column ruler on the colon command line.
scroll, scr [window / 2]
Set the number of lines scrolled.
sections, sect [NHSHH HUnhsh]
VVii only. Define additional section boundaries for the [[[[ and ]]]]
commands.
shell, sh [environment variable SHELL, or /bin/sh]
Select the shell used by the editor.
shiftwidth, sw [8]
Set the autoindent and shift command indentation width.
showdirty [off]
VVii only. Display an asterisk on the colon command line if the file
has been modified.
showmatch, sm [off]
VVii only. Note matching ``{'' and ``('' for ``}'' and ``)'' charac-
ters.
showmode [off]
VVii only. Display the current editor mode (command or input).
sidescroll [16]
VVii only. Set the amount a left-right scroll will shift.
slowopen, slow [off]
Delay display updating during text input.
_T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_.
sourceany [off]
Read startup files not owned by the current user.
_T_h_i_s _o_p_t_i_o_n _w_i_l_l _n_e_v_e_r _b_e _i_m_p_l_e_m_e_n_t_e_d_.
tabstop, ts [8]
This option sets tab widths for the editor display.
taglength, tl [0]
Set the number of significant characters in tag names.
tags, tag [tags /var/db/libc.tags /sys/kern/tags]
Set the list of tags files.
term, ttytype, tty [environment variable TERM]
Set the terminal type.
terse [off]
This option has historically made editor messages less verbose. It
has no effect in this implementation.
timeout, to [on]
Time out on keys which may be mapped.
ttywerase [off]
VVii only. Select an alternate erase algorithm.
verbose [off]
only. Display an error message for every error.
w300 [no default]
VVii only. Set the window size if the baud rate is less than 1200
baud.
w1200 [no default]
VVii only. Set the window size if the baud rate is equal to 1200
baud.
w9600 [no default]
VVii only. Set the window size if the baud rate is greater than 1200
baud.
warn [on]
EExx only. This option causes a warning message to the terminal if
the file has been modified, since it was last written, before a !!
command.
window, w, wi [environment variable LINES]
Background and foreground screens
The command ``:bg'' backgrounds the current screen, and the com-
mand ``:fg [file]'' foregrounds the backgrounded screeen that is
editing the specified file, or, by default, the first background
screen on the queue. The command ``:di[splay] s[creens]'' lists
the background screens.
Set the window size for the screen.
wrapmargin, wm [0]
VVii only. Break lines automatically when they reach the right-hand
margin.
wrapscan, ws [on]
Set searches to wrap around the end or beginning of the file.
writeany, wa [off]
Turn off file-overwriting checks.
Shell screens
The command ``:sc[ript] [file ...]'' runs a shell in the screen.
Editing is unchanged, with the exception that a <carriage-return>
enters the current line (stripped of any prompt) as input to the
shell.
FFAASSTT SSTTAARRTTUUPP
This section will tell you the minimum amount that you need to do simple
editing tasks using vvii. If you've never used any screen editor before,
you're likely to have problems even with this simple introduction. In
that case you should find someone that already knows vvii and have them
walk you through this section.
Tag stacks
Tags are now maintained in a stack. The command ``^T'' returns
to the previous tag location. The command ``:tagpop [number
file]'' returns to the most recent tag location by default, or,
optionally to a specific tag number in the tag stack, or the most
recent tag from the specified file. Use the command ``:di[splay]
t[ags]'' to view the tags stack. The command ``:tagtop'' returns
to the top of the tag stack.
VVii is a screen editor. This means that it takes up almost the entire
screen, displaying part of the file on each screen line, except for the
last line of the screen. The last line of the screen is used for you to
give commands to vvii, and for vvii to give information to you.
New displays
The command ``:di[splay] b[uffers] s[creens] t[ags]'' can be
used to display, respectively, the current cut buffers, the back-
grounded screens, and the tags stack.
The other fact that you need to understand is that vvii is a modeful edi-
tor, i.e. you are either entering text or you are executing commands, and
you have to be in the right mode to do one or the other. You will be in
command mode when you first start editing a file. There are commands
that switch you into input mode. There is only one key that takes you
out of input mode, and that is the <escape> key. (Key names are written
using less-than and greater-than signs, e.g. <escape> means the
``escape'' key, usually labeled ``esc'' on your terminal's keyboard.) If
you're ever confused as to which mode you're in, keep entering the <es-
cape> key until vvii beeps at you. (Generally, vvii will beep at you if you
try and do something that's not allowed. It will also display error mes-
sages.)
Infinite undo
The changes made during an edit session may be rolled backward
and forward. A '.' command immediately after a 'u' command con-
tinues either forward or backward depending on whether the 'u'
command was an undo or a redo.
To start editing a file, enter the command ``vi file_name<carriage-
return>''. The command you should enter as soon as you start editing is
``:set verbose showmode<carriage-return>''. This will make the editor
give you verbose error messages and display the current mode at the bot-
tom of the screen.
Usage information
The command ``:exu[sage [cmd]'' and ``viu[sage] [key]'' provide
usage information for all of the ex and vi commands by default,
or, optionally, for a specific command or key.
The commands to move around the file are:
hh Move the cursor left one character.
jj Move the cursor down one line.
kk Move the cursor up one line.
ll Move the cursor right one character.
<<ccuurrssoorr--aarrrroowwss>>
The cursor arrow keys should work, too.
//tteexxtt<<ccaarrrriiaaggee--rreettuurrnn>>
Search for the string ``text'' in the file, and move the cursor to
its first character.
Extended regular expressions
The ``:set extended'' command treats search and other command
regular expressions as extended (egrep(1) style) regular expres-
sions.
The commands to enter new text are:
aa Append new text, _a_f_t_e_r the cursor.
ii Insert new text, _b_e_f_o_r_e the cursor.
oo Open a new line below the line the cursor is on, and start entering
text.
OO Open a new line above the line the cursor is on, and start entering
text.
<<eessccaappee>>
Once you've entered input mode using the one of the aa, ii, OO, or oo
commands, use <<eessccaappee>> to quit entering text and return to command
mode.
Word search
The command ``^A'' searches for the word referenced by the cur-
sor.
The commands to copy text are:
Number increment
The command ``#'' increments the number referenced by the cursor.
Previous file
The command ``:prev[ious][!]'' edits the previous file from the
argument list.
yyyy Copy the line the cursor is on.
pp Append the copied line after the line the cursor is on.
Left-Right scrolling
The command ``:set leftright'' makes nnvvii do left-right screen
scrolling, instead of the traditional vvii line wrapping.
The commands to delete text are:
dddd Delete the line the cursor is on.
xx Delete the character the cursor is on.
RREECCOOVVEERRYY
There is no recovery program for nvi, nor does it run setuid. Users may
recover any file which they may read, and the superuser may recover any
edit session.
The commands to write the file are:
::ww<<ccaarrrriiaaggee--rreettuurrnn>>
Write the file back to the file with the name that you originally
used as an argument on the vvii command line.
::ww ffiillee__nnaammee<<ccaarrrriiaaggee--rreettuurrnn>>
Write the file back to the file with the name ``file_name''.
Edit sessions are backed by files in _/_v_a_r_/_t_m_p_/_v_i_._r_e_c_o_v_e_r, and are named
``vi.XXXX'', where ``XXXX'' is a number related to the process id. When
a file is first modified, a second file, which contains an email message
for the user, is created, and is named ``recover.XXXX'', where, again,
``XXXX'' is associated with the process id. Both files are removed at
the end of a normal edit session, but will remain if the edit session is
abnormally terminated or the user enters the ex/vi ``preserve'' command.
The use of the _/_v_a_r_/_t_m_p directory may be changed setting the option
``recdir'' in the user's or system startup information.
The commands to quit editing and exit the editor are:
::qq<<ccaarrrriiaaggee--rreettuurrnn>>
Quit editing and leave vi (if you've modified the file, but not
saved your changes, vvii will refuse to quit).
::qq!!<<ccaarrrriiaaggee--rreettuurrnn>>
Quit, discarding any modifications that you may have made.
The recovery directory should have the ``sticky-bit'' set so that only
the owners of files may remove them. If this is not possible on the sys-
tem, then a pseudo-user should own the recovery directory. The recovery
directory must be both read and write-able by any user.
The recovery file has all of the necessary information in it to enable
the user to recover the edit session. In addition, it has all of the
necessary email headers for sendmail. When the system is rebooted, all
of the files in _/_v_a_r_/_t_m_p_/_v_i_._r_e_c_o_v_e_r named ``recover.XXXX'' should be sent
by email, using the --tt flag of sendmail (or a similar mechanism in other
mailers). A simple way to do this is to insert the following script into
your rc.local (or other startup) file:
# Recover nvi editor files.
virecovery=/var/tmp/vi.recover/recover.*
if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
echo 'Recovering vi editor sessions'
for i in $virecovery; do
sendmail -t < $i
done
fi
If nneexx//nnvvii receives a hangup (SIGHUP) signal, it will email the recovery
information to the user itself.
If you don't have the sendmail program on your system, the source file
_n_v_i_/_r_e_c_o_v_e_r_._c will have to be modified to use your mail delivery pro-
grams.
One final caution. Unusual characters can take up more than one column
on the screen, and long lines can take up more than a single screen line.
The above commands work on ``physical'' characters and lines, i.e. they
affect the entire line no matter how many screen lines it takes up and
the entire character no matter how many screen columns it takes up.
BBUUGGSS
This man page is woefully incomplete.
Many and varied. See the file _n_v_i_/_d_o_c_s_/_b_u_g_s_._c_u_r_r_e_n_t for a list of the
known bugs in this version.
See the file _n_v_i_/_d_o_c_s_/_b_u_g_s_._c_u_r_r_e_n_t for a list of the known bugs in this
version.
FFIILLEESS
/tmp Storage for temporary files.
/var/tmp/vi.recover Storage for recovery files.
/bin/sh The default user shell.
/etc/vi.exrc System-wide vi startup file.
/tmp Temporary file directory.
/var/tmp/vi.recover Recovery file directory.
$HOME/.nexrc 1st choice for user's home directory startup file.
$HOME/.exrc 2nd choice for user's home directory startup file.
.nexrc 1st choice for local directory startup file.
.exrc 2nd choice for local directory startup file.
SSEEEE AALLSSOO
ctags(1), more(1), curses(3), dbopen(3)
@ -201,64 +385,15 @@ SSEEEE AALLSSOO
NNrrooffff//ttrrooffff source for the previous three documents are distributed with
nneexx//nnvvii in the _n_v_i_/_d_o_c_s_/_U_S_D_._d_o_c directory of the nneexx//nnvvii source code.
The files ``autowrite'', ``input'', and ``quoting'', found in the
_n_v_i_/_d_o_c_s directory of the nneexx//nnvvii source code.
The files ``autowrite'', ``input'', ``quoting'', and ``structures'',
found in the _n_v_i_/_d_o_c_s_/_i_n_t_e_r_n_a_l_s directory of the nneexx//nnvvii source code.
HHIISSTTOORRYY
The nneexx//nnvvii replacements for eexx//vvii first appeared in 4.4BSD.
The nneexx//nnvvii replacements for the eexx//vvii editor first appeared in 4.4BSD.
SSTTAANNDDAARRDDSS
NNeexx//nnvvii is fairly close to IEEE Std1003.2 (``POSIX''), but it's not there
yet.
NNeexx//nnvvii is close to IEEE Std1003.2 (``POSIX''). That document differs
from historical eexx//vvii practice in several places; there are changes to be
made on both sides.
4.4BSD March 19, 1994 7

544
usr.bin/vi/docs/vi.ref Normal file
View File

@ -0,0 +1,544 @@
.\" Copyright (c) 1994
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)vi.ref 8.19 (Berkeley) 3/18/94
.\"
.Dd "March 18, 1994"
.Dt "EX/VI REFERENCE MANUAL" 1
.Os
.Sh NAME
.Nm ex, vi, view
.Nd text editors
.Sh DESCRIPTION
.Nm \&Vi
is a screen oriented text editor.
.Nm \&Ex
is a line-oriented text editor.
.Nm \&Ex
and
.Nm \&vi
are different interfaces to the same program,
and it is possible to switch back and forth during an edit session.
.Nm View
is the equivalent of using the
.Fl R
(read-only) option of
.Nm \&vi .
.Pp
This reference manual is the one provided with the
.Nm nex/nvi
versions of the
.Nm ex/vi
text editors.
.Nm Nex/nvi
are intended as bug-for-bug compatible replacements for the original
Fourth Berkeley Software Distribution (4BSD)
.Nm \&ex
and
.Nm \&vi
programs.
This reference manual is accompanied by a traditional-style manual page.
That manual page describes the functionality found in
.Nm ex/vi
in far less detail than the description here.
In addition, it describes the system interface to
.Nm ex/vi ,
e.g. command line options, environmental variables, and similar things.
.Pp
This reference is intended for users already familiar with
.Nm ex/vi .
Anyone else should almost certainly read a good tutorial on the
editor first.
If you're in an unfamiliar environment, and you absolutely have to
get work done immediately, see the section entitled FAST STARTUP
in the manual page.
It's probably enough to get you going.
.Pp
For the rest of this reference,
.Nm nex/nvi
is used only when it's necessary to distinguish it from the historic
implementations of
.Nm ex/vi .
.Sh ADDITIONAL FEATURES
There are a few features in
.Nm nex/nvi
that are not found in historic versions of
.Nm ex/vi .
A list of those features is as follows:
.Bl -tag -width indent
.It "8-bit clean data, large lines, files"
.Nm \&Nvi/nex
will edit any format file.
Line lengths are limited by available memory,
and file sizes are limited by available disk space.
The command
.Dq "^Vx[0-9A-Fa-f]* ,"
in input mode, will insert any
legal character value into the text.
.It "Split screens"
The command
.Dq ":sp[lit] [file ...]"
splits the screen in vi mode.
The key
.Dq "^W"
switches between the foreground screens,
and the
.Dq ":resize count"
command can be used to grow or shrink a particular screen.
.It "Background and foreground screens"
The command
.Dq ":bg"
backgrounds the current screen,
and the command
.Dq ":fg [file]"
foregrounds the backgrounded screen
that is editing the specified file, or, by default, the first background
screen on the queue.
The command
.Dq ":di[splay] s[creens]"
lists the background screens.
.It "Shell screens"
The command
.Dq ":sc[ript] [file ...]"
runs a shell in the screen.
Editing is unchanged, with the exception that a <carriage-return>
enters the current line (stripped of any prompt) as input to the
shell.
.It "Tag stacks"
Tags are now maintained in a stack.
The command
.Dq "^T"
returns to the previous tag location.
The command
.Dq ":tagpop [number \| file]"
returns to the most recent tag
location by default, or, optionally to a specific tag number in the
tag stack, or the most recent tag from the specified file.
Use the command
.Dq ":di[splay] t[ags]"
to view the tags stack.
The command
.Dq ":tagtop"
returns to the top of the tag stack.
.It "New displays"
The command
.Dq ":di[splay] b[uffers] \| s[creens] \| t[ags]"
can be
used to display, respectively, the current cut buffers,
the backgrounded screens, and the tags stack.
.It "Infinite undo"
The changes made during an edit session may be rolled backward and
forward.
A '.' command immediately after a 'u' command continues either forward
or backward depending on whether the 'u' command was an undo or a redo.
.It "Usage information"
The command
.Dq ":exu[sage] [cmd]"
and
.Dq "viu[sage] [key]"
provide usage
information for all of the ex and vi commands by default, or, optionally,
for a specific command or key.
.It "Extended regular expressions"
The
.Dq ":set extended"
command treats search and other command regular
expressions as extended (egrep(1) style) regular expressions.
.It "Word search"
The command
.Dq "^A"
searches for the word referenced by the cursor.
.It "Number increment"
The command
.Dq "#"
increments the number referenced by the cursor.
.It "Previous file"
The command
.Dq ":prev[ious][!]"
edits the previous file from the
argument list.
.It "Left-Right scrolling"
The command
.Dq ":set leftright"
makes
.Nm nvi
do left-right screen scrolling, instead of the traditional
.Nm \&vi
line wrapping.
.Sh RECOVERY
There is no recovery program for
.Nm nvi ,
nor does
.Nm nvi
run setuid.
Users may recover any file which they may read, and the superuser
may recover any edit session.
.Pp
Edit sessions are backed by files in
.Pa /var/tmp/vi.recover ,
and are named
.Dq "vi.XXXX" ,
where
.Dq "XXXX"
is a number related to the process id.
When a file is first modified, a second file, which contains an
email message for the user, is created, and is named
.Dq "recover.XXXX" ,
where, again,
.Dq "XXXX"
is associated with the process id.
Both files are removed at the end of a normal edit session,
but will remain if the edit session is abnormally terminated
or the user enters the ex/vi
.Dq "preserve"
command.
The use of the
.Pa /var/tmp
directory may be changed setting the
.Sy recdir
option in the user's or system startup information.
.Pp
The recovery directory should have the
.Dq "sticky-bit"
set so that only the owners of files may remove them.
If this is not possible on the system, then a pseudo-user should
own the recovery directory.
The recovery directory must be both read and write-able by
any user.
.Pp
The recovery file has all of the necessary information in it to enable the
user to recover the edit session.
In addition, it has all of the necessary email headers for sendmail.
When the system is rebooted, all of the files in
.Pa /var/tmp/vi.recover
named
.Dq "recover.XXXX"
should be sent by email,
using the
.Fl t
flag of sendmail (or a similar mechanism in other mailers).
A simple way to do this is to insert the following script into your
.Pa /etc/rc.local
(or other startup) file:
.ne 7v
.Bd -literal -offset indent -compact
# Recover nvi editor files.
virecovery=`echo /var/tmp/vi.recover/recover.*`
if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
echo 'Recovering vi editor sessions'
for i in $virecovery; do
sendmail -t < $i
done
fi
.Ed
.Pp
If
.Nm ex/vi
receives a hangup (SIGHUP) signal, it will email the recovery
information to the user itself.
.Pp
If you don't have the sendmail program on your system, the source file
.Pa nvi/recover.c
will have to be modified to use your local mail delivery programs.
.Sh STARTUP INFORMATION
.Nm Ex/vi
interprets one of two possible environmental variables and reads up
to three of five possible files during startup.
The variables and files are expected to contain
.Nm \&ex
commands, not
.Nm \&vi
commands.
In addition, they are interpreted
.Em before
the file to be edited is read, and therefore many
.Nm \&ex
commands may not be used.
Generally, any command that requires output to the screen or that
needs a file upon which to operate, will cause an error if included
in a startup file or environmental variable.
.Pp
First, the file
.Pa /etc/vi.exrc
is read.
Second, the environmental variable
.Ev NEXINIT
(or the variable
.Ev EXINIT ,
if
.Ev NEXINIT
isn't set) is interpreted.
Third, if neither
.Ev NEXINIT
or
.Ev EXINIT
was set, the file
.Pa $HOME/.nexrc
(or the file
.Pa $HOME/.exrc ,
if
.Pa $HOME/.nexrc
doesn't exist) is read.
Fourth, the file
.Pa .nexrc
(or the file
.Pa .exrc ,
if
.Pa .nexrc
doesn't exist) is read.
.Pp
Startup files will not be read if they are owned by anyone other
than the real user-id of the user running
.Nm \&vi ,
(or by
.Dq root
in the case of the file
.Pa /etc/vi.exrc )
or if they are writable by anyone other than the owner.
Home directory startup files (i.e.
.Pa $HOME/.nexrc
and
.Pa $HOME/.exrc )
will not be read if the
.Dq HOME
environmental variable is not set.
Local startup files (i.e.
.Pa .nexrc
and
.Pa .exrc )
will not be read if the
.Sy exrc
option is turned off in the
.Pa /etc/vi.exrc ,
.Pa $HOME/.nexrc ,
or
.Pa $HOME/.exrc
files, or in the
.Ev NEXINIT
or
.Ev EXINIT
environmental variables.
It is not an error for any of the startup environmental variables
or files not to exist.
.Pp
Because the
.Nm \&ex
command set supported by
.Nm nex/nvi
is a superset of the command set supported by most historical implementations
of
.Nm \&ex ,
.Nm nex/nvi
can use the startup files created for the historical implementations,
but the converse is often not true.
.Sh SIZING THE SCREEN
The size of the screen can be set in a number of ways.
.Nm Ex/vi
takes the following steps until values are obtained for both the
number of rows and number of columns in the screen.
.sp
.Bl -enum -compact
.It
If the environmental variable
.Ev LINES
exists, it is used to specify the number of rows in the screen.
.It
If the environmental variable
.Ev COLUMNS
exists, it is used to specify the number of columns in the screen.
.It
The TIOCGWINSZ
.Xr ioctl 2
is attempted on the standard error file descriptor.
.It
The termcap entry is checked for the
.Dq \&li
entry (rows) and the
.Dq \&co
entry (columns).
.It
The number of rows is set to 24, and the number of columns is set
to 80.
.El
.Pp
If a window change size signal (SIGWINCH) is received,
the same steps are taken with the exception that the first two steps
are skipped.
.Sh REGULAR EXPRESSIONS AND REPLACEMENT STRINGS
Regular expressions are used in line addresses,
as the first part of
.Sy substitute ,
.Sy global ,
and
.Sy vglobal
commands,
and in search patterns.
.Pp
The regular expressions supported by
.Nm \&ex
and
.Nm \&vi
are, by default, the Basic Regular Expressions (BRE's) described in the
IEEE POSIX Standard 1003.2.
The
.Sy extended
option causes all regular expressions to be interpreted as the Extended
Regular Expressions (ERE's) described by the same standard.
(See
.Xr re_format 7
for more information.
Generally speaking, BRE's are
.Xr ed 1
and
.Xr grep 1
style regular expressions, and ERE's are
.Xr egrep 1
style regular expressions.)
.Pp
There are some special strings and characters that can be used in
RE's:
.Bl -enum -compact
.It
An empty RE (e.g.
.Dq \&// )
is equivalent to the last RE used.
.It
The construct
.Dq \e<
matches the beginning of a word.
.It
The construct
.Dq \e>
matches the end of a word.
.It
The character
.Dq \&~
matches the replacement part of the last
.Sy substitute
command.
.El
.Pp
When the
.Sy magic
option is
.Em not
set,
the only characters with special meanings are
.Dq \&^
at the beginning of an RE,
.Dq \&$
at the end of an RE, and the escaping character
.Dq \&\e .
The characters
.Dq \&. ,
.Dq \&* ,
.Dq \&[ ,
and
.Dq \&~
are treated as ordinary characters unless preceded by a
.Dq \&\e ;
when preceded by a
.Dq \&\e
they regain their special meaning.
.Pp
Replacement strings are the second part of a
.Sy substitute
command.
.Pp
The character
.Dq \&&
(or
.Dq \e&
if the
.Sy magic
option is
.Em not
set) in the replacement string stands for the text matched by the RE
that's being replaced.
The character
.Dq \&~
(or
.Dq \e~
if the
.Sy magic
option is
.Em not
set) stands for the replacement part of the previous
.Sy substitute
command.
.Pp
The string
.Dq \e# ,
where
.Dq \&#
is an integer value from 1 to 9, stands for the text matched by
the portion of the RE enclosed in the #'th set of escaped parentheses,
e.g.
.Dq \e(
and
.Dq \e) .
For example,
.Dq "s/abc\e(.*\e)def/\e1/"
deletes the strings
.Dq abc
and
.Dq def
from the matched pattern.
.Pp
The strings
.Dq \el ,
.Dq \eu ,
.Dq \eL ,
and
.Dq \eU
can be used to modify the case of elements in the replacement string.
The string
.Dq \el
causes the next character to be converted to lowercase; the string
.Dq \eu
behaves similarly, but converts to uppercase.
The strings
.Dq \eL
causes characters up to the end of the string or the next occurrence of
the strings
.Dq \ee
or
.Dq \eE
to be converted to lowercase; the string
.Dq \eU
behaves similarly, but converts to uppercase.
.Pp
In
.Nm \&vi ,
inserting a <control-M> into the replacement string will cause the
matched line to be split into two lines at that point.
.Sh SET OPTIONS
#include <set.opt.roff>

1108
usr.bin/vi/docs/vi.ref.ps Normal file

File diff suppressed because it is too large Load Diff

634
usr.bin/vi/docs/vi.ref.txt Normal file
View File

@ -0,0 +1,634 @@
EX/VI REFERENCE MANUAL(1) BSD Reference Manual EX/VI REFERENCE MANUAL(1)
NNAAMMEE
eexx,, vvii,, vviieeww - text editors
DDEESSCCRRIIPPTTIIOONN
VVii is a screen oriented text editor. EExx is a line-oriented text editor.
EExx and vvii are different interfaces to the same program, and it is possi-
ble to switch back and forth during an edit session. VViieeww is the equiva-
lent of using the --RR (read-only) option of vvii.
This reference manual is the one provided with the nneexx//nnvvii versions of
the eexx//vvii text editors. NNeexx//nnvvii are intended as bug-for-bug compatible
replacements for the original Fourth Berkeley Software Distribution
(4BSD) eexx and vvii programs. This reference manual is accompanied by a
traditional-style manual page. That manual page describes the function-
ality found in eexx//vvii in far less detail than the description here. In
addition, it describes the system interface to eexx//vvii, e.g. command line
options, environmental variables, and similar things.
This reference is intended for users already familiar with eexx//vvii. Anyone
else should almost certainly read a good tutorial on the editor first.
If you're in an unfamiliar environment, and you absolutely have to get
work done immediately, see the section entitled FAST STARTUP in the manu-
al page. It's probably enough to get you going.
For the rest of this reference, nneexx//nnvvii is used only when it's necessary
to distinguish it from the historic implementations of eexx//vvii.
AADDDDIITTIIOONNAALL FFEEAATTUURREESS
There are a few features in nneexx//nnvvii that are not found in historic ver-
sions of eexx//vvii. A list of those features is as follows:
8-bit clean data, large lines, files
NNvvii//nneexx will edit any format file. Line lengths are limited by
available memory, and file sizes are limited by available disk
space. The command ``^Vx[0-9A-Fa-f]*'', in input mode, will in-
sert any legal character value into the text.
Split screens
The command ``:sp[lit] [file ...]'' splits the screen in vi mode.
The key ``^W'' switches between the foreground screens, and the
``:resize count'' command can be used to grow or shrink a partic-
ular screen.
Background and foreground screens
The command ``:bg'' backgrounds the current screen, and the com-
mand ``:fg [file]'' foregrounds the backgrounded screen that is
editing the specified file, or, by default, the first background
screen on the queue. The command ``:di[splay] s[creens]'' lists
the background screens.
Shell screens
The command ``:sc[ript] [file ...]'' runs a shell in the screen.
Editing is unchanged, with the exception that a <carriage-return>
enters the current line (stripped of any prompt) as input to the
shell.
Tag stacks
Tags are now maintained in a stack. The command ``^T'' returns
to the previous tag location. The command ``:tagpop [number
file]'' returns to the most recent tag location by default, or,
optionally to a specific tag number in the tag stack, or the most
recent tag from the specified file. Use the command ``:di[splay]
t[ags]'' to view the tags stack. The command ``:tagtop'' returns
to the top of the tag stack.
New displays
The command ``:di[splay] b[uffers] s[creens] t[ags]'' can be
used to display, respectively, the current cut buffers, the back-
grounded screens, and the tags stack.
Infinite undo
The changes made during an edit session may be rolled backward
and forward. A '.' command immediately after a 'u' command con-
tinues either forward or backward depending on whether the 'u'
command was an undo or a redo.
Usage information
The command ``:exu[sage] [cmd]'' and ``viu[sage] [key]'' provide
usage information for all of the ex and vi commands by default,
or, optionally, for a specific command or key.
Extended regular expressions
The ``:set extended'' command treats search and other command
regular expressions as extended (egrep(1) style) regular expres-
sions.
Word search
The command ``^A'' searches for the word referenced by the cur-
sor.
Number increment
The command ``#'' increments the number referenced by the cursor.
Previous file
The command ``:prev[ious][!]'' edits the previous file from the
argument list.
Left-Right scrolling
The command ``:set leftright'' makes nnvvii do left-right screen
scrolling, instead of the traditional vvii line wrapping.
RREECCOOVVEERRYY
There is no recovery program for nnvvii, nor does nnvvii run setuid. Users may
recover any file which they may read, and the superuser may recover any
edit session.
Edit sessions are backed by files in _/_v_a_r_/_t_m_p_/_v_i_._r_e_c_o_v_e_r, and are named
``vi.XXXX'', where ``XXXX'' is a number related to the process id. When
a file is first modified, a second file, which contains an email message
for the user, is created, and is named ``recover.XXXX'', where, again,
``XXXX'' is associated with the process id. Both files are removed at
the end of a normal edit session, but will remain if the edit session is
abnormally terminated or the user enters the ex/vi ``preserve'' command.
The use of the _/_v_a_r_/_t_m_p directory may be changed setting the rreeccddiirr op-
tion in the user's or system startup information.
The recovery directory should have the ``sticky-bit'' set so that only
the owners of files may remove them. If this is not possible on the sys-
tem, then a pseudo-user should own the recovery directory. The recovery
directory must be both read and write-able by any user.
The recovery file has all of the necessary information in it to enable
the user to recover the edit session. In addition, it has all of the
necessary email headers for sendmail. When the system is rebooted, all
of the files in _/_v_a_r_/_t_m_p_/_v_i_._r_e_c_o_v_e_r named ``recover.XXXX'' should be sent
by email, using the --tt flag of sendmail (or a similar mechanism in other
mailers). A simple way to do this is to insert the following script into
your _/_e_t_c_/_r_c_._l_o_c_a_l (or other startup) file:
virecovery=`echo /var/tmp/vi.recover/recover.*`
if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
echo 'Recovering vi editor sessions'
for i in $virecovery; do
sendmail -t < $i
done
fi
If eexx//vvii receives a hangup (SIGHUP) signal, it will email the recovery
information to the user itself.
If you don't have the sendmail program on your system, the source file
_n_v_i_/_r_e_c_o_v_e_r_._c will have to be modified to use your local mail delivery
programs.
SSTTAARRTTUUPP IINNFFOORRMMAATTIIOONN
EExx//vvii interprets one of two possible environmental variables and reads up
to three of five possible files during startup. The variables and files
are expected to contain eexx commands, not vvii commands. In addition, they
are interpreted _b_e_f_o_r_e the file to be edited is read, and therefore many
eexx commands may not be used. Generally, any command that requires output
to the screen or that needs a file upon which to operate, will cause an
error if included in a startup file or environmental variable.
First, the file _/_e_t_c_/_v_i_._e_x_r_c is read. Second, the environmental variable
NEXINIT (or the variable EXINIT, if NEXINIT isn't set) is interpreted.
Third, if neither NEXINIT or EXINIT was set, the file _$_H_O_M_E_/_._n_e_x_r_c (or
the file _$_H_O_M_E_/_._e_x_r_c, if _$_H_O_M_E_/_._n_e_x_r_c doesn't exist) is read. Fourth,
the file _._n_e_x_r_c (or the file _._e_x_r_c, if _._n_e_x_r_c doesn't exist) is read.
Startup files will not be read if they are owned by anyone other than the
real user-id of the user running vvii, (or by ``root'' in the case of the
file _/_e_t_c_/_v_i_._e_x_r_c) or if they are writable by anyone other than the own-
er. Home directory startup files (i.e. _$_H_O_M_E_/_._n_e_x_r_c and _$_H_O_M_E_/_._e_x_r_c)
will not be read if the ``HOME'' environmental variable is not set. Lo-
cal startup files (i.e. _._n_e_x_r_c and _._e_x_r_c) will not be read if the eexxrrcc
option is turned off in the _/_e_t_c_/_v_i_._e_x_r_c, _$_H_O_M_E_/_._n_e_x_r_c, or _$_H_O_M_E_/_._e_x_r_c
files, or in the NEXINIT or EXINIT environmental variables. It is not an
error for any of the startup environmental variables or files not to ex-
ist.
Because the eexx command set supported by nneexx//nnvvii is a superset of the com-
mand set supported by most historical implementations of eexx, nneexx//nnvvii can
use the startup files created for the historical implementations, but the
converse is often not true.
SSIIZZIINNGG TTHHEE SSCCRREEEENN
The size of the screen can be set in a number of ways. EExx//vvii takes the
following steps until values are obtained for both the number of rows and
number of columns in the screen.
1. If the environmental variable LINES exists, it is used to specify
the number of rows in the screen.
2. If the environmental variable COLUMNS exists, it is used to specify
the number of columns in the screen.
3. The TIOCGWINSZ ioctl(2) is attempted on the standard error file de-
scriptor.
4. The termcap entry is checked for the ``li'' entry (rows) and the
``co'' entry (columns).
5. The number of rows is set to 24, and the number of columns is set to
80.
If a window change size signal (SIGWINCH) is received, the same steps are
taken with the exception that the first two steps are skipped.
RREEGGUULLAARR EEXXPPRREESSSSIIOONNSS AANNDD RREEPPLLAACCEEMMEENNTT SSTTRRIINNGGSS
Regular expressions are used in line addresses, as the first part of
ssuubbssttiittuuttee, gglloobbaall, and vvgglloobbaall commands, and in search patterns.
The regular expressions supported by eexx and vvii are, by default, the Basic
Regular Expressions (BRE's) described in the IEEE POSIX Standard 1003.2.
The eexxtteennddeedd option causes all regular expressions to be interpreted as
the Extended Regular Expressions (ERE's) described by the same standard.
(See re_format(7) for more information. Generally speaking, BRE's are
ed(1) and grep(1) style regular expressions, and ERE's are egrep(1) style
regular expressions.)
There are some special strings and characters that can be used in RE's:
1. An empty RE (e.g. ``//'') is equivalent to the last RE used.
2. The construct ``\<'' matches the beginning of a word.
3. The construct ``\>'' matches the end of a word.
4. The character ``~'' matches the replacement part of the last
ssuubbssttiittuuttee command.
When the mmaaggiicc option is _n_o_t set, the only characters with special mean-
ings are ``^'' at the beginning of an RE, ``$'' at the end of an RE, and
the escaping character ``\''. The characters ``.'', ``*'', ``['', and
``~'' are treated as ordinary characters unless preceded by a ``\''; when
preceded by a ``\'' they regain their special meaning.
Replacement strings are the second part of a ssuubbssttiittuuttee command.
The character ``&'' (or ``\&'' if the mmaaggiicc option is _n_o_t set) in the re-
placement string stands for the text matched by the RE that's being re-
placed. The character ``~'' (or ``\~'' if the mmaaggiicc option is _n_o_t set)
stands for the replacement part of the previous ssuubbssttiittuuttee command.
The string ``\#'', where ``#'' is an integer value from 1 to 9, stands
for the text matched by the portion of the RE enclosed in the #'th set of
escaped parentheses, e.g. ``\('' and ``\)''. For example,
``s/abc\(.*\)def/\1/'' deletes the strings ``abc'' and ``def'' from the
matched pattern.
The strings ``\l'', ``\u'', ``\L'', and ``\U'' can be used to modify the
case of elements in the replacement string. The string ``\l'' causes the
next character to be converted to lowercase; the string ``\u'' behaves
similarly, but converts to uppercase. The strings ``\L'' causes charac-
ters up to the end of the string or the next occurrence of the strings
``\e'' or ``\E'' to be converted to lowercase; the string ``\U'' behaves
similarly, but converts to uppercase.
In vvii, inserting a <control-M> into the replacement string will cause the
matched line to be split into two lines at that point.
SSEETT OOPPTTIIOONNSS
There are a large number of options that may be set (or unset) to change
the editor's behavior. This section describes the options, their abbre-
viations and their default values.
In each entry below, the first part of the tag line is the full name of
the option, followed by any equivalent abbreviations. (Regardless of the
abbreviations, it is only necessary to use the minimum number of charac-
ters necessary to distinguish an abbreviation from all other commands for
it to be accepted, in nneexx//nnvvii. Historically, only the full name and the
official abbreviations were accepted by eexx//vvii. Using full names in your
startup files and environmental variables will probably make them more
portable.) The part in square brackets is the default value of the op-
tion. Most of the options are boolean, i.e. they are either on or off,
and do not have an associated value.
Options apply to both eexx and vvii modes, unless otherwise specified.
For information on modifying the options or to display the options and
their current values, see the ``set'' command in the Ex Commands section.
altwerase [off]
VVii only. Change how vvii does word erase during text input. When
this option is set, text is broken up into three classes: alphabet-
ic, numeric and underscore characters, other non-blank characters,
and blank characters. Changing from one class to another marks the
end of a word. In addition, the class of the first character
erased is ignored (which is exactly what you want when erasing
pathname components).
autoindent, ai [off]
If this option is set, whenever you create a new line (using the vvii
AA, aa, CC, cc, II, ii, OO, oo, RR, rr, SS, and ss commands, or the eexx aappppeenndd,
cchhaannggee, and iinnsseerrtt commands) the new line is automatically indented
to align the cursor with the first non-blank character of the line
from which you created it. Lines are indented using tab characters
to the extent possible (based on the value of the ttaabbssttoopp option)
and then using space characters as necessary. For commands insert-
ing text into the middle of a line, any blank characters to the
right of the cursor are discarded, and the first non-blank charac-
ter to the right of the cursor is aligned as described above.
The indent characters are themselves somewhat special. If you do
not enter more characters on the new line before moving moving to
another line, or entering <escape>, the indent character will be
deleted and the line will be empty. For example, if you enter
<carriage-return> twice in succession, the line created by the
first <carriage-return> will not have any characters in it, regard-
less of the indentation of the previous or subsequent line.
Indent characters also require that you enter additional erase
characters to delete them. For example, if you have an indented
line, containing only blanks, the first <word-erase> character you
enter will erase up to end of the indent characters, and the second
will erase back to the beginning of the line. (Historically, only
the ^^DD key would erase the indent characters. Both the ^^DD key and
the usual erase keys work in nnvvii ..)) In addition, if the cursor is
positioned at the end of the indent characters, the keys ``0^D''
will erase all of the indent characters for the current line, re-
setting the indentation level to 0. Similarly, the keys ``^^D''
(i.e. a carat followed by a <control-D>) will erase all of the in-
dent characters for the current line, leaving the indentation level
for future created lines unaffected.
Finally, if aauuttooiinnddeenntt is set, the SS and cccc commands change from
the first non-blank of the line to the end of the line, instead of
from the beginning of the line to the end of the line.
autoprint, ap [off]
EExx only. EExx only. Cause the current line to be automatically dis-
played after the eexx commands <<, >>, ccooppyy, ddeelleettee, jjooiinn, mmoovvee, ppuutt,
tt, UUnnddoo, and uunnddoo. This automatic display is suppressed during
gglloobbaall and vvgglloobbaall commands, and for any command where optional
flags are used to explicitly display the line.
autowrite, aw [off]
If this option is set, the vvii !! ^^^^ ^^]] and ^^ZZ commands, and the eexx
eeddiitt, nneexxtt, rreewwiinndd, ssttoopp, ssuussppeenndd, ttaagg, ttaaggppoopp, and ttaaggttoopp commands
automatically write the current file back to the current file name
if it has been modified since it was last written. If the write
fails, the command fails and goes no further.
Appending the optional force flag ``!'' to the eexx commands nneexxtt,
rreewwiinndd, ssttoopp, ssuussppeenndd, ttaagg, ttaaggppoopp, and ttaaggttoopp stops the automatic
write from being attempted.
(Historically, the nneexxtt command ignored the optional force flag.)
Note, the eexx commands eeddiitt, qquuiitt, sshheellll, and xxiitt are _n_o_t affected
by the aauuttoowwrriittee option.
beautify, bf [off]
If this option is set, all control characters that are not current-
ly being specially interpreted, other than <tab>, <newline>, and
<form-feed>, are discarded from commands read in by eexx from command
files, and from input text entered to vvii (either into the file or
to the colon command line). Text files read by eexx//vvii are _n_o_t af-
fected by the bbeeaauuttiiffyy option.
cdpath [environment variable CDPATH, or ``.'']
This option is used to specify a colon separated list of directo-
ries which are used as path prefixes for any relative path names
used as arguments for the ccdd command. The value of this option de-
faults to the value of the environmental variable CDPATH if it is
set, otherwise to the current directory. For compatibility with
the POSIX 1003.2 shell, the ccdd command does _n_o_t check the current
directory as a path prefix for relative path names unless it is ex-
plicitly specified. It may be so specified by entering an empty
string or a ``.'' into the CDPATH variable or the option value.
columns, co [80]
The number of columns in the screen. Setting this option causes
eexx//vvii to set (or reset) the environmental variable COLUMNS. See the
SCREEN SIZING section for more information.
comment [off]
VVii only. If the first non-empty line of the file begins with the
string ``/*'', this option causes vvii to skip to the end of that C
comment (probably a terribly boring legal notice) before displaying
the file.
directory, dir [environment variable TMPDIR, or /tmp]
The directory where temporary files are created. The environmental
variable TMPDIR is used as the default value if it exists, other-
wise _/_t_m_p is used.
edcompatible, ed [off]
This option causes the presence or absence of gg and cc suffixes on
ssuubbssttiittuuttee commands to be remembered, and to be toggled by repeat-
ing the suffices. The suffix rr makes the substitution be as in the
~~ command, instead of like the && command.
_T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_.
errorbells, eb [off]
EExx only. Causes eexx error messages to be preceded by a bell.
_T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_.
exrc, ex [off]
If this option is turned off in the system or $HOME startup files,
the local startup files are never read (unless they are the same as
the system or $HOME startup files). Turning it on has no effect,
i.e. the normal checks for local startup files are performed, re-
gardless. See the STARTUP INFORMATION section for more informa-
tion.
extended [off]
This option causes all regular expressions to be treated as POSIX
1003.2 extended regular expressions (which are similar to historic
egrep(1) style expressions).
flash [on]
This option causes the screen to flash instead of beeping the key-
board, on error, if the terminal has the capability.
hardtabs, ht [8]
This option defines the spacing between hardware tab settings, i.e.
the tab expansion done by the operating system and/or the terminal
itself. As nneexx//nnvvii never writes tabs to the terminal, unlike his-
toric versions of eexx//vvii, this option does not currently have any
affect.
ignorecase, ic [off]
This option causes regular expressions, both in eexx commands and in
searches, to be evaluated in a case-insensitive manner.
keytime [6]
The 10th's of a second eexx//vvii waits for a subsequent key to complete
a key mapping.
leftright [off]
VVii only. This option causes the screen to be scrolled left-right
to view lines longer than the screen, instead of the traditional vvii
screen interface which folds long lines at the right-hand margin of
the terminal.
lines, li [24]
VVii only. The number of lines in the screen. Setting this option
causes eexx//vvii to set (or reset) the environmental variable LINES.
See the Screen Sizing section for more information.
lisp [off]
VVii only. This option changes the behavior of the vvii ((, )), {{, }}, [[[[
and ]]]] commands to match the Lisp language. Also, the aauuttooiinnddeenntt
option's behavior is changed to be appropriate for Lisp.
_T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_.
list [off]
This option causes lines to be displayed in an unambiguous fashion.
Specifically, tabs are displayed as control characters, i.e.
``^I'', and the ends of lines are marked with a ``$'' character.
magic [on]
This option is on by default. Turning the mmaaggiicc option off causes
all regular expression characters except for ``^'' and ``$'', to be
treated as ordinary characters. To re-enable characters individu-
ally, when the mmaaggiicc option is off, precede them with an ``\''. See
the REGULAR EXPRESSIONS AND REPLACEMENT STRINGS section for more
information.
matchtime [7]
VVii only. The 10th's of a second eexx//vvii pauses on the matching char-
acter when the sshhoowwmmaattcchh option is set.
mesg [on]
This option allows other users to contact you using the talk(1) and
write(1) utilities, while you are editing. EExx//vvii does not turn
message on, i.e. if messages were turned off when the editor was
invoked, they will stay turned off. This option only permits you
to disallow messages for the edit session. See the mesg(1) utility
for more information.
modelines, modeline [off]
If the mmooddeelliinneess option is set, eexx//vvii has historically scanned the
first and last five lines of each file as it is read for editing,
looking for any eexx commands that have been placed in those lines.
After the startup information has been processed, and before the
user starts editing the file, any commands embedded in the file are
executed. Commands are recognized by the letters ``e'' or ``v''
followed by ``x'' or ``i'', at the beginning of a line or following
a tab or space character, and followed by a ``:'', an eexx command,
and another ``:''. This option is a security problem of immense
proportions, and should not be used under any circumstances.
_T_h_i_s _o_p_t_i_o_n _w_i_l_l _n_e_v_e_r _b_e _i_m_p_l_e_m_e_n_t_e_d_.
number, nu [off]
Precede each line displayed with its current line number.
open [on]
EExx only. If this option is not set, the ooppeenn and vviissuuaall commands
are disallowed.
optimize, opt [on]
VVii only. Throughput of text is expedited by setting the terminal
to no do automatic carriage returns when printing more than one
(logical) line of output, greatly speeding output on terminals
without addressable cursors when text with leading white space is
printed.
_T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_.
paragraphs, para [IPLPPPQPP LIpplpipbp]
VVii only. Define additional paragraph boundaries for the {{ and }}
commands. The value of this option must be a character string con-
sisting of zero or more character pairs.
In the text to be edited, the character string <newline>.<char-
pair>, (where <char-pair> is one of the character pairs in the op-
tion's value) defines a paragraph boundary. For example, if the
option were set to ``LaA ##'', then all of the following additional
paragraph boundaries would be recognized:
<newline>.La
<newline>.A<space>
<newline>.##
prompt [on]
EExx only. This option causes eexx to prompt for command input with a
``:'' character; when it's not set, no prompt is displayed.
readonly, ro [off]
This option causes a force flag to be required to attempt to write
the file back to the original file name. Setting this option is
equivalent to using the --RR command line option, or editing a file
which lacks write permission.
recdir [/var/tmp/vi.recover]
The directory where recovery files are stored.
redraw, re [off]
VVii only. The editor simulates (using great amounts of output), an
intelligent terminal on a dumb terminal (e.g. during insertions in
visual mode the characters to the right of the cursor are refreshed
as each input character is typed).
_T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_.
remap [on]
If this option is set, it's possible to define macros in terms of
other macros. Otherwise, each key is only remapped up to one time.
For example, if ``A'' is mapped to ``B'', and ``B'' is mapped to
``C'', The keystroke ``A'' will be mapped to ``C'' if rreemmaapp is set,
and to ``B'' if it is not set.
remapmax [on]
If this option is set, a key may only be remapped 50 times. If it
is not set, a key may be remapped an infinite number of times, and
the editor can be placed into infinite loops.
report [5]
Set the threshold of the number of lines that need to be changed
before a message will be displayed to the user. The value is the
largest value about which the editor is silent, i.e. by default, 6
lines must change before the user is notified.
ruler [off]
VVii only. Display a row/column ruler on the colon command line.
scroll, scr [window / 2]
Set the number of lines scrolled by the vvii commands ^^DD and ^^UU.
Historically, the eexx zz command, when specified without a count,
used two times the size of the scroll value; the POSIX 1003.2 stan-
dard specified the window size, which is a better choice.
sections, sect [NHSHH HUnhsh]
VVii only. Define additional section boundaries for the [[[[ and ]]]]
commands. The sseeccttiioonnss option should be set to a character string
consisting of zero or more character pairs. In the text to be
edited, the character string <newline>.<char-pair>, (where <char-
pair> is one of the character pairs in the option's value), defines
a section boundary in the same manner that ppaarraaggrraapphh option bound-
aries are defined.
shell, sh [environment variable SHELL, or /bin/sh]
Select the shell used by the editor. The specified path is the
pathname of the shell invoked by the vvii !! shell escape command and
by the eexx sshheellll command. This program is also used to resolve any
shell meta-characters in eexx commands.
shiftwidth, sw [8]
Set the autoindent and shift command indentation width. This width
is used by the aauuttooiinnddeenntt option and by the <<, >>, and sshhiifftt com-
mands.
showdirty [off]
VVii only. Display an asterisk on the colon command line if the file
has been modified.
showmatch, sm [off]
VVii only. This option causes vvii, when a ``}'' or ``)'' is entered,
to briefly move the cursor the matching ``{'' or ``(''. See the
mmaattcchhttiimmee option for more information.
showmode [off]
VVii only. This option causes vvii to display the strings ``Command''
or ``Input'' on the colon command line, based on the current mode
of the editor.
sidescroll [16]
VVii only. Sets the number of columns that are shifted to the left
or right, when vvii is doing left-right scrolling and the left or
right margin is crossed. See the lleeffttrriigghhtt option for more infor-
mation.
slowopen, slow [off]
This option affects the display algorithm used by vvii, holding off
display updating during input of new text to improve throughput
when the terminal in use is slow and unintelligent.
_T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_.
sourceany [off]
If this option is turned on, vvii historically read startup files
that were owned by someone other than the editor user. See the
STARTUP INFORMATION section for more information. This option is a
security problem of immense proportions, and should not be used un-
der any circumstances.
_T_h_i_s _o_p_t_i_o_n _w_i_l_l _n_e_v_e_r _b_e _i_m_p_l_e_m_e_n_t_e_d_.
tabstop, ts [8]
This option sets tab widths for the editor display.
taglength, tl [0]
This option sets the maximum number of characters that are consid-
ered significant in a tag name. Setting the value to 0 makes all
of the characters in the tag name significant.
tags, tag [tags /var/db/libc.tags /sys/kern/tags]
Sets the list of tags files, in search order, which are used when
the editor searches for a tag.
term, ttytype, tty [environment variable TERM]
Set the terminal type. Setting this option causes eexx//vvii to set (or
reset) the environmental variable TERM.
terse [off]
This option has historically made editor messages less verbose. It
has no effect in this implementation. See the vveerrbboossee option for
more information.
timeout, to [on]
If this option is set, eexx//vvii waits for a specific period for a sub-
sequent key to complete a key mapping (see the kkeeyyttiimmee option). If
the option is not set, the editor waits until enough keys are en-
tered to resolve the ambiguity, regardless of how long it takes.
ttywerase [off]
VVii only. This option changes how vvii does word erase during text
input. If this option is set, text is broken up into two classes,
blank characters and non-blank characters. Changing from one class
to another marks the end of a word.
verbose [off]
only. VVii historically bells the terminal for many obvious mis-
takes, e.g. trying to move past the left-hand margin, or past the
end of the file. If this option is set, an error message is dis-
played for all errors.
w300 [no default]
VVii only. Set the window size if the baud rate is less than 1200
baud. See the wwiinnddooww option for more information.
w1200 [no default]
VVii only. Set the window size if the baud rate is equal to 1200
baud. See the wwiinnddooww option for more information.
w9600 [no default]
VVii only. Set the window size if the baud rate is greater than 1200
baud. See the wwiinnddooww option for more information.
warn [on]
EExx only. This option causes a warning message to the terminal if
the file has been modified, since it was last written, before a !!
command.
window, w, wi [environment variable LINES]
This option determines the default number of lines in a screenful,
as written by the zz command. It also determines the number of
lines scrolled by the vvii commands ^^FF and ^^BB. The value of window
can be unrelated to the real screen size, although it starts out as
the number of lines on the screen (see the SCREEN SIZING section).
Setting the value of the wwiinnddooww option is the same as using the --ww
command line option.
If the value of wwiinnddooww (as set by the wwiinnddooww, ww330000, ww11220000 or ww99660000
options) is smaller than the actual size of the screen, large
screen movements will result in displaying only that smaller number
of lines on the screen. (Further movements in that same area will
result in the screen being filled.) This can provide a performance
improvement when viewing different places in one or more files over
a slow link.
wrapmargin, wm [0]
VVii only. If the value of wrapmargin is non-zero, vvii will break
lines, that are more than that number of characters long, into two
lines at the blank character closest to the value. If wrapmargin
is 0, or if there is no blank character upon which to break the
line, the line will not be broken.
wrapscan, ws [on]
This option causes searches to wrap around the end or the beginning
of the file, and back to the starting point. Otherwise, the end or
beginning of the file terminates the search.
writeany, wa [off]
If this option is set, file-overwriting checks that would usually
be made before the wwrriittee and xxiitt commands, or before an automatic
write (see the aauuttoowwrriittee option), are not made. This allows a
write to any file, provided the file permissions allow it.
4.4BSD March 18, 1994 10

179
usr.bin/vi/intr.c Normal file
View File

@ -0,0 +1,179 @@
/*-
* Copyright (c) 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static char sccsid[] = "@(#)intr.c 8.1 (Berkeley) 3/23/94";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/time.h>
#include <bitstring.h>
#include <errno.h>
#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include "compat.h"
#include <db.h>
#include <regex.h>
#include "vi.h"
/*
* There's a count of how deep the interrupt level in the SCR structure
* has gone. Each routine that wants to be interrupted increments this
* level, and decrements it when it tears the interrupts down. There are
* two simplifying assumptions:
*
* 1: All interruptible areas want the same handler (we don't have
* to save/restore the old handler).
* 2: This is the only way to turn on interrupts (we don't have to
* worry about them already being turned on if the interrupt
* level is 0).
*
* We do it this way because interrupts have to be very fast -- if the
* O_REMAPMAX option is turned off, we are setting interrupts per key
* stroke.
*
* If an interrupt arrives, the S_INTERRUPTED bit is set in any SCR that
* has the S_INTERRUPTIBLE bit set. In the future this may be a problem.
* The user should be able to move to another screen and keep typing while
* another screen runs. Currently, if the user does this and the user has
* more than one interruptible thing running, there will be no way to know
* which one to stop.
*/
static void intr_def __P((int));
/*
* intr_init --
* Set up a interrupts.
*/
int
intr_init(sp)
SCR *sp;
{
struct sigaction act;
struct termios nterm;
/* You can never interrupt sessions not using tty's. */
if (!F_ISSET(sp->gp, G_STDIN_TTY))
return (1);
/* If interrupts already set up, just increase the level. */
if (sp->intr_level++)
return (0);
/* Turn interrupts on in this screen. */
F_SET(sp, S_INTERRUPTIBLE);
/* Install a handler. */
act.sa_handler = intr_def;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
if (sigaction(SIGINT, &act, &sp->intr_act)) {
msgq(sp, M_SYSERR, "sigaction");
goto err1;
}
/*
* Turn on interrupts. ISIG turns on VINTR, VQUIT and VSUSP. We
* want VINTR to interrupt, so we install a handler. VQUIT is
* ignored by main() because nvi never wants to catch it. A handler
* for VSUSP should have been installed by the screen code.
*/
if (tcgetattr(STDIN_FILENO, &sp->intr_term)) {
msgq(sp, M_SYSERR, "tcgetattr");
goto err2;
}
nterm = sp->intr_term;
nterm.c_lflag |= ISIG;
if (tcsetattr(STDIN_FILENO, TCSANOW | TCSASOFT, &nterm)) {
msgq(sp, M_SYSERR, "tcsetattr");
/*
* If an error occurs, back out the changes and run
* without interrupts.
*/
err2: (void)sigaction(SIGINT, &sp->intr_act, NULL);
err1: sp->intr_level = 0;
F_CLR(sp, S_INTERRUPTIBLE);
return (1);
}
return (0);
}
/*
* intr_end --
* Tear down interrupts.
*/
void
intr_end(sp)
SCR *sp;
{
/* If not the bottom level of interrupts, just return. */
if (--sp->intr_level)
return;
/* Turn off interrupts. */
if (tcsetattr(STDIN_FILENO, TCSANOW | TCSASOFT, &sp->intr_term))
msgq(sp, M_SYSERR, "tcsetattr");
/* Reset the signal state. */
if (sigaction(SIGINT, &sp->intr_act, NULL))
msgq(sp, M_SYSERR, "sigaction");
/* Clear interrupt bits in this screen. */
F_CLR(sp, S_INTERRUPTED | S_INTERRUPTIBLE);
}
/*
* intr_def --
* Default interrupt handler.
*/
static void
intr_def(signo)
int signo;
{
SCR *sp;
for (sp = __global_list->dq.cqh_first;
sp != (void *)&__global_list->dq; sp = sp->q.cqe_next)
if (F_ISSET(sp, S_INTERRUPTIBLE))
F_SET(sp, S_INTERRUPTED);
}

249
usr.bin/vi/put.c Normal file
View File

@ -0,0 +1,249 @@
/*-
* Copyright (c) 1992, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static char sccsid[] = "@(#)put.c 8.3 (Berkeley) 3/14/94";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/time.h>
#include <bitstring.h>
#include <ctype.h>
#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include "compat.h"
#include <db.h>
#include <regex.h>
#include "vi.h"
/*
* put --
* Put text buffer contents into the file.
*
* !!!
* Historically, pasting into a file with no lines in vi would preserve
* the single blank line. This is almost certainly a result of the fact
* that historic vi couldn't deal with a file that had no lines in it.
* This implementation treats that as a bug, and does not retain the blank
* line.
*/
int
put(sp, ep, cbp, namep, cp, rp, append)
SCR *sp;
EXF *ep;
CB *cbp;
CHAR_T *namep;
MARK *cp, *rp;
int append;
{
CHAR_T name;
TEXT *ltp, *tp;
recno_t lno;
size_t blen, clen, len;
char *bp, *p, *t;
if (cbp == NULL)
if (namep == NULL) {
cbp = sp->gp->dcbp;
if (cbp == NULL) {
msgq(sp, M_ERR, "The default buffer is empty.");
return (1);
}
} else {
name = *namep;
CBNAME(sp, cbp, name);
if (cbp == NULL) {
msgq(sp, M_ERR,
"Buffer %s is empty.", charname(sp, name));
return (1);
}
}
tp = cbp->textq.cqh_first;
/*
* It's possible to do a put into an empty file, meaning that the
* cut buffer simply becomes the file. It's a special case so
* that we can ignore it in general.
*
* Historical practice is that the cursor ends up on the first
* non-blank character of the first line inserted.
*/
if (cp->lno == 1) {
if (file_lline(sp, ep, &lno))
return (1);
if (lno == 0) {
for (; tp != (void *)&cbp->textq;
++lno, tp = tp->q.cqe_next)
if (file_aline(sp, ep, 1, lno, tp->lb, tp->len))
return (1);
rp->lno = 1;
rp->cno = 0;
(void)nonblank(sp, ep, rp->lno, &rp->cno);
goto ret;
}
}
/* If a line mode buffer, append each new line into the file. */
if (F_ISSET(cbp, CB_LMODE)) {
lno = append ? cp->lno : cp->lno - 1;
rp->lno = lno + 1;
for (; tp != (void *)&cbp->textq; ++lno, tp = tp->q.cqe_next)
if (file_aline(sp, ep, 1, lno, tp->lb, tp->len))
return (1);
rp->cno = 0;
(void)nonblank(sp, ep, rp->lno, &rp->cno);
goto ret;
}
/*
* If buffer was cut in character mode, replace the current line with
* one built from the portion of the first line to the left of the
* split plus the first line in the CB. Append each intermediate line
* in the CB. Append a line built from the portion of the first line
* to the right of the split plus the last line in the CB.
*
* Get the first line.
*/
lno = cp->lno;
if ((p = file_gline(sp, ep, lno, &len)) == NULL) {
GETLINE_ERR(sp, lno);
return (1);
}
GET_SPACE_RET(sp, bp, blen, tp->len + len + 1);
t = bp;
/* Original line, left of the split. */
if (len > 0 && (clen = cp->cno + (append ? 1 : 0)) > 0) {
memmove(bp, p, clen);
p += clen;
t += clen;
}
/* First line from the CB. */
memmove(t, tp->lb, tp->len);
t += tp->len;
/* Calculate length left in original line. */
clen = len ? len - cp->cno - (append ? 1 : 0) : 0;
/*
* If no more lines in the CB, append the rest of the original
* line and quit. Otherwise, build the last line before doing
* the intermediate lines, because the line changes will lose
* the cached line.
*/
if (tp->q.cqe_next == (void *)&cbp->textq) {
/*
* Historical practice is that if a non-line mode put
* is inside a single line, the cursor ends up on the
* last character inserted.
*/
rp->lno = lno;
rp->cno = (t - bp) - 1;
if (clen > 0) {
memmove(t, p, clen);
t += clen;
}
if (file_sline(sp, ep, lno, bp, t - bp))
goto mem;
} else {
/*
* Have to build both the first and last lines of the
* put before doing any sets or we'll lose the cached
* line. Build both the first and last lines in the
* same buffer, so we don't have to have another buffer
* floating around.
*
* Last part of original line; check for space, reset
* the pointer into the buffer.
*/
ltp = cbp->textq.cqh_last;
len = t - bp;
ADD_SPACE_RET(sp, bp, blen, ltp->len + clen);
t = bp + len;
/* Add in last part of the CB. */
memmove(t, ltp->lb, ltp->len);
if (clen)
memmove(t + ltp->len, p, clen);
clen += ltp->len;
/*
* Now: bp points to the first character of the first
* line, t points to the last character of the last
* line, t - bp is the length of the first line, and
* clen is the length of the last. Just figured you'd
* want to know.
*
* Output the line replacing the original line.
*/
if (file_sline(sp, ep, lno, bp, t - bp))
goto mem;
/*
* Historical practice is that if a non-line mode put
* covers multiple lines, the cursor ends up on the
* first character inserted. (Of course.)
*/
rp->lno = lno;
rp->cno = (t - bp) - 1;
/* Output any intermediate lines in the CB. */
for (tp = tp->q.cqe_next;
tp->q.cqe_next != (void *)&cbp->textq;
++lno, tp = tp->q.cqe_next)
if (file_aline(sp, ep, 1, lno, tp->lb, tp->len))
goto mem;
if (file_aline(sp, ep, 1, lno, t, clen)) {
mem: FREE_SPACE(sp, bp, blen);
return (1);
}
}
FREE_SPACE(sp, bp, blen);
/* Reporting... */
ret: sp->rptlines[L_PUT] += lno - cp->lno;
return (0);
}

89
usr.bin/vi/vi/v_zexit.c Normal file
View File

@ -0,0 +1,89 @@
/*-
* Copyright (c) 1992, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static char sccsid[] = "@(#)v_zexit.c 8.7 (Berkeley) 3/8/94";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/time.h>
#include <bitstring.h>
#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include "compat.h"
#include <db.h>
#include <regex.h>
#include "vi.h"
#include "excmd.h"
#include "vcmd.h"
/*
* v_zexit -- ZZ
* Save the file and exit.
*/
int
v_zexit(sp, ep, vp)
SCR *sp;
EXF *ep;
VICMDARG *vp;
{
if (F_ISSET(ep, F_MODIFIED) &&
file_write(sp, ep, NULL, NULL, NULL, FS_ALL))
return (1);
/*
* !!!
* Historic practice: quit! or two quit's done in succession
* (where ZZ counts as a quit) didn't check for other files.
*
* Check for related screens; quit if they exist, the user will
* get a message on the last screen.
*/
if (sp->ccnt != sp->q_ccnt + 1 &&
ep->refcnt <= 1 && file_unedited(sp) != NULL) {
sp->q_ccnt = sp->ccnt;
msgq(sp, M_ERR,
"More files to edit; use \":n\" to go to the next file");
return (1);
}
F_SET(sp, S_EXIT);
return (0);
}