I noticed that the /php.vim syntax file on my ubuntu machine has the php_htmlInStrings
parameter. I can enable this option to display HTML syntax highlighting in lines in my php files, which is great. I would also like to make javascript syntax highlighting in lines in php file. Does anyone know if this can be done, and if so, how can I do this?
edited - added additional features
I should also mention that I would be happy with a solution in which I would need to parse all my javascript strings, despite the php function, before outputting the result. This can get around the problem suggested by conner below, where vim has problems deciding whether the javascript string contains. eg:
$js = "some regular text which is not javascript##now vim has detected that this part is javscript##back to regular text"; parse($js); function parse($str) { return str_replace('##', '', $str); }
The reason I would be happy to do this is because I will probably include in my project the html / css / js minifier variable, which will do replacements on strings anyway.
Of course, if for ##
there is an equivalent vim character that will not be displayed in the source code and will not need to be filtered out, this would be preferable ...
redo 2
In accordance with the solution below, the desired effect can be achieved as follows:
$js = "<script>some javascript</script>";
(with :let php_htmlInStrings=1
in vim). If someone can show me that a vim script is required so that the javascript syntax highlighting appears in the next line, I will give them the answer:
$js = /*<script>*/"some javascript"/*</script>*/;