Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 155 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

This might appear silly, but I have been wondering for a while, how can I put code inside a comment in stackoverflow. I haven't been able to figure this out. I have seen users putting those grayish blocks in a comment.

I tried (<pre><code>) but that didn't work.

Regards

share|improve this question

migrated from stackoverflow.com Jul 2 '10 at 1:49

This question came from our site for professional and enthusiast programmers.

    
you mean like this? – tster Jul 2 '10 at 1:48
    
This belongs on meta – fmark Jul 2 '10 at 1:49
up vote 3 down vote accepted

You can use backquotes to insert code in comments, just as you might insert inline code in a question or answer: printf("here is some code\n");

share|improve this answer
    
@Ether - I tried doing this. Text wrapped in backquotes displays a gray block in question or answer, but in comments it displays a highlighted box. How do I get the grey box in a comment? – ShiVik Jul 2 '10 at 2:23
    
@ShiVik: what dis the difference between a highlighted box and a grey box? Do they both use a monospaced font? – Ether Jul 2 '10 at 2:24
    
Yes. highlighted box is just white in background, it appears hightlighted when I hover the mouse over the comment which has it. Grey box is always highlighted grey whether I hover mouse over it or not. – ShiVik Jul 2 '10 at 2:31

Putting four spaces before the code will automatically generate the code block. Inside of a comment, you can wrap it with ` and it will demarcate the code. Or simply mark up the code that you want to be laid out as code and press the button with the 101010 label.

share|improve this answer

You can't, because the comments only support limited markdown tags.

Stop with the down votes - this was migrated while i was in the middle of editing it!! What i was busy clarifying is that it isn't a full code block - you don't get syntax coloring etc, just the highlighted background.

For the FAQ on comments check here. For the details on allowed markdown, check here.

share|improve this answer
1  
You were probably downvoted because the OP mentioned specifically what he was looking for: "I have seen users putting those grayish blocks in a comment." – Michael Mrozek Jul 2 '10 at 1:58

use backticks "" <code here> "".

BTW, this belongs on meta.

share|improve this answer

You must log in to answer this question.

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