[net.unix-wizards] VI Mode Lines - What are they?

korn@datagen.UUCP (05/29/86)

I just received the beta test version of PC/VI Version 1.02 from
Custom Software Systems (For those who don't know it, PC/VI is a
full implementation of VI which runs under MS-DOS).  The release
notice which came with the program documented a number of
enhancements and bug fixes, this included a feature called "mode
lines".  The release notice stated that this was a feature
implemented in PC/VI just as it is in AT&T's Version 3.9 of UNIX VI.

Now for the big question, what are mode lines?!?  Anyone out there
running AT&T VI who can answer this?

John Korn
Data General Corp
{allegra, ihnp4, decvax}!datagen!korn

guy@sun.UUCP (06/07/86)

> ...this included a feature called "mode lines".  The release notice
> stated that this was a feature implemented in PC/VI just as it is in
> AT&T's Version 3.9 of UNIX VI.
> 
> Now for the big question, what are mode lines?!?  Anyone out there
> running AT&T VI who can answer this?

"mode lines" are an alleged feature, present not only in the "vi" 3.9 which
comes with System V Release 2, but also in the "vi" 3.7 which comes with
4.2BSD.  (It's not really "AT&T" "vi", 3.7 comes with S5R1 and is almost
identical to the 3.7 that comes with 4.2, and 3.9 is a version that was
changed to use "terminfo" and had a few other things done to it.)

One of the first or last five lines of the file can be a "mode line".  If
this line is of the form

	<stuff>ex:<commands>:<stuff>

or

	<stuff>vi:<commands>:<stuff>

OR

	<stuff>ei:<commands>:<stuff>

OR

	<stuff>vx:<commands>:<stuff>

where the <stuff> items represent possibly-null strings and the <commands>
is another possibly-null string, it is a "mode line".  The <commands> part
of the first such line it finds is executed as an "ex" command when the file
is read.

What's that you say?  You have a user named "sex" whose password file entry
is at the end of "/etc/passwd", and you get strange error messages when you
"vi" the password file?  Three guesses why....

4.3BSD's "vi" has a variable called "modeline", which is off by default;
mode line checking is only done if it's on.  One hopes this will migrate
into S5's "vi".
-- 
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy@sun.com (or guy@sun.arpa)