Important Command-Line Arguments

In a pure BSD environment, nvi is installed under the names ex, vi, and view. Typically they are all links to the same executable, and nvi looks at how it is invoked to determine its behavior. (Unix vi works this way, too.) It allows the Q command from vi mode to switch it into ex mode. The view variant is like vi, except that the readonly option is set initially.

nvi has a number of command-line options. The most useful are described here:

-c command

Execute command upon startup. This is the POSIX version of the historical +command syntax, but nvi is not limited to positioning commands. (The old syntax is also accepted.)

-F

Don’t copy the entire file when starting to edit. This may be faster, but it allows the possibility of someone else changing the file while you’re working on it.

-r

Recover specified files, or if no files are listed on the command line, list all the files that can be recovered.

-R

Start in read-only mode, setting the readonly option.

-s

Enter batch (script) mode. This is only for ex and is intended for running editing scripts. Prompts and nonerror messages are disabled. This is the POSIX version of the historic “-” argument; nvi supports both.

-S

Run with the secure option set, disallowing access to external programs.[53]

-t tag

Start editing at the specified tag.

-w size

Set the initial window size to size lines.

[53] As with anything labeled “secure,” blind trust is usually inappropriate. Keith Bostic says, though, that you can trust ...

Get Learning the vi and Vim Editors, 7th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.