1224 votes
Accepted

Why should I not upload images of code/data/errors?

You should not post code (or error/exception messages, log files, configuration files, project files, or anything else that is represented in textual form) as an image because: Images cannot be ...
180 votes

Markdown editor indent and outdent functionality

Yes, please! We are developers - we basically expect Tab to indent code and Shift+Tab to unindent it. This could be implemented on programming-related sites only (SO, Programmers, Code Review, ...
129 votes

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 ...
  • 27.9k
117 votes

Why should I not upload images of code/data/errors?

The first reason is that links to images fail. The second reason is that text on images is not searchable. The third reason is that it gives you an incentive 'not to try'; simply show us a screenshot ...
111 votes
Accepted

How should compiler errors, linker errors and logs be formatted?

I'm routinely editing questions (example) to display compiler errors in code blocks but I put <!-- language: lang-none --> in front of them to disable misleading syntax highlighting (example). ...
  • 23.9k
96 votes

How can we avoid "overhang" code indentation?

I think it's caused by people copy-pasting from the start of the function name, instead of from the start of the actual line, on indented code. Like the selection in this .gif, kindly provided by @...
  • 69.5k
91 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 ...
  • 56.9k
81 votes
Accepted

Spaces around code keywords

Yes, of course those code keywords should be surrounded by spaces. It's entirely baffling to me that anyone could claim otherwise and not be trolling.
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 ...
  • 691k
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"; }...
  • 23.9k
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 ...
  • 40.6k
66 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 ...
  • 40.6k
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 ...
  • 6,494
58 votes
Accepted

How to format a link within a code block

Sure, here you go: I tried to edit one of my posts by adding a comment within a code block which contains a link. Like so: .example { text-decoration: underline; -moz-text-decoration-...
  • 44.3k
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 ...
  • 88.8k
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 ...
  • 27.7k
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
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 ...
  • 46k
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 ...
  • 14.2k
52 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 ...
50 votes

Spaces around code keywords

I don't think there is any official guidance on this (though feel free to edit this if I am wrong) but in general, most people use spaces to separate words in sentences. This includes words which are ...
48 votes
Accepted

Why do backticks not work inside HTML lists?

This is correct Markdown behavior. As the syntax rules state: Note that Markdown formatting syntax is not processed within block-level HTML tags. E.g., you can’t use Markdown-style *emphasis* ...
  • 35.2k
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 ...
  • 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
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 ...
  • 48.7k
43 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 ...
  • 16.2k
42 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 ...
  • 4,614
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 ...
  • 3,483
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.
  • 49.7k

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