4

Markdown, which is used to write Stack Overflow posts, will ignore line breaks in paragraphs as long as each line does not end with two spaces, and each paragraph contains "one or more consecutive lines of text".

This enables hard-wrapping of the Markdown source to a certain column length, like this (78 columns):

[Markdown][fireball], [which is used to write Stack Overflow posts][so-down],
will ignore line breaks in paragraphs as long as each line [does not end with
two spaces][so-breaks], and [each paragraph contains "one or more consecutive
lines of text"][fire-break].

Many text editors, such as Vim and Sublime Text, can easily hard-wrap text to a user-configured column length with a shortcut, such as gq in Vim and ALT + Q in Sublime Text (on Windows).

When editing user posts, is it OK to hard-wrap their posts to a certain column length? What about when writing your own posts?

2 Answers 2

22

If you're referring to the act of replacing something like this:

var results = from myRow in myDataTable.AsEnumerable() where myRow.Field<int>("RowNo") == 1 select myRow;

with something like this:

var results = from myRow in myDataTable.AsEnumerable()
              where myRow.Field<int>("RowNo") == 1
              select myRow;

I'd consider that a perfectly acceptable use of your edit privileges, assuming you know what you are doing.

It has to be done intelligently, however. Hard-wrapping posts to some arbitrary number of characters isn't going to work for code, for obvious reasons. For non-code text, wrapping is done automatically anyway, so hard-wrapping paragraphs of text is pointless.

17
  • For sure. Computer code on SO is constantly and habitually edited to not run wide. (WRT what Hat says below - if this question is not about that issue - sorry for the time waste!)
    – Fattie
    Apr 30, 2014 at 13:17
  • @JoeBlow the example by the OP clearly shows that he's not talking about editing code.
    – rsanchez
    Apr 30, 2014 at 17:09
  • 1
    @rsanchez: Besides code, I can't think of any other practical use case. Apr 30, 2014 at 17:10
  • @RobertHarvey yeah, that's why the other answer is right for me :)
    – rsanchez
    Apr 30, 2014 at 17:14
  • @rsanchez: See the last sentence in my answer. Apr 30, 2014 at 17:15
  • @RobertHarvey still, I think you are introducing confusion by answering in the first place something the OP didn't ask.
    – rsanchez
    Apr 30, 2014 at 17:38
  • @rsanchez: That's because what the OP asked makes no sense. Apr 30, 2014 at 17:39
  • 1
    While I detest source lines that go off the screen and require scrolling to read (especially when such formatting is added by 3rd parties), it's also important to remember that adding extra lines to code can cause its own problems; particularly if part of the question's information is a stack trace which references line numbers. Apr 30, 2014 at 18:34
  • @ChrisStratton: I find that stack traces are most easily readable by simply formatting them as code. Apr 30, 2014 at 18:36
  • The issue is not with the stack trace, but with changing the line count of the code which it refers to by line number; granted SO doesn't actually display line numbers, but once the line count is distorted it's even harder to puzzle out. Apr 30, 2014 at 18:37
  • @ChrisStratton: It's up to the OP to tell us what line of code is throwing the exception, not up to us to count the number of lines until we get to the 150th one. We might not even be seeing the entire code file in the question. Apr 30, 2014 at 18:39
  • 1
    @RobertHarvey sorry, I wrote my question and answer while I was very tired and it ended up coming out as not very clear. Voting to close as unclear for now.
    – user456814
    Apr 30, 2014 at 19:28
  • I completely agree with Robert. The question is about, and can only be, about computer code on SO. (Regarding 'changing the line breaks on quoted English text' -- who cares? It is, at best a subtle issue along the lines of would you do that in a (say) textbook - you know how sometimes you see 'line breaks changed here' sort of thing.)
    – Fattie
    May 1, 2014 at 7:35
  • Chris dude - your example is (no offense) incredibly bad. Of course, obviously, everyday, as a matter of course, always and everywhere, in every possible format, ever, online and offline, on blackboards, in handwriting, on computers, on SO, in rock carvings - of course, obviously, always, you reformat computer code so it is a good length on the page. it's just a bizarre non-starter to even be discussing this. You have raised an obscure case where, of course, you can't change the line lengths and sometimes you just have to leave it scrolling right. So what?
    – Fattie
    May 1, 2014 at 7:37
  • BTW you don't need to go to such an incredibly obscure example to demonstrate "sometimes with computer code it's better to let it run long even if it scrolls right". Often with eg string literals etc you have to let it run long (although indeed, as a curiosity, you COULD always change it - Turing - if desired, in every language). Regarding the line numbers changing. (As in "my problem is at the line marked 17...") Obviously - you just change those, if the code is formatted craply and you change the code formatting.)
    – Fattie
    May 1, 2014 at 7:39
4

The Short Answer

It's Not OK to hard-wrap someone else's post, unless they were originally hard-wrapped to a certain length.

It's also Not OK to hard-wrap your own posts, because you then make it harder for other people to edit them.

The Long Answer

You might think you're being helpful by hard-wrapping this:

[Markdown][fireball], [which is used to write Stack Overflow posts][so-down], will ignore line breaks in paragraphs as long as each line [does not end with two spaces][so-breaks], and [each paragraph contains "one or more consecutive lines of text"][fire-break].

to this:

[Markdown][fireball], [which is used to write Stack Overflow posts][so-down],
will ignore line breaks in paragraphs as long as each line [does not end with
two spaces][so-breaks], and [each paragraph contains "one or more consecutive
lines of text"][fire-break].

You're not. You're making it harder for other users to edit the post. Not everyone uses their own text editor to write/edit Stack Overflow posts, and even though some users might, not everyone knows how to configure their editor to hard-wrap text to a certain column length.

Besides, many text-editors can soft-wrap text. So no unnecessary hard-wraps, for the sake of your fellow users.

Note: I've been hard-wrapping both my own posts and the posts of other users for the past month, and I just realized how much of a Bad Idea that was. If I ended up hard-wrapping your post in the past, then I am sorry.

7
  • This seems to be completely wrong, Cupcake. IF, again that is IF you skilled in the programming language in question - once again that is IF you are skilled in the code - it is absolutely always possible (I think Turing proved this :) ) to re-format the code so that it fits properly. Of course you are 100% correct that if you are not a professional engineer with the code in question, don't touch it. Regarding the situation where you ARE an engineer for the software language in question - yes people always, and should always, edit to fit. Code that is too wide is a plague.
    – Fattie
    Apr 30, 2014 at 13:11
  • 3
    You're making it harder for other users to edit the post” – even worse, rewrapping text introduces noise into the diff which makes it harder for other users to see what you've actually edited. Outside of SE I use one line per sentence so that line-by-line diffs are fairly obvious, but SE shows diffs on a character-by-character level which completely removes the need for diff-friendly line breaks.
    – amon
    Apr 30, 2014 at 13:11
  • (Regarding your comment that, essentially, "it's hard to write computer code" - well sure. Any skilled engineer in a given language can - of course - edit code (for whatever reason) and (if desired) keep it from being too wide. It's worth noting that when you literally write computer code, you do this as a rule - you never let anything get too wide.)
    – Fattie
    Apr 30, 2014 at 13:13
  • 2
    @JoeBlow I don't think the question was about reformatting code. Apr 30, 2014 at 13:13
  • I think there might be a basic confusion here between SO entries that are computer code, and other (English, etc), SO entries. Nobody, at all, cares about SO other than for computer code. ( ;-) ) So regarding how to deal with natural English, etc - whatever you guys say. But it's totally inconceivable you would not edit objective-c, c#, etc, for width. It's must, much, much better when you do. (Occasionally, often, people don't bother - but it's better to do so.)
    – Fattie
    Apr 30, 2014 at 13:15
  • Hat Guy -- if so, fair enough, I was following Robert's answer which is the most popular so far.
    – Fattie
    Apr 30, 2014 at 13:16
  • 1
    I disagree. You arguments concern "infrastructural" aspect of the whole editing process. And this process doesn't exist for the purpose of itself - it is to improve posts. So it's much more important that you can improve a post by making it more readable (removing the necessity to scroll horizontally is a readability improvement - I hope we can agree on that), than that it will make harder to further improve the post. Note also that a good edit should leave almost nothing to improve.
    – BartoszKP
    Apr 30, 2014 at 19:29