Closed rsaihe closed 2 years ago
Very interestingly, just after I finished writing the previous message I decided to test the same snippet in an XML file and it indented correctly, so it definitely is specific to Vim's indentation of HTML.
Yes, this is related to how Vim indents HTML. If you write it by hand, you get the following behaviour:
<div>
test|
<div>
test
</div|
<div>
test
</div>|
Notice how closing tag was re-indented after finishing it with >
.
When you enter it via your snippet, the rule is not triggered since <<{}>>
and </<{~1}>>
aren't matching pair.
Ah, that makes sense. Any idea why it does still work in XML files?
Indentation for XML is implemented differently, because all XML tags need to have a closing tag, while in HTML not all of them. Thus when Vim sees any closing tag in XML, it just decreases the indent; while in HTML needs to check whether you are closing <li>
or the <ul>
above it.
Alright, I see.
Yeah, unfortunately, I don't see any straightforward way to fix the problem.
I've noticed that there seems to be one particular case that is not indented correctly.
Specifically, I have the following snippet for HTML files:
However, when I expand this, instead of the expected result (using
div
as an example):I get the following:
I'm not exactly sure why this particular case indents incorrectly, but I speculate it is related to the name of the closing tag itself being a placeholder.