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...

1 Answer 1


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.


You must log in to answer this question.

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