1

This question already has an answer here:

How to write code in a question/answer on a Stack Exchange site?

marked as duplicate by Shadow The Dragon Wizard discussion Dec 25 '15 at 19:47

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.

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

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

10

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

(Note: Do not mistake Backtick character and key ` with apostrophe character and key ') Thanks to @middaparka for the advice

Backtick key is here on most english keyboards:
backtick key

code block

markdown
(see Markdown Editing Help page)

  • 1
    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
  • And all my life I've been prepending every single line with 4 spaces – floribon May 17 '16 at 13:52
1

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

0

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.

0

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.

0

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.