What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 130 Stack Exchange communities.

There are currently no plans to add support for newlines to comments (see How about newlines within comments?). However, new users often post unreadable code snippets as a comment. Comments like:

User 1: Can you show us the code?

User 2: Here is my code #include <stdio.h> int main(void) { int a = 0; char * b = malloc(SIZE) ....

I suspect that many of these are caused by users typing in code snippets with soft returns or by copying and pasting. I think these comments could be avoided by adding a message that says some variant on:

Stack overflow removes newlines on comments before display. Perhaps your comment needs to be an edit to the question or answer, a new answer, or split in to multiple comments?

There's currently no feedback that the comment is about to have the newlines stripped - and I think the quality of comments from new users would be improved by having this feedback.

share|improve this question

2 Answers 2

We absolutely don't need to encourage people to split their comments into multiple comments because they happen to contain a new line.

When someone posts cost in a comment that should be an edit, that user should be educated instead. For that matter, anyone can make that edit for them and flag comments for removal.

share|improve this answer
1  
I think it's the code snippets that are the big issue here - I added the multiple comment thing because of the top voted answer on the feature request for allowing new lines. I agree that users should be educated about edits instead of comments - and I think putting a warning message will automate a large part of that education process ;) –  Timothy Jones Mar 15 '12 at 1:55
    
@TimothyJones I think a long warning message ('Looks like you're trying to do X. Maybe you should try Y, Z, or Q instead.') is likely to confuse people who may be unfamiliar with SE in the first place. A bit of personal attention and education about the "edit" button or an invitation to post a new answer would be more helpful, IMHO. –  Anna Lear Mar 15 '12 at 1:58

This problem is much easier to solve than you think, and it doesn't require adding more error messages to the UI that no one will ever read anyway.

In fact, the problem arises in the very first comment, presumably left by an experienced user who understands that code blocks don't belong in comments and that askers have the ability to edit their questions to include additional information.

Instead of saying:

Can you show us the code?

you should be saying:

Please edit your question to include the code.

Bonus points if "edit" is an inline link to the edit page for their question, like this.

In other words, the initial comment(s) should attempt to instruct the user on the appropriate course of action.

There is never a good reason to post blocks of code in comments, so the error message you suggest showing is encouraging precisely the wrong behavior. We don't want people splitting up the code into multiple comments, and we don't want people posting new answers when they should be editing the question. Yet, it's impossible for a new user to know which of the three proposed alternatives they should choose, and most of them, unfamiliar with the idea of editing an existing post, would probably opt for one of the latter choices.

There's currently no feedback that the comment is about to have the newlines stripped

Well, not before the comment is posted. But there's feedback immediately after, which is probably even more powerful feedback than an error message they won't bother to read anyway. It is plainly apparent after the comment gets posted that it is unreadable and not useful. I see users attempt this frequently, and every time, they have deleted the comment and tried something else. Which, it seems to me, achieves everything that you hope a pop-up message would accomplish. The only problem is that they occasionally post their code as a new answer to the question, but you aren't going to prevent that either.

share|improve this answer

You must log in to answer this question.

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