5

This question already has an answer here:

How to enter code snippets in posts on Stack Overflow? I am getting frequent error messages while submitting posts with code. I am getting the following message:

Your Post appears to contain code that is not properly formatted as code.Please indent all code by 4 spaces using the code toolbar button or the ctrl+k keyboard shortcut.for more editing help , click the ? tool bar icon.

I have tried this by using ctrl+k -->enter code here and entered the code but I am getting the same error message. Also, I have tried using ">" before every line, even then the same message appears.

marked as duplicate by Tobias Kienzler, Antony, Danubian Sailor, Mat, Aziz Shaikh Aug 15 '13 at 7:07

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 Aug 15 '13 at 5:35

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

  • A simple way: type the code, select the code, press Ctrl + K. And you should ask this question on Meta. – Yu Hao Aug 15 '13 at 5:34
  • Even here, this information is very searchable. For example, there are guidelines when writing your post with a link to more information. – chris Aug 15 '13 at 5:35
  • There's a ? icon at the top right of the box where you entered your question. Click it, then click "advanced help". – Keith Thompson Aug 15 '13 at 6:12
3

To create code blocks or other preformatted text, indent by four spaces:

This will be displayed in a monospaced font. The first four spaces
will be stripped off, but all other whitespace will be preserved.

Markdown and HTML are turned off in code blocks:
<i>This is not italic</i>, and [this is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

The $ character is just a shortcut for window.jQuery. If you want to have a preformatted block within a list, indent by eight spaces:

  1. This is normal text.
  2. So is this, but now follows a code block:

    Skip a line and indent eight spaces.
    That's four spaces for the list
    and four to trigger the code block.
    

StackOverflow guide.

  • 7
    Where did jQuery come from? – Paulpro Aug 15 '13 at 5:36
  • This is the most frustrating part of using StackOverflow for me. For YEARS, I still cannot get this to work. GitHub is so easy. Why not use support GitHub markup. – user24601 Aug 11 '18 at 17:02
0

Highlight/Select the code and press Ctrl+k.

  • Unfortunately, this does not work for me. – user24601 Aug 11 '18 at 17:02