On Thu, Jul 20, 2006 at 12:39:28AM +0200, Cesar Romani wrote:
> 
> In the following code, "if" from line 2 doesn't match "else" from line 7
> 
> -------------------------------- 
>  1 <?php
>  2 if($a > $b)
>  3 {
>  4   echo "a is bigger than b";
>  5   if($a=10) $b=5;
>  6 }
>  7 else
>  8 {
>  9   echo "a is smaller than b";
> 10 }
> 11 ?>
> --------------------------------
> 
> Many thanks in advance.
> 
> Cesar

     PHP syntax, like that of C, is not really suited to matchit.  If
you use the alternative syntax for control structures, it will work much
better:

<?php
if($a > $b):
  echo "a is bigger than b";
  if($a=10): $b=5; endif;
else:
  echo "a is smaller than b";
endif;
?>

It would be nice if you could insist on the ":" character after the
condition, but that will not be possible until I get around to rewriting
matchit.vim .  (Consider that the condition could be much more
complicated than "($a > $b)".  It could span several lines, and it could
include nested parentheses, strings, comments, and ?: operators.)

     You can always match on the braces instead of the key words.

     If you decide that the problems with matching on "if" outweigh the
benefits, either take it up with the maintainer of ftplugin/php.vim or
else modify it to your taste:

:help ftplugin-overrule

HTH                                     --Benji Fisher

Reply via email to