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...
What is meta?
- Any Stack Exchange user can ask a question
- The community provides support, votes on ideas, and reports bugs
- Your voice helps shape the way Stack Exchange operates
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.
To get this:
Use the tag
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.