Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 153 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

Possible Duplicate:
How do I get my code blocks formatted?

where should we post large chunks of code that we don't want to clog up our posts?

Is there a way to make a scrollable code block? Or do we have to use external website like pastebin?

Second question - is there a more reliable way to paste code blocks? I'm finding it difficult to paste code on SO sometimes.. it will sometimes only take the 'middle chunk' of my code block as code, no matter what I do or how hard I indent or where i put the < code > blocks... any advise??

share|improve this question

marked as duplicate by Ether, ChrisF, squillman, GEOCHET, random Jan 26 '10 at 1:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Code blocks are scrollable - or am I missing something? – nb69307 Jan 25 '10 at 23:58
@Neil: the OP was using literal <code> tags, which he discovered don't work very well. Which makes me think that the stylesheet should make <code> tags work just like markdown-indented code blocks... – Ether Jan 26 '10 at 0:51
You can associate your account with your StackOverflow account, to get a 100 rep here. See this link,… – Lance Roberts Jan 26 '10 at 0:53

alt text

share|improve this answer
+1 for the work that must have took – Lance Roberts Jan 26 '10 at 0:43
+1 for the effort, although the site of that thing makes me want to poor H2SO4 into every orifice of my body – squillman Jan 26 '10 at 2:06
aaaaaaaaggghhhhh!!! kill it! killitkillitkillitkillit!!! – quack quixote Jan 26 '10 at 2:42
@squillman. Were the misspellings site and poor deliberate? – TRiG is Timothy Richard Green Feb 4 '13 at 12:49

Regarding scrolling code blocks:

If you need that much space for the code on which you're asking a question, you probably have a larger problem. Generally speaking, if I have to read your code for 5 or 10 or 20 minutes to understand what's going on, I'm not going to answer your question. It's essentially the "big wall of text" problem, but with syntax highlighting.

My recommendation is to find the smallest working set of code possible which reproduces the error, and paste that in instead. This helps those of us who might want to answer by giving us only what we need (better signal-to-noise ratio), and it helps you by not (potentially) exposing more of your (or your company's) code than is critically needed.

share|improve this answer
I have an issue with SqlCacheDepedency. I found someone willing to help me on SO so I wanted to post the SQL Trace as things happened on my website. But even posting a 50 line snippet of SQL logs is ugly and harsh. There ARE legitimate uses for a code paste / scrollable code text box! – user142370 Jan 25 '10 at 23:01
post it as a link from pastebin – Jeff Atwood Jan 25 '10 at 23:52
@unknown: You gotta go with the guy who runs the site. :) – John Rudy Jan 26 '10 at 1:32

After you paste the code block, select it, then hit the code button:

share|improve this answer
thanks! never saw or realized what that button did. – user142370 Jan 25 '10 at 23:03

Very large code blocks automatically scroll both horizontally and vertically. They still take up a lot of vertical space before they scroll, though, so your post may still appear pretty cluttered.

In general I've suggested pasting only tiny excerpts of code, with links to pastebin or similar services where the larger pieces of code exist to put the small post into context.

Regarding your second question, Code blocks must be indented by 4 spaces on every line. The editing bar has a code icon (looks like a small block of 1's and 0's) to help with this. Paste your code, then select it in the editing box, and press the code icon. It'll indent everything you've selected by 4 spaces, and it will show up correctly.

Unfortunately using <code> and other HTML tags may fail due to the use of < and > symbols in the code, so the best way is to indent everything 4 spaces.

share|improve this answer
Vertically? Are you sure? I've never seen a vertical scroll bar except when there's also a horizontal scroll bar. – mmyers Jan 25 '10 at 23:21
@mmyers You ought to frequent the C++ tags more often - see… – nb69307 Jan 25 '10 at 23:57
Huh, I wonder why the downvote? – Adam Davis Jan 26 '10 at 0:27
@Neil: I'm not sure what that's supposed to prove. I don't see any scroll bars on that question or any of the answers. – mmyers Jan 26 '10 at 15:06
@mmyers Perhaps you have them mysteriously turned off? Or are using a teeny font size? There is definitely a vertical scrollbar for the first bit of code (starting with "class stringlist") when I look at it. – nb69307 Jan 26 '10 at 16:08
@Neil: I'm guessing that Firefox/Chrome/whatever-you're-using auto-inserts scrollbars into <pre> areas then, because I'm certainly not seeing any in IE7. And the code area requires me to scroll quite a ways in the browser window, so it couldn't be font size. – mmyers Jan 26 '10 at 18:29
I can confirm that the scroll bars exist in Firefox 3.5.x, and Google Chrome 3.0.195.something, and do not exist in IE7. – Adam Davis Jan 26 '10 at 19:08
Wow, pre scrollbars are actually relatively complex: – Adam Davis Jan 26 '10 at 19:14
Hmm, interesting question here:…. – mmyers Jan 26 '10 at 19:19
Ah, here's the Jeff Atwood post about it:… – Adam Davis Jan 26 '10 at 19:26
That looks IE8-specific, though. And that "none\9" hack is in the current CSS. – mmyers Jan 26 '10 at 21:36
Yep. Sounds like ie6 and ie7 are just thrown by the wayside like so much garbage, and the only hack is for ie8. On corporate desktops, one is often stuck with ie7 or (heaven forbid!) ie6. – Adam Davis Jan 26 '10 at 21:56