I often see new users that are unaware of the formatting capabilities of the WMD editor, prominently the "format as code" function.

Some of them don't format their code at all (especially XML and HTML will not show up in the question, and other code gets line-wrapped), or they shoot themselves in the foot trying to make the editor do something that could be easy (replacing < with &lt; to make HTML tags appear, sprinkling <br> tags to force line breaks).

As a user who edits many questions, it results in a lot of work to correct these misunderstandings. I know there are editor buttons and a help section on the right, but in general - people don't read anything.

I propose that new users (less than 100 rep or so) get their WMD editor pre-filled with some advice like this:

Welcome to StackOverflow. Here is a quick overview of what you 
can do in this editor:

Indent blocks of code by four spaces (you will even get automatic 
syntax highlighting!):

    <xml code="sample">
      <!-- use the "0101" button above, or the CTRL-K keyboard shortcut -->

Use backticks to format inline bits of 
code: `var hint = "The button or shortcut work here as well!"`

You can also write **bold** or *italics*, use lists

- like
- this

or headlines

##Like This##

The editor can do even more, take some time to explore its capabilities. 
  • 8
    a very nice idea, but I'd limit it to brand new users Oct 8, 2009 at 9:09
  • 2
    Agreed, it must go away quickly. Then maybe to those that do not have yet asked a question (or written an answer), or maybe have less than 30 rep instead of 100.
    – Tomalak
    Oct 8, 2009 at 9:43

5 Answers 5



Simple method for reliably detecting code in text?

We just deployed a method that we think is quite reliable for blocking 98% of posts submitted with code that has improper code formatting (or no code formatting at all).

For example, when I go into Chrome incognito and attempt to ask this question body on Stack Overflow right now:

I needed to add up all the rows for a result. Using the select_sum as follows

Here is the model

function Dues_Paid_Tot($date)
        $query = $this->db->select_sum('Dues_Paid', 'Dues_Paid_Tot');
        $query = $this->db->get('Membership');
        return $query->result();

Here is the controller

function Fiscal2()
    $date = $this->input->post('Select_Date');
        if($query = $this->report_model->fiscal_list($date))
            $data['records'] = $query;
    $data['date'] = $this->input->post('Select_Date');
    $data['Dues_Paid_Tot'] = $this->report_model->Dues_Paid_Tot($date);
    $data['main_content'] = 'report_fiscal_view';
    $this->load->view('includes/template', $data);

I get back:

Oops! Your question couldn't be submitted because:

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 [?] toolbar icon.

This check is limited to users with <= 50 reputation and is performed on questions / answers / edits and suggested edits.

If you see or hear of any cases where this is triggered inappropriately -- or not triggered, and it should have been -- let us know.

  • since you posted this way back when, there is much better formatting help as well. But the types of users who can't format code aren't reading much.. we have to block them. Jul 13, 2011 at 13:05
  • You do realize that your comment links to this very question? :-) I've seen the help (via Chrome's incognito mode), it's awesome. Better than I would have wished for. — Regarding those that don't read anything: Yes, there is a certain human factor you can't do anything about. :( Some people straight-out refuse to think if there is any way to avoid it. I wonder why some of them decide to become programmers.
    – Tomalak
    Jul 13, 2011 at 18:35
  • @Tomalak, Jeff's comment should point to Is there a way to improve new user code-formatting in questions and answers?, I guess.
    – Arjan
    Jan 8, 2012 at 11:21

What'll happen is, users will just post the help text as their question...

  • That's something we could check for?
    – kanamekun
    Oct 8, 2009 at 17:06
  • True! A few times I've seen code segments that begin with "enter code here". Oct 8, 2009 at 17:06
  • 3
    CodeProject does this with their article entry form. And they do check for the boilerplate during submission... Still, idiots show up and enter some text while leaving half the original text in place. On the one hand, it's a dead giveaway: if you see any shred of the boilerplate in the final article, you can pretty much stop reading. On the other hand, it makes already pathetic articles look even more so.
    – Shog9
    Oct 8, 2009 at 17:12
  • 1
    Well... You can't check for every idiocy people can come up with. But you can help those that stare at a big white screen and are at a loss. It's just psychology, to a certain degree.
    – Tomalak
    Oct 8, 2009 at 18:47
  • 1
    it can't possibly be more than the number of users who currently show up and post 200 lines of unformatted PHP code in their question.
    – Kip
    Oct 26, 2009 at 21:42

They don't read now, what makes you think they'll read some "junk" that they need to clear out of their way in order for them to get the codez now, post haste!

Anyway, that's too much text. Cut it down to the real meat:

If you have code, select it and then hit the icon with the 101010.

But they won't even read that.

  • If it is right in their way and looks welcoming and helpful, the odds that they read (or at least skim) it are much higher. But I agree that the text may be shortened, just not as much as you propose. It must look like advice, not like line noise.
    – Tomalak
    Oct 8, 2009 at 9:45
  • Select your code and hit Ctrl-K
    – Amarghosh
    Oct 8, 2009 at 12:50
  • Shortcuts might not work for non-US layout keyboards.
    – random
    Oct 8, 2009 at 12:54

I don't think that this is a good idea. People have a question and they want this question on the site and often ASAP. They won't read the pre-filled text.

But what about forcing users to preview their questions before they can post them? Yes, I admit that most of them will not be reading their own questions either, but if you paste a couple of lines of code, you expect the block to stand out in the preview which will not be the case if the editor just treats it as a paragraph of text.


Great idea, though I think some of that can be cut back. No need to explain lists or headlines or even backticks. Just bold, italics, and code block will probably suffice.

And maybe the editor window can be smaller than normal for these users, so that they are more likely to notice the preview text?

  • 1
    A smaller window might also discourage the pasting of huge code blocks.
    – Ether
    Oct 26, 2009 at 22:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .