Making Vim auto-indent PHP/HTML using alternative syntax
Posted
by njbair
on Stack Overflow
See other posts from Stack Overflow
or by njbair
Published on 2010-04-17T16:33:21Z
Indexed on
2010/04/17
16:43 UTC
Read the original article
Hit count: 318
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:
<html>
<body>
<p>
<?php if (1==1): ?>
This line should be indented.
<?php endif; ?>
</p>
</body>
</html>
I want Vim to recognize the open control structure and indent the HTML within it. Another example which uses pure PHP:
<?php
if (1==1):
echo "This line gets indented";
echo "This one doesn't";
endif;
?>
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.
© Stack Overflow or respective owner