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

Possible Duplicate:
How do I format my code blocks?

how to write code in a question/comments on stackoverflow?

share|improve this question

migrated from stackoverflow.com Apr 22 '11 at 21:47

This question came from our site for professional and enthusiast programmers.

marked as duplicate by ChrisF, Rosinante, waiwai933, John Saunders, Shog9 Apr 23 '11 at 4:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

5 Answers 5

Before and after your code block press the ` (backtick) key followed by a blank space.

Backtick key is here on most english keyboards:
backtick key

code block

(see Markdown Editing Help page)

share|improve this answer
This is a comment to show you that backtick key to mark inline code spans work on comments too: println('It works on comments too!'); – Francisco Alvarado Apr 22 '11 at 22:03

Above the text box there is a button with curly braces. Mark your code and push that button.

share|improve this answer
YES! I've been looking for this! – T.J. Feb 23 '12 at 16:18

If you add four spaces before a line, it will become code. Otherwise you can copy and paste your code into the text box. Select it, then press the {} button at the top of the form to turn it into code.

share|improve this answer

It tells you on the right side when you are writing the question. I believe it is 4 spaces in front of each line of code.

share|improve this answer

Put it within backticks or indent the lines with four spaces. This information is clearly provided to you when you go to the post-a-question link.

share|improve this answer
You need to use a backtick (`), not an apostrophe / "single quote". :-) – middaparka Apr 22 '11 at 21:48
Fixed, thank you! – chandsie Apr 22 '11 at 21:50