Take the 2-minute tour ×

I edit PHP in Vim and have enjoyed the auto-indenting, but PHP's alternative syntax doesn't auto-indent how I would like. For instance, in an HTML template, Vim doesn't recognize the open control structure in the same way it does when using braces. Example:

      <?php if (1==1): ?>
      This line should be indented.
      <?php endif; ?>

I want Vim to recognize the open control structure and indent the HTML within it. Another example which uses pure PHP:

  if (1==1):
    echo "This line gets indented";
  echo "This one doesn't";

The indentation is terminated by the semicolon, even though the control structure is still open.

Does anybody know how to get Vim to work in these situations? Thanks.

share|improve this question
add comment

3 Answers

Check this out, this one as well

share|improve this answer
Actually I am already using those. The second link is included by default in Vim 7, and the first one sources the second one and adds the HTML inter-operation. –  njbair Apr 17 '10 at 17:31
add comment
up vote 1 down vote accepted

It would seem that this is not possible given the currently available Vim plugins, nor is it likely to be addressed.

share|improve this answer
add comment

It is too late but me by help others. I found this plugin work very well with indentation in html+php files vim-html-enhanced

share|improve this answer
add comment

Your Answer


