views:

91

answers:

2

I know I did not word the question right but I was not sure how. So here it goes.

when using vim the way my color syntax is now, when i type in $ it shows yellow and when i write text it comes in white. How can I configure my vimrc to know when I am writing a php variable ($variable) and keep the color consistent between the $ and the words after it (variable in my example)? it just a nuisance thing but i hate seeing variable names with non-matching color, it drives me nuts.

Thanks and let me know if you need more clarification. I am a Linux and vim rookie working my way through. Thanks

+2  A: 

You might want to consider getting this to fix your problem: http://www.vim.org/scripts/script.php?script_id=1571

Michael Goldshteyn
Thanks, i have downloaded the php.vim file, although i do not have a .vim folder in my home directory. Is it sufficient to just create the file? ie... ~/.vim/syntax/php.vim or am i mistaken on its location? Thanks again
Drewdin
I think that would work...
Michael Goldshteyn
Useful [site](http://vim.wikia.com/wiki/Vim_Tips_Wiki) not just for beginners
kfl62
So, did that vim script work out for you?
Michael Goldshteyn
when i tried to move the folder it told me that there is no folder in my home directory. I'm going to browse around for it and see if i can find it.
Drewdin
See if you have a ~/.vimrc file. A line in that file might help you locate the syntax directory. It should be: $VIMRUNTIME/syntax, assuming $VIMRUNTIME is defined, which might be /usr/share/vim/vim72/syntax/ for all users. But a better place is still ~/.vim/syntax, which you might have to create if it is not already there. This will allow the script you downloaded to override the default script which might or might not be present in /usr/share/vim/vim72/syntax/.
Michael Goldshteyn
I created the /home/.vim/syntax folder and moved the php.vim file there. I added the following line to my vimrc, which i found in the etc/vim folder. let $VIMRUNTIME = "/home/.vim/syntax". It does not seem to be working right. What does a basic vimrc look like? I think the one I have is changing the appearance. Thanks for all the help, i am a linux/vim rookie and i am not familiar with the file structure yet.
Drewdin
for some reason it adds the test syntax to anything i try to open, plus it still has different text colors of the $ and the text although it does recognize php functions. I removed the $VIMRUNTIME and it still does the same thing.
Drewdin
If it is using the php settings and the $ is a different color from the rest of the variable name, you might want to examine the guts of that php vim script and see if there are comments maybe pointing this out, so you can change it to what you prefer...
Michael Goldshteyn
Thanks for all of your help Michael, thanks to your link, your help and the vim website I was able to use :echo $VIMRUNTIME, :echo $HOME and :VERSION to find everything i needed. I truly appreciate your help!
Drewdin
You're welcome!
Michael Goldshteyn
A: 

I believe what you're looking for is:

hi link phpIdentifier phpVarSelector

You can simply add this to your ~/.vimrc file or you can create a php-specific "after" syntax file and add it there:

~/.vim/after/syntax/php.vim

Create the directories if they do not already exist.

For future highlighting changes you can use this mapping to figure out what the syntax group is under the cursor.

Curt Nelson