Consider the following code:
<gaga> <bar at1="" at2="" at3="" at4="" at5="" at6="" at7="" at8="" at9="" at10=""/> gaga </gaga>
Re-indenting this gives you the following, which incorrectly doesn't decrease the indent level after the "/>":
<gaga> <bar at1="" at2="" at3="" at4="" at5="" at6="" at7="" at8="" at9="" at10=""/> gaga </gaga>
Moving all the attributes (at1 to at10) on a single line is a way around the problem, but when there are a lot of arguments, it sometimes just makes sense to have the attributes over multiple lines. I imagine that this could be fixed by tuning the decreaseIndentPattern and increaseIndentPattern for XML. Has anyone already done that?
Alex
----- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ Personal Blog: http://avernet.blogspot.com/ Twitter - http://twitter.com/avernet
Does anyone have any clue on this one?
Alex
Alessandro Vernet wrote:
Consider the following code:
<gaga> <bar at1="" at2="" at3="" at4="" at5="" at6="" at7="" at8="" at9="" at10=""/> gaga </gaga>
Re-indenting this gives you the following, which incorrectly doesn't decrease the indent level after the "/>":
<gaga> <bar at1="" at2="" at3="" at4="" at5="" at6="" at7="" at8="" at9="" at10=""/> gaga </gaga>
Moving all the attributes (at1 to at10) on a single line is a way around the problem, but when there are a lot of arguments, it sometimes just makes sense to have the attributes over multiple lines. I imagine that this could be fixed by tuning the decreaseIndentPattern and increaseIndentPattern for XML. Has anyone already done that?
Alex
----- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ Personal Blog: http://avernet.blogspot.com/ Twitter - http://twitter.com/avernet
Consider the following code:
<gaga> <bar at1="" at2="" at3="" at4="" at5="" at6="" at7="" at8="" at9="" at10=""/> gaga </gaga> [...] I imagine that this could be fixed by tuning the decreaseIndentPattern and increaseIndentPattern for XML. Has anyone already done that?
The reason this doesn't work, sadly, is due to a limitation of the folding engine. In a nutshell, the "closing" fold needs to be at the same tab stop as the "opening". In my experience the indenting behaviour maps fairly consistently with the folding behaviour.
A workaround to make the example fold, and perhaps re-indent properly:
<gaga> <bar at1="" at2="" at3="" at4="" at5="" at6="" at7="" at8="" at9="" at10="" /> gaga </gaga>
Less than ideal, I'll grant, but you get used to it.
~ Daniel
Daniel,
Daniel Stockman wrote:
The reason this doesn't work, sadly, is due to a limitation of the folding engine. In a nutshell, the "closing" fold needs to be at the same tab stop as the "opening". In my experience the indenting behaviour maps fairly consistently with the folding behaviour.
A workaround to make the example fold, and perhaps re-indent properly:
<gaga> <bar at1="" at2="" at3="" at4="" at5="" at6="" at7="" at8="" at9="" at10="" /> gaga </gaga>
Less than ideal, I'll grant, but you get used to it.
The issue is that I often use the re-indent command on code that I haven't written myself, to make it more readable. (It is amazing to me how some people manage to get any work done on totally badly indented XML files!) So I don't have the option of putting the /> on a new line.
As a workaround, I changed decreaseIndentPattern to kick in when it finds a /> on a line where there is no corresponding <. So you would get the following:
<foo> <bar a1="v1" a2="v2" a3="v3"/> <bar/> </foo>
The a3="v3" is not properly aligned with the a2="v2", but at least the remainder of the code around is properly indented. With this updated decreaseIndentPattern, if you put the /> on a new line, as you suggested, you also get the correct indentation:
<foo> <bar a1="v1" a2="v2" a3="v3" /> <bar/> </foo>
Not ideal, but I think an improvement over the default pattern. Here is the updated pattern:
decreaseIndentPattern = '^\s*(</[^>]+>|-->|--%>|[^<]*/>)';
Alex
----- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ Personal Blog: http://avernet.blogspot.com/ Twitter - http://twitter.com/avernet