E

Section: Misc. Reference Manual Pages (P)
Updated: November 16, 1988
Index Return to Main Contents
 

NAME

e - command line preprocessor for the vi(1) editor.  

SYNOPSIS

e [ option ] [ file ] ...  

DESCRIPTION

e is an interface to vi(1) that maintains a history of the most recently e'ed files for each directory. Using the history, it is both fast and simple to re-edit previously e'ed files.

In addition, e does spelling corrections on its arguments, fast lookup and editing of files in other directories, and allows for the inheritance of .exrc files in other directories. It also closes the modeline security hole, making it possible to ensure that no .exrc file that you don't own is ever seen by vi.

 

INVOCATION

The invocation syntax is (almost) a superset of that of vi. A list of the interesting command line variations is given below. [x] indicates that "x" is optional. "cmd" means an ex(1) command.
e
Invokes vi on the last file that was e'ed in this directory.
e -
Prints the history for this directory and allows fast selection of a previous file - or a new one.
e .
Prints the history for this directory without asking for input.
e -pat
vi's the last file that was e'ed with the string "pat" on the command line.
e +[cmd]
vi's the last file that was e'ed in this directory, but executes command "cmd" on entering vi.
e [+[cmd]] file
vi's the file and adds it to the history list. Minor spelling corrections are suggested if "file" does not exist but is close (in spelling) to some file that does.
e [+[cmd]] files
vi's the files and adds them as a single entry to the history.

The vi(1) options -r, -v, -x, -w and -R are all passed as is to vi and so behave as would be expected.  

EXAMPLE

Assume here that you are in the directory /tmp/mydir and that it contains (only) the files "death", "main.c", "pete.c", "bigmac" and "fries"; and that your e history file contains

/tmp/mydir death
+/main.c pete.c
bigmac
fries

"e ." will show you the history...

[3]: death
[2]: +/main pete.c
[1]: bigmac
[0]: fries

"e" by itself will get you immediately back into "fries".

"e -" will present the same as shown for "e .", but will ask for a number or another filename. Carriage return is equivalent to zero (i.e. the last filename), backspace or interrupt will quit.

"e -2" will get you immediately into "pete.c", searching for "main" on entering vi.

"e -ath" searches for the pattern "ath", finds it in "death", and that's what you get.

"e +10" will get you into "fries" on line 10 (assuming it has 10 lines).  

THE HISTORY

A single history file is kept. Its default location is $HOME/.e but this can be changed with the VIHIST environment variable. The history is rearranged with each use to place the last e'ed file at the end of the list. Duplicate entries are removed. The number of history items kept for each directory is 8. Seeing as the list is ordered by use, this number is ample.

The history file consists of entries composed of a directory name followed by lines of file names (oldest to newest). Each filename is preceded by a single TAB character. The directory names are all absolute pathnames.  

FILENAME CORRECTION

If you make a simple spelling mistake when typing a file name, e will detect it, ask whether it was really what you meant, and offer suggestions. Errors that are detected are: wrong character, omitted character, interchanged characters and extra character.

In the above example, "e bigamc" will prompt you with
"correct to bigmac [y]?"

Answering "n" will not do the correction, "Q" or "q" will quit. If there is more than one possible correction, you will be prompted for each in turn. A response of "N" means that you really want what you typed, and no further corrections will be offered. Any other response (e.g. a RETURN) will do the correction for you.  

CROSS-DIRECTORY EDITING

The environment variable VIPATH can be used to enable fast lookup and editing of files in different directories. It should contain a list of directories that you want searched when e cannot find the file you request in the current directory. Here is an example:

Suppose you are in the directory /bin with VIPATH set to /usr/include/sys

"e inode.h" will prompt you with
"/usr/include/sys/inode.h [y]?"

since /bin/inode.h does not exist, but /usr/include/sys/inode.h does. You can say "n" or "q" to reject or quit. "N" will reject the current suggestion and searching for further ones will be stopped. Any other response (e.g. a RETURN) is taken as a yes.

It is handy to have $HOME in your VIPATH, this gives you easy access from anywhere to commonly used files.

If you accept a suggestion, then the file is put into the history. Spelling corrections are not suggested across directories. There is (of course) no need to put "." in your VIPATH. Doing so will just slow things down and cannot possibly be of help. This should be clear, "." is always searched first for the given filename. Putting it into your VIPATH will have it searched twice. The directory names in VIPATH may be separated by white space (including newlines) and colons.  

.exrc INHERITANCE

If you set the environment variable "VIINHERIT", e will look for a .exrc file in the directory where the (first) file you are about to edit resides. If it finds one, it arranges to read it as though it were in the directory from which you issued the e command. This is very useful as many people have specialised .exrc files in their directory trees.

For instance, in a directory of C source you might like to set autoindent and showmatch, whereas in a directory that contained correspondence, you might want neither of these, but wrapmargin and ignorecase instead. Inherited .exrc files allow you to e files in other directories and get the results intended by the .exrc files in them.

There is a drawback however. vi has an option called "modeline" which makes it possible for a malicious user to leave a trojan-horse type file in a directory with a specially prepared .exrc file that turns on "modeline". As a result, if you cd to that directory and vi the wrong file, then the modeline feature allows the other user to execute commands as you. Not nice.

If you set "VISAFEINHERIT", e will make sure that you never get caught by this one. In short, it notices when this could happen and changes directory to avoid the .exrc. There is no need to have "VIINHERIT" set if all you want to do is avoid the security problem. But setting them both gives you the best of both worlds. (See the NOTES for the drawback...)  

NOTES

When using "e -", the terminal is put into cbreak mode. If the first character typed is a digit (in the acceptable range of history items) then you will get that history item without further ado. Thus if you have a file called 4play and you try to type "4play" from within an "e -", then you'll probably end up in the wrong place. This is to say you'll get the file that was the 4th last in the history.

The history length must be less than or equal to 9 (the code sets it to 8 at present). The problem with having more is that with "e -" you go into cbreak and the first digit entered (say n ) is taken to mean "I want the nth last file". This saves the need for hitting return, but also means that two digit numbers can't be done.

When "VISAFEINHERIT" is set and your command would have resulted in vi going through a foreign .exrc, e will change the name of the file you want to its full path name, and change directory underneath you to your home directory. For example, if user joe says "e file" in /tmp and user mary owns /tmp/.exrc, then the result will be as though joe had typed "e /tmp/file" from his home directory. Of course when he exits vi he will still be in /tmp. Perhaps this could be considered a bug. If you don't like it, you can live with the modeline problem.

The same problem with the directory changing underneath you happens when e inherits a .exrc for you (via "VIINHERIT") - you get changed to that directory while you are in vi.  

FILES

$HOME/.e - the default e history file.  

ENVIRONMENT VARIABLES

VIHIST - The location used by e for the history.
VIPATH - Search directories.
VIINHERIT - If set, e tries to inherit .exrc files.
VISAFEINHERIT - Ensures you don't inadvertently go through someone else's .exrc file.  

BUGS

The first character on a select line cannot be backspaced over.
The vi option "-" is not available. I should have chosen another letter.  

SEE ALSO

ex(1), edit(1).  

AUTHOR

Terry Jones
Department of Computer Science
University of Waterloo


 

Index

NAME
SYNOPSIS
DESCRIPTION
INVOCATION
EXAMPLE
THE HISTORY
FILENAME CORRECTION
CROSS-DIRECTORY EDITING
.exrc INHERITANCE
NOTES
FILES
ENVIRONMENT VARIABLES
BUGS
SEE ALSO
AUTHOR

This document was created by man2html, using the manual pages.
Time: 21:52:03 GMT, February 02, 2023