1

I often see code that is poorly formatted and I stop looking at the question because I don't have the time to try to parse it. Yes we should format it ourselves when posting a good question, but we know that doesn't always happen, specially with newbies.

I'm not talking about the button that displays something as code, I'm talking about a pretty-print button that would apply some formatting to the code that is set to display as code. Something like what this website does http://prettyprinter.de/module.php?name=PrettyPrinter

What's the chances that code can get pretty printed automatically? Or at least a a button to do it for you?

0

1 Answer 1

0

enter image description here

8
  • 1
    That just higlights the code? I mean one that fixes your indentation and makes your code legible Commented Sep 15, 2014 at 17:25
  • 1
    @JuanMendes That's going to vary widely based on the language, the personal preferences of the programmer, etc.
    – Servy
    Commented Sep 15, 2014 at 17:26
  • But it could use some sensible defaults, use it if you want to? There are plenty of tools that do pretty printing of most languages. Commented Sep 15, 2014 at 17:28
  • @JuanMendes An an enormous amount of work goes into writing them. It requires lexing/parsing the code (which is far harder to do if you don't actually know what language the code is written in) doing a lot of semantic analysis of the code (also extremely hard to do if you don't know what language the code is written in) and then applying a fairly complex set of rules on how to intent the code. Having SE do all of that would be...very hard.
    – Servy
    Commented Sep 15, 2014 at 17:30
  • IntelliJ does it, I never said it was easy. I'm just tired of seeing poorly formatted code. Commented Sep 15, 2014 at 17:33
  • 1
    @JuanMendes You're going to need to justify why spending that extremely large amount of development effort is actually worth it, given that programmers already have access to other tools that already do this for the languages they're active in.
    – Servy
    Commented Sep 15, 2014 at 17:35
  • Servy I'll save my comments for the question that I searched for and didn't find Commented Sep 15, 2014 at 17:39
  • Another problem is that the code posted on SO is often broken, that's why people come to SO in the first place. So your formatter does not only have to deal with hundreds of languages with thousands of versions and variations, but also must be able to handle syntax errors.
    – lxg
    Commented Sep 15, 2014 at 20:41

Not the answer you're looking for? Browse other questions tagged .