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

I tried to do this today, and whenever I hit Return to get to the line where I want to put the comment, the editor thinks I'm done with the comment as if I'd hit Enter to mean "I'm done", instead of to go to the next line. I didn't see a place in the comment code editor to disable this intepretation of Enter, but then I realized, perhaps Stack Overflow doesn't want us to put code in comments. Hmm...

share|improve this question

1 Answer 1

up vote 11 down vote accepted

The real question here seems to be whether you can insert line breaks in comments. And the answer to that question is no. There is no magic key sequence that will insert a new line, and that's by-design.

You can use Shift+Enter to insert a line return inside the edit box, but it will not be rendered on the page once the comment is posted. So this is a fairly useless feature, in my opinion, even though they apparently do show up in the data dump.


However, there is a way to insert short code snippets in comments. It's the exact same syntax that's used to indicate inline code snippets in posts (questions or answers). All you have to do is surround the phrase with backticks (`). For example, you would enter (exactly as shown):

Use the tag `<blink>` to get that effect.

To get this:

Use the tag <blink> to get that effect.

It's obviously not designed for long snippets of code, but comments aren't designed for long anything. They're only for brief responses to a post. If you really need to post some source code, you need to post an answer to the question, instead.

share|improve this answer
1  
Yes, but if one of the Illuminati has closed a question, all the action is in the comments. Code in comments, on stack overflow...what a crazy idea! e.g. Printing 1 to 1000 without loop or conditionals –  user643722 Jan 6 '12 at 23:51

You must log in to answer this question.

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