Vim modeline syntax (see :help modeline
) is not intended to specify commands
to execute during file opening. That is exactly what autocommands is for (see
:help autocommand
). What you are trying to do should be an autocommand
similar the following.
autocmd FileType foo call matchadd('Special', '\(REQUIRED\|OPTIONAL\)')
or
autocmd BufReadPost *.foo call matchadd('Special', '\(REQUIRED\|OPTIONAL\)')
(Here instead of *.foo
you can use any pattern that matches path or filename
(or both) of the target file.)
If the configuration you are setting up is local to some files or a project,
and you don't want to pollute your .vimrc
with those autocmd
s, use
localvimrc plugin. It allows you to have a "local" .vimrc
file next to
your target file or project folder. Script stored in that .lvimrc
is
executed when you open files in the same directory where the "local" .vimrc
is, or in its subdirectories. Autocommands shown above (or any other
configurations) can be stored in a .lvimrc
file local the project. For
details about localvimrc configuration see the homepage of the plugin.