System: gvim 8.1 1-116 / windows10

A file that I'd like to use modeline (enabled): # vim: ft=python but disable ale plugin that will trigger on save - the file contains some python codes.

Command that I'd like to run by vim before parse the file: :ALEDisable.

Here I just want to disbale ALE on a specific file that comes with clear declaration in modeline.


You've already solved your problem, but for the benefit of future readers, I'll paste a couple of bits from :help modeline:

No other commands than "set" are supported, for security reasons (somebody might create a Trojan horse text file with modelines).


Hint: If you would like to do something else than setting an option, you could define an autocommand that checks the file for a specific string. For example:

au BufReadPost * if getline(1) =~ "VAR" | call SetVar() | endif

And define a function SetVar() that does something with the line containing "VAR".

Similarly, you could use something like:

au BufReadPost your_file.conf AleDisable

Or you could remove the modeline altogether with an autocommand along the lines of:

au BufReadPost your_file.conf AleDisable | set ft=python

Silly me, I just want to have highlight of python while keep ft=conf because this is a note that contains python code, I'd like to have python code highlighted properly, so just set modeline: # vim: syntax=python I can achieve the purpose.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.