If I have an apache file in /etc/apache2/sites-available/www.example.com and I set its filetype like so
:set filetype=apache
What does that do? Does that change the file at all? Is it only reflected in the instance of vim? The session of vim? I can manually set the filetype, but then vim warns me that I am in read only mode (/etc/apache2 needs root access). If I open vim as root, I won’t get the warning, but if I leave and open it again (as normal or root), the filetype is gone. How do I make this more permanent, at least when called from the same session file
set filetypechanges the way vim handles the file, by invoking all theFileTypeautocommands. It does not persist. If you want to always open that file withfiletype=apache, try adding this into your.vimrc:You can read more about it in:
EDIT: as found in my
/usr/share/vim/vim73/filetype.vim:s:StarSetfwillsetfiletypetoapacheif the filetype doesn’t match an ignored pattern. On my system,:echo g:ft_ignore_patwill show only archive file extensions as ignored.setfiletypedoesset filetype, but only once.So, at least on my system, the pattern
*/etc/apache2/sites-*/*would catch your filename and make it anapachefile.