I have php files well any file type in general that I would like vim to highlight here docs sections using a different syntax highlighting.

echo <<<HTMLDOC
<h1> I am highlighted as html </h1>

echo 'High Lighted as PHP again '

You can tweak the colors of course but try this:

:highlight MyHereDoc ctermbg=green guibg=green
:match MyHereDoc /<<<\([A-Za-z]*\)\_.*\1/

Also, if you plan on it being something more perminant in your vimrc add:

highlight MyHereDoc ctermbg=green guibg=green
matchadd("MyHereDoc", '<<<\([A-Za-z]*\)\_.*\1')
  • TY I will try it as soon as I get the chance. – MageProspero Oct 6 '11 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.