6

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.

5

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 '16 at 2:16
  • 1
    You should mark the answer as correct, @alec. – Karl Yngve Lervåg Jan 29 '16 at 5:52

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.