The HTML that's being returned by this PHP function doesn't have any syntax highlighting.

If I delete the ' on line 13 the HTML highlighting works (but the PHP function breaks), with it the HTML highlighting does not work.

How do I get the HTML to have its proper syntax highlighting inside of this function?

html loses syntax highlighting inside php return function

Do I want to be doing something like this? I'm having a hard time figuring out what to make of that and how I would adapt it for my situation, let alone whether or not that's the right approach.

It would be great if Vim could automatically recognize HTML inside a PHP file without having to type any hard-to-remember commands.


1 Answer 1


From :help ft-php-syntax:

There are the following options for the php syntax highlighting.


Enable HTML syntax highlighting inside strings:

  let php_htmlInStrings = 1

You can add that your vimrc.

  • Thank you so much!!! I didn't even know there was an option of "ft-php-" for the syntax help. Adding that let php_... to .vimrc did the trick!
    – alec
    Jan 29, 2016 at 2:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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