how do you get modeline(s) to work under vi?

Jim Logan logan at inpnms.UUCP
Wed Dec 20 13:16:19 AEST 1989


In article <493 at hades.OZ> greyham at hades.OZ (Greyham Stoney) writes:
# Can anyone provide me with a working example of how to get modelines to
# work under vi?. Our vi (ISC 386/ix) 'set all' shows a 'modelines' option;
# (note that it's plural; the BSD manual I have says it's singular) but I
# can't seem to get it to do anything.

I played with this for a good hour one day, and I would imagine
that others would like to see how it is done; hence the post. 
You're right, there is nothing in the man page that describes
modelines.   

All you have to do is put the line "set modelines" in $HOME/.exrc
and put a line like "ex: set some_flags:" near the top or bottom
of the file.   

A word of warning:  When modelines are used, it changes the files
status to modified.  This makes it a real pain to switch back and
forth between files since you have to explicitly type ":e!#"
rather than being able press <ctrl>-^.    

It is also a problem when looking at source code.  When you use
vi to look at a file, you have to explicitly type ":q!" to get
out of it.  You can't use "ZZ" because it will cause "make" to
recompile when there is no need.  I used it for a while at the
top of header files developed here with 3-space tabs.  You could
turn off "warn" or map "ZZ" to ":q!", but it's too easy to have
an accident that way.  

			-Jim
-- 
James Logan                       UUCP: uunet!inpnms!logan
Data General Telecommunications   Inet: logan%inpnms at uunet.uu.net
(301) 590-3069



More information about the Comp.unix.i386 mailing list