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

:let g:PHP_outdentphpescape = 0 doesn't indent multi line PHP block #30

Closed danielepiccone closed 10 years ago

danielepiccone commented 10 years ago
<p>Recent articles:</p>
<div>
    <div>
<?php
$cat = get_the_category();
$args = 'cat=';
foreach ($cat as $c) {

when indented using :let g:PHP_outdentphpescape = 0 becomes

<p>Recent articles:</p>
<div>
    <div>
    <?php
$cat = get_the_category();
$args = 'cat=';
foreach ($cat as $c) {

the <?php tag is moving, but the block does not follow the tag.

using vim 7.4 and the latest version of the plugin

2072 commented 10 years ago

This is normal, this option only prevents PHP's escape tag from being always put at column 0.

danielepiccone commented 10 years ago

That's fine, but shouldn't the lines under the <?php tag should be indented as well?

<p>Recent articles:</p>
<div>
    <div>
    <?php
    $cat = get_the_category();
    $args = 'cat=';
    foreach ($cat as $c) {

Commonly I have my block of code indented following the last html tag indentation Ideally what I am trying to achieve is to have this result, but the one above would be fine too

<p>Recent articles:</p>
<div>
    <div>
    <?php
        $cat = get_the_category();
        $args = 'cat=';
        foreach ($cat as $c) {
2072 commented 10 years ago

The principle behind this indentation script is to completely ignore non-PHP code (ie: if you remove what is between <? and ?> the indentation should not change). See the example here: http://www.2072productions.com/to/phpindent.txt