Skip to main content
added 25 characters in body
Source Link
muru
  • 25.1k
  • 8
  • 83
  • 144
 modelines, ml  default: nomodelines
        If modelines is set, then the first 5 lines and  the  last  five
        lines  of  the file will be checked for ex command lines and the
        comands issued.  To be recognized as a command  line,  the  line
        must  have the string ex: or vi: in it.  This string may be any-
        where in the line and anything after the : is interpeted as edi-
        tor commands.  This option defaults to off because of unexpected
        behavior when editting files such as /etc/passwd.
 modelines, ml  default: nomodelines
        If modelines is set, then the first 5 lines and  the  last  five
        lines  of  the file will be checked for ex command lines and the
        comands issued.  To be recognized as a command  line,  the  line
        must  have the string ex: or vi: in it.  This string may be any-
        where in the line and anything after the : is interpeted as edi-
        tor commands.  This option defaults to off because of unexpected
        behavior when editting files such as /etc/passwd.
Release 2/17/02
* POSIX.2: Backslash has no special meaning inside RE bracket expressions.
...
* Made modelines compatible to SVr4 ex: The option name is "modelines" or
  "ml" now; a space or tab preceeding "ex:" or "vi:" is not required.
Release 2/17/02
* POSIX.2: Backslash has no special meaning inside RE bracket expressions.
...
* Made modelines compatible to SVr4 ex: The option name is "modelines" or
  "ml" now; a space or tab preceeding "ex:" or "vi:" is not required.

SevnSven Guckes' list of vi options says modelines was supported by SVR3.1 vi, but not which format. I'd wager it would be the vi:.../ex:...second form.

 modelines, ml  default: nomodelines
        If modelines is set, then the first 5 lines and  the  last  five
        lines  of  the file will be checked for ex command lines and the
        comands issued.  To be recognized as a command  line,  the  line
        must  have the string ex: or vi: in it.  This string may be any-
        where in the line and anything after the : is interpeted as edi-
        tor commands.  This option defaults to off because of unexpected
        behavior when editting files such as /etc/passwd.
Release 2/17/02
* POSIX.2: Backslash has no special meaning inside RE bracket expressions.
...
* Made modelines compatible to SVr4 ex: The option name is "modelines" or
  "ml" now; a space or tab preceeding "ex:" or "vi:" is not required.

Sevn Guckes' list of vi options says modelines was supported by SVR3.1 vi, but not which format. I'd wager it would be the vi:.../ex:....

 modelines, ml  default: nomodelines
        If modelines is set, then the first 5 lines and  the  last  five
        lines  of  the file will be checked for ex command lines and the
        comands issued.  To be recognized as a command  line,  the  line
        must  have the string ex: or vi: in it.  This string may be any-
        where in the line and anything after the : is interpeted as edi-
        tor commands.  This option defaults to off because of unexpected
        behavior when editting files such as /etc/passwd.
Release 2/17/02
* POSIX.2: Backslash has no special meaning inside RE bracket expressions.
...
* Made modelines compatible to SVr4 ex: The option name is "modelines" or
  "ml" now; a space or tab preceeding "ex:" or "vi:" is not required.

Sven Guckes' list of vi options says modelines was supported by SVR3.1 vi, but not which format. I'd wager it would be the second form.

Source Link
muru
  • 25.1k
  • 8
  • 83
  • 144

The original Vi does support modelines of the second form, however, modelines has to be set before the file is read. The manpage of ex says:

 modelines, ml  default: nomodelines
        If modelines is set, then the first 5 lines and  the  last  five
        lines  of  the file will be checked for ex command lines and the
        comands issued.  To be recognized as a command  line,  the  line
        must  have the string ex: or vi: in it.  This string may be any-
        where in the line and anything after the : is interpeted as edi-
        tor commands.  This option defaults to off because of unexpected
        behavior when editting files such as /etc/passwd.

The Changes file says:

Release 2/17/02
* POSIX.2: Backslash has no special meaning inside RE bracket expressions.
...
* Made modelines compatible to SVr4 ex: The option name is "modelines" or
  "ml" now; a space or tab preceeding "ex:" or "vi:" is not required.

This indicates that modelines support was present earlier, it was changed in 2002.

Sevn Guckes' list of vi options says modelines was supported by SVR3.1 vi, but not which format. I'd wager it would be the vi:.../ex:....

As for other implementations, nvi's manpage says:

modelines, modeline [off]
  Read  the first and last few lines of each file for ex commands.
  This option will never be implemented.

(Emphasis varies depending on the age of the manpage.)

For Elvis:

modeline, ml (Boolean, global)
modelines, mls (Number, global)

The modeline option controls whether Elvis will look for modelines in each buffer after it has been loaded from a file. If modelines is true, then Elvis will search through the first and last modelines lines of the buffer for something that looks like "ex:commands:" or "vi:commands:" and if found, it executes the commands as an ex command line. (This behavior is implemented in the elvis.arf file.) This is typically used for changing tabstops and the like. The modeline option is false by default, and modelines is 5.


It looks like the first is only for Vim (and descendants).