1. Starting ex
Each instance of the editor has a set of options,
which can be set to tailor it to your liking.
The command
edit
invokes a version of
ex
designed for more casual or beginning
users by changing the default settings of some of these options.
To simplify the description which follows we
assume the default settings of the options.
When invoked,
ex
determines the terminal type from the TERM variable in the environment.
It there is a TERMCAP variable in the environment, and the type
of the terminal described there matches the TERM variable,
then that description
is used. Also if the TERMCAP variable contains a pathname (beginning
with a /) then the editor will seek the description of the terminal
in that file (rather than the default /etc/termcap).
If there is a variable EXINIT in the environment, then the editor
will execute the commands in that variable,
otherwise if there is a file
.exrc
in your HOME directory
ex
reads commands from that file, simulating a
source
command.
Option setting commands placed in
EXINIT or
.exrc
will be executed before each editor session.
A command to enter
ex
has the following prototype:**
-
ex [ - ] [ -v ] [ -t tag ] [ -r ] [ -l ] [ -wn ] [ -x ] [ -R ] [ +command ] name ...
The most common case edits a single file with no options, i.e.:
-
ex name
The
-
command line option
option suppresses all interactive-user feedback
and is useful in processing editor scripts in command files.
The
-v
option is equivalent to using
vi
rather than
ex.
The
-t
option is equivalent to an initial
tag
command, editing the file containing the
tag
and positioning the editor at its definition.
The
-r
option is used in recovering after an editor or system crash,
retrieving the last saved version of the named file or,
if no file is specified,
typing a list of saved files.
The
-l
option sets up for editing LISP, setting the
showmatch
and
lisp
options.
The
-w
option sets the default window size to
n,
and is useful on dialups to start in small windows.
The
-x
option causes
ex
to prompt for a
key,
which is used to encrypt and decrypt the contents of the file,
which should already be encrypted using the same key,
see
crypt(1).
The
-R
option sets the
readonly
option at the start.
Name
arguments indicate files to be edited.
An argument of the form
+command
indicates that the editor should begin by executing the specified command.
If
command
is omitted, then it defaults to ``$'', positioning the editor at the last
line of the first file initially. Other useful commands here are scanning
patterns of the form ``/pat'' or line numbers, e.g. ``+100'' starting
at line 100.