Live data from Hacker News

How can a code editor hint at code nesting level without indentation?

programmers.stackexchange.com

21–25 of 25 posts

Re: How can a code editor hint at code nesting level without indentation?

#22
post #4

I believe Xcode 4 does something similar to the heatmaps shown here, although it does everything vertically, in shades of gray. You can sort of see it in this screenshot - look in the left-hand margin of the code editing window. http://www.neowin.net/images/uploaded/xcode4.jpg

Xcode 3 does this as well.

Re: How can a code editor hint at code nesting level without indentation?

#23
post #17
post #3

Earlier quoted context omitted.

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 t…

He 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.

The point is to have multiple layout/decoration algorithms to toggle between, depending on which aspect of the code the user wants to focus on.

Re: How can a code editor hint at code nesting level without indentation?

#24
post #17

Earlier quoted context omitted.

He 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.

The point is to have multiple layout/decoration algorithms to toggle between, depending on which aspect of the code the user wants to focus on.

Tell me how it could indent this correctly:

    
      
    
      
    
        
      
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.

Re: How can a code editor hint at code nesting level without indentation?

#25
post #24

Earlier quoted context omitted.

The point is to have multiple layout/decoration algorithms to toggle between, depending on which aspect of the code the user wants to focus on.

Tell me how it could indent this correctly: 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…

This 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.
Post reply on HN