I have a wide screen like 70% of the people, still the Stack Overflow site has a small resolution support and any embedded code scroll sideways. Is there any settings that can resolved that ? (Probably not.)

  • 3
    Don't be so defeatist, have some optimism – random Feb 7 '11 at 21:56
  • 1
    Well, linebreaks are crucial in some languages. So we could have code that looks ugly , or code that looks invalid - either way, it will be Bad in some way. Given such choice, I'll take "shown as intended but ugly" over "somewhat pretty but possibly misleading" any day of the week. Perhaps some fiddling with user CSS could help you there? – Piskvor Feb 7 '11 at 22:38

Just edit the question and improve code layout. When I got inspired to start contributing to stackoverflow, this is what I did and I believe it helps all of us.

I was surprised how half of the questions that I answered became obvious to me while re-formatting the code to fit within the margins.

The problem here is that many questions are from relatively new programmers, or from people just starting with a new and foreign language. In this case, it can be hard to figure out where and when it is possible to add line breaks without changing the meaning of a piece of code.

So, my answer is that we need to rely on people to improve the lay-out of code-samples, and we cannot really rely on any code beautifiers. Even more so because of the large variety of languages present.

Therefore, we need to encourage people to break down their code across multiple lines, or for editors to improve on the layout of those code snippets. And we should do so in the SO guidelines.

Examples: Python and shell lines require backslashes to continue onto the next line, with exceptions. For the two languages, those exceptions are completely different.

I like to break of shell command lines at logical operators, with an extra level of indent:

command -which -might fail &&
    other command to run ||

No backslashes required here.

With Python, you can break lines inside brackets (function calls, lists). Anything else requires a backslash.

You must log in to answer this question.

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