After consulting with the IRC room, and reading the help files in vim
on filetypes, I've tried everything I can think of and find.  My work
uses .page file extensions for php files.  They are syntax
highlighted when I open them, thankfully because of one of the lines
below, in my .vimrc file.

source /usr/share/vim/vim71/syntax/php.vim

^ This line is doesn't belong in a vimrc.  In addition to being
inexplicably tied to a single (old) vim version, it will only have any
effect at all in the first buffer that is edited, and even then only
if that buffer's filetype can't be detected, and even then only until
you change the filetype with :setfiletype or :set filetype or
:filetype detect

syntax on
filetype detect

^ These are ok...

if did_filetype()       " filetype already set..
  finish                " ..don't do these checks
endif
if getline(1) =~? '^\<\?php'
  set filetype=php
endif

^ These lines also don't belong in a vimrc.  They would belong in a
file called ~/.vim/scripts.vim - See :help new-filetype-scripts or,
more generically, :help new-filetype .  Your vimrc is only read once,
when vim starts, so these lines only take effect once (which is the
problem you're seeing).  All  of the  solutions in :help new-filetype
take effect each time a file is opened.

The above in scripts.vim would probably work. Alternatively, delete it
and put the following in ~/.vim/filetype.vim

if exists("did_load_filetypes")
  finish
endif
augroup filetypedetect
  au! BufRead,BufNewFile *.page setfiletype php
augroup END

Hope this helps further,

Ben.




--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

Reply via email to