Live data from Hacker News

The Definitive Guide to Syntax Highlighting

wilfred.me.uk

21–24 of 24 posts

Re: The Definitive Guide to Syntax Highlighting

#21
This made me think that it would be useful to have different, easily switchable highlighting modes: syntax and symbols when I'm writing, structure when I'm reading code.

Or maybe syntax highlighting for the scope I'm in and structure for the rest.

I often use the folding/nesting indicators when reading code, it would be an extension of that.

Re: The Definitive Guide to Syntax Highlighting

#22
post #21

This made me think that it would be useful to have different, easily switchable highlighting modes: syntax and symbols when I'm writing, structure when I'm reading code. Or maybe syntax highlighting for the scope I'm in and structure for the rest. I often use the folding/nesting indicators when reading code, it would be an extension of that.

The editor Source Insight had/has this feature, code was in one of two modes, draft or preview. I think that the syntax algorithm was the same, but draft was fixed pitch, syntax colored only, whereas preview had proportional fonts, different sizes and styles in addition to color

I last used SourceInsight circa 2005 so I have no idea about its current status

Re: The Definitive Guide to Syntax Highlighting

#23
post #21

This made me think that it would be useful to have different, easily switchable highlighting modes: syntax and symbols when I'm writing, structure when I'm reading code. Or maybe syntax highlighting for the scope I'm in and structure for the rest. I often use the folding/nesting indicators when reading code, it would be an extension of that.

I've been using (and loving) something similar to this while switching modes between code and prose in vim [0]. In addition to changing how syntax highlighting, spellchecking and line breaks happen, there are some other interesting bits specific to prose; like formatting text for pasting into word processors, &c.

[0] http://alols.github.io/2012/11/07/writing-prose-with-vim/

Re: The Definitive Guide to Syntax Highlighting

#24

The best highlighting is no highlighting at all. Think about it. You've read that the best programs read like a book. Now picture a book you are reading where the title, subject, nouns and verbs were all colored in some way. Try and read smoothly through that forest and think about highlighting some more. There are a number of articles about reading on the web and how you highlight links without interrupting the flow…

I like to think of syntax highlighting as a quick draft-parse. It lets you know how the computer is parsing the code structure. I know, "Code is written for humans to read and only incidentally for computers to execute", but you'd be quite put out if the computer didn't execute your code.

If human languages were written for one more-or-less uniform reader, I'd love a feature that showed how people would resolve pronouns ("Mary gave Sue her laptop.") or ambiguous attachment in general. Granted that's semantic, and probably closer to the feature in some editors where other instances of the same variable are highlighted on hovering, but they are both a form of visual feedback as to how the input token stream will be interpreted. I'd also say it's more important to get that information with a computer, because humans are pretty good at error recovery, and can often resolve syntax errors at the semantic level ("This sentence doesn't make sense; presumably it's a typo and was meant, because that makes sense in context.")

In fairness, I dislike most highlighting schemes, but they definitely have a certain value.

Post reply on HN