2072 / PHP-Indenting-for-VIm

The official VIm indent script for PHP
http://www.2072productions.com/to/phpindent.txt
128 stars 29 forks source link

wrong indent on conditionals #7

Closed andalou closed 12 years ago

andalou commented 12 years ago

I'm using vim 7.3.496 and php indent 1.35. The following code is wrong indented:

foreach ($x as $value) {
   if (!($i % 2)) print '<tr>';
      print '<td>'.$value.'</td>';
      if ($i % 2) print "</tr>\n";
   $i++;
}

Moreover, I see that shiftwidth is always set to 3. How can I set it to 2?

Many thanks in advance,

Cesar

2072 commented 12 years ago

Hi,

I've just tried with vim 7.3.495 and I couldn't reproduce this issue, I correctly get:

<?php

foreach ($x as $value) {

 if (!($i % 2)) print '<tr>';

 print '<td>'.$value.'</td>';

 if ($i % 2) print "</tr>\n";

 $i++;

}

?>

Are you sure that the correct php.vim indent script is loaded? Are you using specific settings? (try with a default vimrc)

About ShiftWidth, this is a vim setting see :help shiftWidth

John

On 19/04/2012 04:55, andalou wrote:

I'm using vim 7.3.496 and php indent 1.35. The following code is wrong indented:

foreach ($x as $value) { if (!($i % 2)) print ''; print ''.$value.''; if ($i % 2) print "\n"; $i++; }

Moreover, I see that shiftwidth is always set to 3. How can I set it to 2?

Many thanks in advance,

andalou commented 12 years ago

You were right, I had three php.vim: one on C:\Vim\vimfiles\indent, one on C:\Vim\vim73\indent and one on C:\Vim\vimfiles\after\indent the third one was your php.vim 1.35. They were loaded in that order. I thought the last one is what overwrites the previous ones but it was loading the first php.vim. I removed it and put your php.vim 1.35 there. Now it is working, but I don't know whether it loads C:\Vim\vim73\indent\php.vim, version 1.33, or C:\Vim\vimfiles\indent\php.vim, version 1.35.

Regards,

Cesar