Recent Posts

Archive

2012

2011

2010

2009

2008

2007

2006

Tags

Authors

Brad Montgomery

Feeds

RSS / Atom

Vim Syntax highlighting for Apache Config Files

Posted by Brad Montgomery 1 year, 11 months ago (4 comments)

I use Django with Apache and mod_wsgi. Each project that I work on has different apache config files, so I like to keep those in the same mercurial repo that contains my django project's code.

For some time now, it's been bugging me that vim doesn't do syntax highlighting for those apache configs (nor the wsgi files). I finally decided to do something about it, and I'm glad I did, because it's a fairly simple fix:

My project directory layout often look like this:

~/django_projects/projectname/
__init__.py
apache_configs/
projectname
projectname.wsgi
manage.py
settings.py
myapp/

Vim does syntax highlighting for apache files based on their path. To get vim to recognize the files in the apache_configs directory, you need to edit (or create) ~/.vim/filetype.vim and add the following:

au BufNewFile,BufRead ~/django_projects/de_concierge/apache_configs/*wsgi setf python
au BufNewFile,BufRead ~/django_projects/de_concierge/apache_configs/* setf apache

You'd have to add variants of this for each separate project, but this works well for me.

There's several other ways you can modify this, and the solution that I used comes from this thread on the vim_mac mailing list. (There's also a lot of good info in :help new-filetype ).
Tags:

Sorry, I've disabled comments. If you want, talk to me on twitter: @bkmontgomery