Correct indentation of HTML and PHP using Vim

前端 未结 10 435
悲&欢浪女
悲&欢浪女 2020-11-29 20:02

I\'ve been using Vim for a while, and I can\'t get proper HTML indentation working in PHP files.

For example, what I want is for each child to be indented one tab mo

相关标签:
10条回答
  • 2020-11-29 20:31

    After searching for days for the solution ,nothing worked and finally this worked,add this to your vimrc

    au BufEnter,BufNew *.php :set filetype=html
    
    0 讨论(0)
  • 2020-11-29 20:33

    For me it works good if I first do :set ft=html and then :set syn=php.

    0 讨论(0)
  • 2020-11-29 20:35

    i found this solution is much better. http://www.vim.org/scripts/script.php?script_id=1120

    supporting HEREDOC html style. which occur frequently in my code.
    BTW:it's has more versions than the old one (script id 604, alex posted it above)

    0 讨论(0)
  • 2020-11-29 20:38

    There is a set of vimrc instructions on the Vim Wiki called Better indent support for PHP with HTML that will use the correct plugin depending on the block.

    There is also a Vundle/Pathogen Plugin that uses the same code but is easier to install and keeps your .vimrc clean.

    Pathogen

    cd ~/.vim/bundle
    git clone https://github.com/captbaritone/better-indent-support-for-php-with-html.git
    

    Vundle

    Place in .vimrc

    Bundle 'captbaritone/better-indent-support-for-php-with-html'
    

    Run in vim

    :BundleInstall
    
    0 讨论(0)
提交回复
热议问题