3

I have centoS operating system.

I am creating my own apache config file like /usr/local/apache/conf/my.conf

There are more files like httpd.conf and php.conf in that directory

Now when i see those files then keywords of apache directives like LoadModule are shown in different colors. But in my created conf file tey show like normal text.

Why is that

2 Answers 2

3

Here's the relevant part from my (unmodified) filetype.vim:

" Apache config file
au BufNewFile,BufRead .htaccess,/etc/httpd/*.conf        setf apache
au BufNewFile,BufRead httpd.conf*,srm.conf*,access.conf*,apache.conf*,apache2.conf*,/etc/apache2/*.conf*,/etc/httpd/conf.d/*.conf* call s:StarSetf('apache')

As you can see, it only matches specific .conf files such as httpd.conf, and .conf files in particular directories. This is because Apache is not the only software that uses .conf files.

You can either add an autocommand for your own .conf file, or if this is just a one-off, run :setf apache.

6
  • I did that , it worked for time being but when i opened file again. it was lost. how can i use auto command u mentioned
    – user840891
    Jul 15, 2011 at 8:40
  • Just look at the two lines I included. (au is shorthand for autocmd). See :help au for details.
    – hammar
    Jul 15, 2011 at 8:45
  • I tried this but gies error au BufNewFile,BufRead /usr/local/apache/conf/*.conf setf apache
    – user840891
    Jul 15, 2011 at 9:02
  • What's the error message?
    – hammar
    Jul 15, 2011 at 9:08
  • in red color they say no such group or event. i am executing by going in file with vim my.conf then :command at bottom. is that right
    – user840891
    Jul 15, 2011 at 9:12
2

You could use a modeline in the top or bottom 5 lines of your config files:

# vim: set filetype=apache:

See ":help modeline".

You must log in to answer this question.