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 ...
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 ...
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 ...
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";
}...
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 ...
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 ...
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 ...
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 ...
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 ...
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....
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 ...
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 ...
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 ...
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 ...
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 MMod
- 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 ...
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 ...
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 ...
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:
[
DharmanMod
- 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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
code-formatting × 480discussion × 152
support × 140
bug × 135
feature-request × 104
markdown × 61
formatting × 35
edits × 27
syntax-highlighting × 26
markdown-rendering × 26
editor × 25
status-completed × 23
design × 22
code × 20
stack-snippets × 17
comments × 14
questions × 13
suggested-edits × 13
status-bydesign × 12
asking-questions × 11
quality-filter × 11
mobile-web × 8
review-queues × 8
tags × 6
error-message × 6