Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

migrated from Jul 15 '11 at 17:46

This question came from our site for professional and enthusiast programmers.

up vote 3 down vote accepted

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.

share|improve this answer
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 '11 at 8:40
Just look at the two lines I included. (au is shorthand for autocmd). See :help au for details. – hammar Jul 15 '11 at 8:45
I tried this but gies error au BufNewFile,BufRead /usr/local/apache/conf/*.conf setf apache – user840891 Jul 15 '11 at 9:02
What's the error message? – hammar Jul 15 '11 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 '11 at 9:12

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

# vim: set filetype=apache:

See ":help modeline".

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.