There are a few cases where the file extension isn't necessarily indicative of the file contents, and filetype needs to be set with a modeline. For example, Salt *.sls
files can contain many different types of data, including YAML, Jinja2, or Python code, and I include a modeline at the bottom of those to set the correct filetype for syntax highlighting.
# vim:ft=python
I have a BufWritePost autocommand in my .vimrc
that runs a style linter on my python code any time I save a buffer:
au BufWritePost *.py call Flake8()
I would like to do something similar whenever a buffer of FileType python is written, but haven't been able to find an autocommand that matches on filetype. Is there one? Or is there some other approach that will get the effect I want?
:help FileType
?FileType
or I wouldn't have mentioned it twice in my post. I'm also clearly looking for an autocommand that is triggered "whenever a buffer of FileType python is written", which is not whatau FileType
appears to do. If I've missed something, and you want to offer some indication of what exactly I've missed, then please share.