56 votes

Why does the first line of a code block often get an extra level of indentation?

The cause is a user incorrectly thinking that the "Code Sample" (Ctrl+K) button in the editor should be pressed before pasting the code, instead of after pasting and selecting the code block....
  • 237k
45 votes

Code blocks surrounded by single backtick then triple backticks

status-review The problem is, in fact, the new Stacks editor used in the wizard. Just click the "inline code" button and try to paste some code (even a single line triggers it): Note that ...
  • 17.6k
29 votes

Do you agree that questions/answers on Stack Overflow should be included in code blocks as comments instead of long explanations?

Only code comments belong in the code block. The explanation of your code should be provided regardless of any code comments. They're not the same thing.
  • 29.8k
25 votes

Do you agree that questions/answers on Stack Overflow should be included in code blocks as comments instead of long explanations?

Do you agree that questions/answers on Stack Overflow should be included in code blocks as comments instead of long explanations? No. It's harder to delineate between comments in the code and ...
  • 8,473
25 votes

Do you agree that questions/answers on Stack Overflow should be included in code blocks as comments instead of long explanations?

No. Code comments are not meant for general prose and they are not suitable for it either. The point of a code comment is to describe the immediate code around it. Including a general question such ...
21 votes
Accepted

Putting code in quote blocks when not quoting anything - is removing the quotes correct?

Of course one should remove improper formatting when found. If a block of code is not a quote, quote formatting shouldn't be used. Blockquote formatting is reserved for things copied from somewhere ...
  • 40.5k
19 votes

Should I use inline code when mentioning a class, function, interface name?

Today someone kindly told me that: Name of interface are not "code". As code are the constructors. That someone is wrong. Code is anything written in an IDE, which includes the names of ...
  • 20.6k
15 votes

Do you agree that questions/answers on Stack Overflow should be included in code blocks as comments instead of long explanations?

I think there's two separate issues here: Keeping code blocks that must be copied to test a solution all in one piece This is a good goal. The "slicing with row index by..." comment is ...
  • 17.6k
14 votes
Accepted

How to paste Python code in Stack Overflow without DIY

You can always use three backticks (```) and prevent the need to indent the code: ``` code ``` Or select and use Ctrl + K to indent automatically.
  • 22.6k
13 votes

Are there any Stack Overflow rules regarding line indentation in formatted code?

It's important to look at things in perspective... ...and to be fair, the new edit makes the post a bit more readable and would be something we'd trust someone with expanded edit privileges to do. It ...
  • 103k
9 votes

Give a code block a filename

It's relevant and useful to include the name of the file that a code block should go in Not always. Many questions give a short block of text as an example of where they're having the problem, and ...
  • 5,923
8 votes

Do you agree that questions/answers on Stack Overflow should be included in code blocks as comments instead of long explanations?

Conserving vertical whitespace isn't a realistic problem for well posed questions If you need to mention single lines of code in the middle of the prose of a question, that is supported: Suppose I ...
7 votes

Do you agree that questions/answers on Stack Overflow should be included in code blocks as comments instead of long explanations?

A lot has been said in this meta post. I have but one thing to add which is kind of a running theme of this meta post. Do not go against the grain. Our personal opinions do not matter when it comes to ...
  • 5,050
6 votes
Accepted

Correct use of code block formatting?

A code block is for when you have code; hence why it's called a code block. A quote block is for when you are quoting something; that might be an article, documentation, a quote/comment, book, or even ...
  • 85.9k
6 votes
Accepted

Code blocks surrounded by single backtick then triple backticks

Markdown mode in the Stacks Editor will no longer automatically add code fences for pasted-in code. So this will solve the issue for when folks paste code blocks into inline code sections. It still ...
  • 40.4k
5 votes

Mixing monospace and normal text doesn't look nice

So the cause of this is that ...well, they are misaligned. By 2 pixels: The fact that it's 2 pixels is unsurprising, given that the font-size of inline code blocks is 13px, while post body text is ...
  • 17.6k
5 votes

Literal tab in code block renders as four spaces

I'm confused and saddened by the staff response here, and would like to urge reconsideration. Accuracy is more important than uniformity This way we can guarantee that whitespace in our code snippets ...
4 votes

Code blocks surrounded by triple backtick then single backtick

Given the high amount of questions presenting code blocks formatted incorrectly, with the support of our designers, we have decided to make 2 small UX adjustments to the editor menu commands (see ...
  • 11
4 votes

HTML formatting inside highlighted code blocks is no longer supported - how can I fix my posts?

Why is text formatting in code blocks now broken? This is caused by a change to the syntax highlighter used by Stack Overflow, Highlight.js. As of version 11 (released May 2021), support for HTML ...
  • 1,958
4 votes

Cannot figure why am getting "Your post appears to contain code that is not properly formatted"

It can also be code in tables. This caused my answer to be rejected: |Mathematical Operation|JSBI Operation| |---------|----| |Addition|c = JSBI.add(a, b)| |Subtraction|c = JSBI.subtract(a, b)| |...
  • 1,599
3 votes

Prevent wrapping inline code

There will always be some ambiguities when determining where to insert line breaks in code. Short of inserting a character that instructs the browser to not break the word here, I have no idea how you ...
1 vote

'Code zoom' feature to view code in expanded popup

How would this make "a huge difference"? As you can see here, that example code snippet would be perfectly readable if posted on Stack Overflow now, save for two extremely long lines, the ...
  • 237k

Only top scored, non community-wiki answers of a minimum length are eligible