On Mon, Feb 8, 2010 at 11:05 AM, File077 wrote:
>
> 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.
>
>
> My problem is, when I press "CTRL+w", "n" for a new pane, then ":e
> other_file.page" to bring up a second file in the same window, it isn't
> syntax highlighted.  I always have to type ":filetype=php" to get it colored
> right.  It is a big pain in the butt.
>
> Can anyone help?
>
>
> 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.

> syn on

^ This is redundant - you already did a ":syntax on" above.

Hope that helps.

~Matt

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

Reply via email to