elvis has a number of interesting features:
Like nvi,
elvis also has a home-grown method for
allowing translations of messages into different languages.
The elvis.msg file is searched for along
the elvispath
and loaded into a buffer named
Elvis messages
.
Messages have the form
"terse message:
long message."
Before printing a message, elvis looks up the
terse form, and if there is a corresponding long form, that
message is used.
Otherwise, the terse message is used.
This is perhaps the most interesting of elvis' features. For certain kinds of files, elvis formats the file content on the screen, giving a surprisingly good approximation of a WYSIWYG effect. elvis can also use the same formatting for printing the buffer to several kinds of printers. Display modes get their own subsection, below.
elvis loads four files (if they exist), that allow you to customize its behavior before and after reading and writing a file. This feature also gets its own subsection, below.
elvis is the only one of the clones that actually implements vi's open mode. (Think of open mode as like vi, but with only a one-line window. The "advantage" to open mode is that it can be used on terminals that don't have cursor motion capabilities.)
The :safer
command sets the safer
option for execution of non-home-directory .exrc
files, or any other untrusted files. When safer
is set, "certain commands are disabled, wildcard
expansion in filenames is disabled, and certain options are locked (including
the safer
option itself)".
The elvis documentation is no more
specific than this; don't blindly trust elvis to
provide complete security for you.
elvis extends the ex command
language with a built-in calculator (sometimes referred to as
an expression evaluator in the documentation). It understands C
expression syntax, and is most used in the :if
,
:calc
, and :eval
commands.
See the online help for the details, as well as the sample
initialization files in the elvis distribution
for examples.
elvis 2.1 has a debugger for vi
macros (the :map
command). This can be useful when
writing complicated input or command maps.
elvis has several display modes. Depending on the kind of file, elvis produces a formatted version of the file, producing a WYSIWYG effect. The display modes are outlined in Table 10.11.
Mode | Display Appearance |
---|---|
normal | |
syntax | |
hex | An interactive hex dump, reminiscent of mainframe hex dumps. This is good for editing binary files. |
html | A simple Web page formatter. The tag commands can be used to follow links and return. |
man |
The :normal
command will switch the display from
one of the formatted views to normal
mode.
Use :display
mode
to switch back. As a shortcut, the ^W d
command will toggle the display modes for the window.
Of the available modes, html
and man
are the most WYSIWYG in nature.
The online documentation clearly defines the subset of both
markup languages that elvis understands.
elvis uses
the html
mode for displaying its online
help, which is written in HTML and has many
cross-referencing links within it.
The example below shows elvis editing one of the
HTML help files. The screen is split. Both windows show the
same buffer; the bottom window is using the html
display mode, while the top is using the normal
display mode:
<html><head> <title>Elvis 2.0 Sessions</title> </head><body> <h1>10. SESSIONS, INITIALIZATION, AND RECOVERY</h1> This section of the manual describes the life-cycle of an edit session. We begin with the definition of an <a href="#SESSION">edit session</a> and what that means to elvis. This is followed by sections discussing <a href="#INIT">initialization</a> and <a href="#RECOVER">recovery after a crash.</a> _____________________________________________________________________ 10.0 SESSIONS, INITIALIZATION, AND RECOVERY This section of the manual describes the life-cycle of an edit session. We begin with the definition of an edit session and what that means to elvis. This is followed by sections discussing initialization and recovery after a crash. 10.1 Sessions
The man
mode is also interesting, since
normally you have to format and print a man page to be sure you've
done a decent job of laying it out.
The following quote from the online help seems appropriate.
Troff source was never designed to be interactively edited, and although I did the best I could, attempting to edit in
man
mode is still a disorienting experience. I suggest you get in the habit of usingnormal
mode when making changes, andman
mode to preview the effect of those changes. The^W d
command makes switching between modes a pretty easy thing to do.
As an interesting adjunct, both the html
and man
modes also work with the
:color
command described in
Section 10.9.2, "Syntax Highlighting".
This is particularly nice with man
mode.
For example,
by default on a Linux console, only bold text (.B)
is distinguishable
from normal text. But with syntax coloring on, both bold and
italic (.I) text become distinct.
The mode commands are summarized in
Table 10.12.
Command | Function |
---|---|
di [splay ] [mode [lang ]] | |
no[ |
Associated with each window is the bufdisplay
option, which should be set to one of the supported display modes.
The standard elvis.arf file (see the
next subsection) will look at the extension of the buffer's
filename and attempt to set the display to a more interesting mode
than normal
.
Finally, elvis can also apply its WYSIWYG formatting
to printing the contents of a buffer.
The :lpr
command formats a line range (or the
whole buffer, by default) for printing.
You can print to a file or down a pipe to a command.
By default, elvis prints to a pipe
that executes the system print spooling command.
The :lpr
command is controlled by several
options, described in Table 10.13.
Option | Function |
---|---|
lptype , lp | |
lpconvert , lpcvt | If set, convert Latin-8 extended ASCII to PC-8 extended ASCII. |
lpcrlf , lpc | |
lpout , lpo | |
lpcolumns , lpcols | |
lpwrap , lpw | |
lplines , lprows | |
lpformfeed , lpff | |
lppaper , lpp | The size of the paper (letter, a4, etc.). This only matters for PostScript printers. |
Most of the options are self-explanatory. elvis supports several printer types, as described in Table 10.14.
Name | Printer Type |
---|---|
ps | |
ps2 | PostScript, two logical pages per sheet of paper. |
epson | |
pana | |
ibm | |
hp | Hewlett-Packard printers, and most non-PostScript laser printers. |
cr | |
bs | Overtyping is done via backspace characters. This setting is the closest to traditional UNIX nroff. |
dumb |
If you have a PostScript printer, by all means use an lptype
of ps
or ps2
. Use the latter to
save paper, which is particularly handy when printing drafts.
elvis gives you the ability to control its
actions at four points when reading and writing files:
before and after reading a file, and before and
after writing a file.
It does this by executing the contents of four ex
scripts at those respective points.
These scripts are searched for using the directories listed in the
elvispath
option.
This file is executed Before Reading a File.
The default version looks at the file's extension,
and attempts to guess whether or not the file is binary.
If it is, the binary
option is turned on,
to prevent elvis from converting newlines
(which may be actual CR-LF pairs in the file) into
linefeeds internally.
This file is executed After Reading a File. The default version examines the file's extension in order to turn on syntax highlighting.
This file is executed Before Writing a File,
in particular, before completely replacing an original file
with the contents of the buffer.
The default version implements copying the original file to
a file with a .bak extension.
You must set the backup
option for this to work.
This file is executed After Writing a File. There is no default file for this, although it might be a good place to add hooks into a source code control system.
The use of command files to control these actions is quite powerful. It allows you to easily tailor elvis' behavior to suit your needs; in other editors these kinds of features are much more hardwired into the code.