使用替代语法使Vim自动缩进PHP/HTML

njb*_*air 9 php syntax vim

我在Vim中编辑PHP并且喜欢自动缩进,但PHP的替代语法不会自动缩进我想要的方式.例如,在HTML模板中,Vim不会像使用大括号时那样识别打开的控件结构.例:

<html>
  <body>
    <p>
      <?php if (1==1): ?>
      This line should be indented.
      <?php endif; ?>
    </p>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

我希望Vim识别开放控制结构并缩进其中的HTML.另一个使用纯PHP的例子:

<?php
  if (1==1):
    echo "This line gets indented";
  echo "This one doesn't";
  endif;
?>
Run Code Online (Sandbox Code Playgroud)

即使控制结构仍处于打开状态,分号也会以分号结束.

有人知道如何让Vim在这些情况下工作吗?谢谢.

njb*_*air 1

考虑到当前可用的 Vim 插件,这似乎是不可能的,也不太可能得到解决。