Modelines in vi (was: Obscure Vi bug?)
Norman Joseph
norm at oglvee.UUCP
Fri Aug 3 23:48:15 AEST 1990
In <1990Aug2.211835.24599 at math-cs.kent.edu> jstuart at math-cs.kent.edu
(Jeff Stuart) writes:
>We have a problem here also with vi that when you edit a file and that
>file contains an ei: possibly followed by some text and then another :
>vi gives an error message.
Some versions of vi recognize an option called "modelines." When this
option is turned on (via :set modelines in your .exrc, or, in your case,
possibly by default) vi will recognize, in the first and last 5 or so
lines of the file you're editing, lines of the form:
vi:<valid vi commands here>:
ex:<valid ex commands here>:
If vi is using a regular expression like [ve][ix]: to search for this line,
this would explain your troubles with the `ei:' line.
Any valid command found between the two colons will be executed when
the file is read in. You should be able to remedy your problems by
creating a .exrc file in your $HOME directory and including in it the
line `:set nomodelines'. This will turn of the modelines "feature"
at each invocation of vi.
[scurries out of dark hole; steps up on soapbox]
While a feature like modelines may have its uses, it is generally
frowned upon due to its potential use as a Trojan Horse (consider
getting an unsuspecting user to edit a file with vi containing a
line like `vi:!rm -rf *:'. Having a vendor supply a vi with the
modelines option turned on by default is like distributing sendmail
with the DEBUG option turned on :-).
[climbs down from soapbox; scurries back into dark hole]
--
Norm Joseph cgh!amanue!oglvee!norm at dsi.com
Oglevee Computer Systems, Inc. {pitt,cgh}!amanue!oglvee!norm
"Shucking Usenet oysters in pursuit of a pearl." -- Bill Kennedy
More information about the Comp.unix.questions
mailing list