To write the indentation problem in the django template with vim

66 4

When you use vim for some of the django templates, for example:

<li>
 {% if sth %}
 <p>something</p>
 {% endif %}
</li>

I ask for the indentation that's above, but it's forced to automatically indent the <_ p> line in vim, as it's:

<li>
 {% if sth %}
 <p>something</p>
 {% endif %}
</lil>

"<p>"has to be completed and manually modified. .

I understand that because this is an html file, vim treats it as a normal html indentation, ignoring the if tags in django.
So how can it be handled that can let vim treat"% % % % prematurely"as a label in html.

2 Answers

66 4

I can think of the % % if * % % and <li> in your code for a rank. Or the following writing is more demanding, and doesn't break the indented structure of html.

<li>
{% if sth %}
 <p>something</p>
{% endif %}
</li>
...