dongqiaolong9034 2012-07-26 02:49
浏览 24

vim php_javascriptInStrings选项?

I noticed that the syntax/php.vim file on my ubuntu machine has a php_htmlInStrings option. I can turn this option on to display HTML syntax highlighting within strings in my php files, which is great. I would also like to do javascript syntax highlighting within strings in a php file. Does anybody know if this can be done and if so how can I do it?

edited - added extra possibilities

I should also mention that I would be happy with a solution where i have to parse all my javascript strings though a php function before outputting the result. This might get around the problem suggested by conner below where vim has trouble deciding if the string contains javascript. for example:

$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 be incorporating a html/css/js variable minifier into my project which will be doing substitutions on strings anyway.

Of course if there is a vim-specific equivalent character for ## which will not show up in the source code and would not need to be filtered out then this would be preferable...

re-edit 2

As per conner's solution below, the desired effect can be achieved like so:

$js = "<script>some javascript</script>";

(with :let php_htmlInStrings=1 in vim). If somebody can show me the vim script required to get the javascript syntax highlighting to show up in the following string then I will award them the answer:

$js = /*<script>*/"some javascript"/*</script>*/;
  • 写回答

2条回答 默认 最新

  • dongtu1789 2012-07-30 13:45
    关注

    Have you tried this php.vim syntax file?

    评论

报告相同问题?

悬赏问题

  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画