Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

My GVIM 7.3.46 install on Windows XP Professional SP3 32bit does not seem to have PHP syntax highlighting. I have added this file to C:\Documents and Settings\myUsername\vimfiles\syntax and set this in VIM:

au! Syntax php source C:\Documents and Settings\dotancohen\vimfiles\syntax\vim.php

However, running set syntax=php does not highlight files as PHP, neither for files with the .php extension nor for no-extension files.

How can I fix this?

share|improve this question
up vote 2 down vote accepted

GVim should have PHP syntax enabled by default.

1) Check for the existance of the file:

C:\Program Files\Vim\vim73\syntax\php.vim


C:\Program Files\Vim\vim73\filetype.vim
should include the line:

au BufNewFile,BufRead *.php,*.php\d,*.phtml,*.ctp       setf php

It sounds like you might want to try uninstalling GVim and reinstalling it again.

share|improve this answer
Thank you jfuga, both the conditions that you mention are true. What else might cause GVIM to refuse to syntax-highlight PHP files? – dotancohen Apr 17 '12 at 14:00
Do you have a _vimrc file? If so, make sure "syntax on" is listed as a command within this file. – jftuga Apr 17 '12 at 14:04
Thanks, I do have that file. In fact, I just found out that removing _vimrc enables syntax highlighting! – dotancohen Apr 17 '12 at 14:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .