# How to set PHP syntax highlighting in GVIM on Windows?

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?

-

GVim should have PHP syntax enabled by default.

1) Check for the existance of the file:

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

2)

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.

-
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