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

Multiline strings break indentation #60

Closed LaserMoai closed 5 years ago

LaserMoai commented 7 years ago

The last line there doesn't get indented properly.

<?php
if ($v) {
        echo "
";
echo "";

Version 1.62

2072 commented 7 years ago

I'm unable to reproduce this issue.

Could you install the new 1.63 version and try again?

With 1.63 version you can type the following command to check if the indent script was indeed loaded:

:echo GetPhpIndentVersion()

this should print 1.63

2072 commented 7 years ago

I was able to reproduce a similar problem but you should check issue #47 as this is related. I'll fix it when I'll have some time but you really should be using heredoc notation instead of multi-line strings...

LaserMoai commented 7 years ago

I'm just following examples from "PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide."

h3xx commented 6 years ago

Can confirm.

Given the following file:

<?php

class Foo
    public function bar() {
        $foo = "
";
    }
}

Pressing Enter in insert mode after the ; on the "; line puts the insertion point TWO sw to the left of where it should be. I would expect it to be aligned with the $ in the $foo line.

Oddly enough:

A related issue:

Given the following file:

<?php

class Foo
    public function bar() {
        $foo = "
";
$baz = "bar";
    }
}

Expected indenting in this case would be to align the $ of the $baz line to the $ in the $foo line.