5

It is generally agreed that posted code is best formatted so that the horizontal scroll is not required for the code box in most cases and for most users.

I have conducted surveys here and on Meta Mathematica and found that the common length varies between sites due to the different designs uses but that most users see the same code box width. I have also learned that those of us using non-default zooms may have very different, often greater, code box widths.

  • I am requesting a feature that indicates when code is wider than an ideal width (as defined by the majority of viewers). This should be a visual indicator such as a vertical line in the edit preview area, rather than a pop-up or other annoyance in the editing area itself.

  • The line would be present only for those with wider-than-normal code boxes.* For users with the "common" code box width the code box preview already serves this purpose.

It would be useful to me to have this functionality personally if someone is able and willing to provide a userscript, but I feel that this feature has general application and benefit as it would inform those who are unaware of the common line length and subtly remind those who are in the habit of ignoring it.

Since the common code box width varies by site design it would be necessary to have his configurable by site, perhaps by the moderators.

I am tagging this with because if anyone has a better idea about how to accomplish what I describe two paragraphs above I'd like to hear it.


* It could also appear for those with narrow than normal code boxes when long lines exist and would serve to provide these users as well with a guide for what the common width is on a platform that otherwise provides no indication.

5
  • As an aside: note that on mobile, code blocks do not scroll, but use whatever width is available and wrap lines. I've not used the Android app, so I don't know what's used there.
    – Arjan
    Commented Aug 16, 2013 at 11:27
  • @Arjan Thanks, I was not aware of that.
    – Mr.Wizard
    Commented Aug 16, 2013 at 11:32
  • See the screen captures on your first survey: some Android, some iOS. On tablets, the width might be taller than the regular site, but then such tablets would probably use the regular website rather than the mobile theme.
    – Arjan
    Commented Aug 16, 2013 at 11:43
  • @Arjan Well that's embarrassing. I guess I was aware of it and forgot, as I did read those threads at one point.
    – Mr.Wizard
    Commented Aug 16, 2013 at 11:47
  • Another aside: mobile used to have scrolling too, but this was changed because "Two-finger scrolling doesn't work reliably (or at all) on some of the Android devices I've tested with. Makes wrapping the only real option." (Also, many users don't even know that their mobile might support two-finger scrolling.)
    – Arjan
    Commented Aug 16, 2013 at 12:05

1 Answer 1

1

I agree that this would be useful, but I struggle with how useful it would be and whether it would be worth the development effort for something that will be —at best— a fallible hint. Obviously the ideal is that code blocks would never be scrolled horizontally, but to me it is usually more important that the code I'm reading is unmodified from the original. If people are encouraged to fiddle with their code so that it fits the SE window they may be inadvertently making changes that are relevant to the question/answer.

1
  • For now I shall not argue with the question of whether it is worth the development method. However what I am asking for is not different for the majority of users from what they already see. Most users see the horizontal scroll bars in the preview and on the post itself and can ignore it if the choose. However there is a group of users who will not see these scroll bars when the code is over-width; I am proposing providing an indicator only for these users. This would not introduce any new problems such as people feeling forced to reformat their code.
    – Mr.Wizard
    Commented Aug 16, 2013 at 10:58

You must log in to answer this question.

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