Use vim to write indentation problems in Django templates
PHP中文网
PHP中文网 2017-05-16 16:43:11
0
2
630

When using vim some django templates, for example:

  • {% if sth %}

    something

    {% endif %}
  • The indentation I require is as above, but in vim it will be forced to automatically indent the line "

    " forward and become:

  • {% if sth %}

    something

    {% endif %}
  • You must finish typing the line "

    " and manually change the indentation. .

    What I understand is that because this is an html file, vim treats it as a normal html indentation format and ignores the if tag in django.
    So what should we do to make vim treat "{% %}" as a tag in HTML?

    PHP中文网
    PHP中文网

    认证0级讲师

    reply all (2)
    仅有的幸福

    Can I think that {% if * %} and

  • in your code are of the same level? Or the following way of writing is more in line with the requirements and will not destroy the indentation structure of HTML.

  • {% if sth %}

    something

    {% endif %}
    • 迷茫

      The automatic indentation in VS2010 is the first type. I think VIM’s processing is correct.
      Because compared to ul, indenting li by one tab is a good indentation.

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!