When using vim some django templates, for example:
<li> {% if sth %} <p>something</p> {% endif %} </li>
The indentation I require is as above, but in vim it will be forced to automatically indent the line "<p>" forward and become:
<li> {% if sth %} <p>something</p> {% endif %} </lil>
You must finish typing the line "<p>" 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?
仅有的幸福2017-05-16 16:45:11
Can I think that {% if * %} and <li> 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.
<li> {% if sth %} <p>something</p> {% endif %} </li>
迷茫2017-05-16 16:45:11
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.