129 votes
Accepted

Change the code block button from inserting indentation to triple-backticks

Absolutely. Fenced code blocks are a dramatic UX improvement. The extra indentation makes editing an existing block much harder. Fenced blocks make the process of copy/pasting code into the question ...
jpmc26's user avatar
  • 28.7k
92 votes
Accepted

Should code be edited so that it is visible rather than being in one long line?

Yes, if you're improving the quality of the post, you should make the edit. Code on a single line is not very readable, so formatting it is an improvement. Make sure that when formatting the code you ...
cigien's user avatar
  • 58.7k
79 votes
Accepted

How do I remove excess indentation on my code blocks?

For reasons previously unbeknownst to me, the same keyboard shortcut that you use to format unformatted code as Markdown code blocks (Ctrl+K) can also be used to reduce the indentation of code blocks ...
BoltClock's user avatar
  • 705k
73 votes

Could Stack Overflow support GitHub flavored markdown?

Another benefit that I'm surprised hasn't been given more emphasis is the ability to specify the language ```php class PleaseAdd { public function tripleBackTicks() { echo "please"; }...
andrewtweber's user avatar
  • 24.8k
70 votes
Accepted

Why are posts edited to change the code formatting markers?

It depends on the case. As most of the time the "why someone did something" question is asked, only the specific "someone" can really answer it. In the one you linked, I would say ...
yivi's user avatar
  • 43.3k
67 votes
Accepted

Should I review questions with images of code as "looks ok" or "requires editing"?

Neither of the options you are considering. If there are pictures of code instead of code, the question should be closed. The most appropriate reason would be: "Requires editing" is when someone ...
yivi's user avatar
  • 43.3k
59 votes

Change the code block button from inserting indentation to triple-backticks

I agree. One of the biggest annoyances I face is reviewing edits from new users who have added code fences to indented code without removing the first layer of indentation. Code like this: const myVar ...
Joundill's user avatar
  • 6,969
58 votes

Is it frowned upon to use backticks around a word or even part of it to refer to some function or keyword as part of a sentence?

Code blocks mark a language boundary; only use them when your formatting helps to distinguish prose meanings from code meanings. Partial-word code blocks can be particularly distracting or can impair ...
Jeff Bowman's user avatar
  • 92.1k
57 votes
Accepted

A way to reduce the number of questions with only images?

While your suggestion is, like most suggestions posted on Meta, both reasonable and simple, the chance of it being implemented within the next millennium is, again like most suggestions, zero or as ...
Ian Kemp's user avatar
  • 28.6k
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....
Cody Gray - on strike's user avatar
53 votes

How does the highlight.js change affect Stack Overflow specifically?

My recommendation: If you know the language, go ahead and explicitly set it. Even on posts where the question includes exactly one language tag? So far, language tags overrode the heuristic for ...
Konrad Rudolph's user avatar
53 votes

Is it frowned upon to use backticks around a word or even part of it to refer to some function or keyword as part of a sentence?

I think occasionally it is OK, but most of the time a different phrasing only costs one extra word, and adds enough extra clarity and readability that the trade-off is worth it: "Use DateTimes ...
kaya3's user avatar
  • 48.2k
52 votes
Accepted

For a single lengthy command, which code markup syntax is preferred?

For a *nix command line it makes the most sense and is the most readable, in my opinion, to put it in a code block and use a \ line continuation to break it into readable length lines. Horizontal ...
Stephen P's user avatar
  • 14.5k
46 votes
Accepted

Are backticks appropriate for emphasizing references to things that show up in code?

Yes, this usage is acceptable. Identifiers that are found in source code are code, and therefore it's acceptable to format them as if they are code. The rule is, inline code formatting is only for ...
Cody Gray - on strike's user avatar
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 ...
Ryan M's user avatar
  • 18.7k
44 votes
Accepted

Why is there no line numbering in code sections?

Adding line numbers is a no-brainer to me. It's frustrating that line numbers aren't included in SO. How many of us code without line numbers? (I sure don't). There simply isn't a better way to ...
yano's user avatar
  • 4,995
44 votes

Should there be a warning for code containing bidirectional Unicode text?

Rather than a warning – which might be gamed by some bogus reason why it's there in prose – or outright blocking – which might block valid questions or answers – invisible unicode characters, I ...
Baum mit Augen's user avatar
  • 49.2k
44 votes

Should code be edited so that it is visible rather than being in one long line?

In general, my answer would be "yes, but...", but in this case it would be "probably not." It depends on the purpose. The probably not: You used a very specific example from r ...
camille's user avatar
  • 16.5k
41 votes

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

Include pictures in post may cause this problem. If we insert picture using Image button in toolbar, or use shortcut key Ctrl+G, a script like below will be inserted to out post: [![enter image ...
zhm's user avatar
  • 3,541
39 votes
Accepted

Support CommonMark fenced code blocks

Code fences are now implemented. See Implement ```-style (fenced) Markdown code blocks on MSE for all the details.
balpha's user avatar
  • 50.2k
39 votes

For a single lengthy command, which code markup syntax is preferred?

The inline backticks are more for distinguishing references to code within the context of an English sentence (such as object names and function names). For example, a C# List has a more specific ...
ryanyuyu's user avatar
  • 6,376
35 votes

Indent 8 spaces when clicking the Code Sample button after a list item

Just a suggestion. I believe that this kind of feature request could be accepted much faster if accompanied by the pull request. Although Stack Overflow as a whole is not open source, some of ...
Your Common Sense's user avatar
33 votes

Why are posts edited to change the code formatting markers?

Spaces to fences might be useful. In cases where two language tags are specified the larger tag, by questions, is taken to highlight the code. E.g. a question tagged java and matlab will highlight ...
Adriaan's user avatar
  • 17.9k
32 votes
Accepted

When should we use code, quotes and bold blocks?

Code (be it snippets, complete code blocks, or identifiers as defined by each language but that are interspersed with regular text) should be formatted as code. So should file paths and file names. ...
yivi's user avatar
  • 43.3k
31 votes
Accepted

All my code is properly formatted, yet I am unable to post an answer due to unformatted code. Why?

In the first version of this question where you post your original markdown, you had indented code only one line down from your quoted text. When posting blocks of code there has to be a blank line ...
BSMP's user avatar
  • 4,626
30 votes
Accepted

How can I include code inside a quotation?

5 spaces are needed after > (1 for the quotation and 4 for the code). So: This class prints what is the meaning of life. class MeaningOfLife { private static final String MEANING_OF_LIFE = &...
Tunaki's user avatar
  • 134k
30 votes

Change the code block button from inserting indentation to triple-backticks

I find the original code indentation, though buggy, very useful in cleaning up code that was pasted from inside multiple indentations. If the code button was to be changed to use backticks, then I ...
Chris Schaller's user avatar
29 votes
Accepted

Is it appropriate to ask a user to spend time formatting their own code?

No, your time here is valuable and I don't think it's appropriate to waste it on something that is unlikely to have any effect. People who care, who are interested in participating here and ...
Don't Panic's user avatar
  • 41.2k
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.
Dharman's user avatar
  • 31.4k
28 votes

When should we use code, quotes and bold blocks?

When in doubt, prefer code formatting for technical content such as file paths, tracebacks, or logs. Quote style is basically fancy but regular text. Any content that purposely or accidentally ...
MisterMiyagi's user avatar
  • 45.4k

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