开发者

VIM php syntax error

I have syntax highlighting enabled in VIM and it properly recognizes files of all types and makes everything look开发者_如何转开发 beautiful. In one PHP file however I am doing a preg_match() with a regex string that includes ?> in the middle, and VIM considers this to be the end of the PHP code section of my file and everything after it becomes gross looking with no colors.

Aside from rewriting my regex to not contain those two characters in a row, is there something I can do to make VIM realize I am in the middle of a string and not a code section?


I would say no, unless you actually mod the src of vim. The syntax highlighter on SO has the same problem:

<?php

  some_code("that is highlighted correctly");
  $mystring = "This code is highlighted OK, until I do ?>";
  some_other("code that should be syntax highlighted but isn't");

?>

This is because SO and vim use regex's to highlight the code, and they are not complex enough to cope with this...


You might be able to escape the >:

?\>

if it's part of the content, that shouldn't break the regex.

The only other way I can think of is using ASP style tags <% %> or <script language="php"></script> but I'm not sure whether vim supports those, and it would be kludgy.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜