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

Mike Wescott wescott at Columbia.NCR.COM
Tue Dec 19 08:34:30 AEST 1989


In article <493 at hades.OZ> 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.

Assuming that you want modelines (and not showmode as was suggested by
another).  You must have modelines set before you start to edit a file
by using the EXINIT environment variable or in your .exrc.  Or set it
by hand and use :n to edit the file.

The modelines option has nasty possibilities for Trojan Horse attacks,
so use it sparingly and never as root.

For those of you wondering what this option does, it permits the inclusion
of editor commands in the text of the file to be editted. The best (legitimate)
use I can think of is to change shiftwidth and/or tabstop:

/******
	vi:set shiftwidth=4:
	vi:set tabstop=4:
******/

Vi scans the first 5 and last 5 lines of the file for a string of characters
such that the first colon on the line is preceded by the string "ex" or
"vi" (some versions also permit "vx" or "ei") and is followed by a
colon-terminated command string.

-- 
	-Mike Wescott
	 mike.wescott at ncrcae.Columbia.NCR.COM
--
	-Mike Wescott
	 mike.wescott at ncrcae.Columbia.NCR.COM



More information about the Comp.unix.questions mailing list