6 ms·
The context in the original question makes clear: the OP is not looking to save space. He wants to take out the structural (tabbed) spacing inherent from the ne
by asolove 15y ago
The context in the original question makes clear: the OP is not looking to save space. He wants to take out the structural (tabbed) spacing inherent from the nesting of XML in order to make it visually clear where documents have manually-inserted whitespace.
This is actually a really interesting question, although I'm not sure the answers there are very helpful. I would prefer seeing the code actually indented, and then a light-gray visual guideline where the structural indentation ends, e.g.:
|<xml:something>
|<xml:what-the>
| left some extra whitespace
|</xml:what-the>
|</xml:something>
- kenjackson 15y agoYes, I like your approach the most of those listed.
- mjschultz 15y agoIt's been a while since I used an IDE (instead of vim), but don't most of them support code-folding that provides a light gray bracket for a block of code (usually with a collapsible indicator at the top)? Or is the effect you want slightly different?
- Jach 15y agoNote vim can do folds too. (Not a commonly known feature, I only learned about it recently myself.) But the effect he wants is the literal bars showing indentation levels which I think some IDEs have... vim could fake it by highlighting the bg cells.
- jtreminio 15y agoPHPStorm does something very similar to this, and it jars me everytime I try to use Netbeans and this is missing.
- ars 15y agoHe wants automatic detection of nesting? Good luck with that, considering I find it hard to manually decide how to indent mixed PHP, HTML and Javascript code. I can't imagine an automatic tool having any success.
- greyfade 15y agoThat's more or less what I told him on his other question. He originally wanted to make it more general-purpose, so that this same editor interface would be used for programming languages in general. I did my best to talk him out of that madness and he has since narrowed his scope to XML.
- mvzink 15y agoThat's the idea man, somebody's gotta imagine it.
- lurker19 15y agoThe point is to have multiple layout/decoration algorithms to toggle between, depending on which aspect of the code the user wants to focus on.
- ars 15y agoTell me how it could indent this correctly: <?if(bool):?> <TABLE class="foo"> <?else:?> <TABLE class="bar"> <?endif;?> <TR><TD></TD></TR> </TABLE> If you only look at the HTML it looks like a doubly nested table. If you only look at the PHP the inner elements of the table will not be indented correctly. And this is a very simple example. Real code can be far more complex - for example the table tag could be generated by a function, and not even visible in this file. If you took my indenting, and converted it into some kind of graphical display that might be cool. But automatic detection? Good luck.
- asolove 15y agoThis is not the question asked. The question is specifically about XML documents, where there is a single and quite easy correct answer for the indentation.