Is there a way for a reader (not the OP) to expand a scrollable window containing source code in a question? I sometimes have difficulty understanding a block of code because I can't see it all at once. I find myself having to continually scroll the code up and down within the window. It would be nice to be able to request that the code in all of its entirety be displayed in the question.

  • 1
    Yeah! And add a split pane while you are at it, just like Visual Studio does.
    – Oded
    Oct 28, 2012 at 20:28
  • 1
    @Oded - StackIDE... sounds like the name of the next User script or Chrome extension!
    – jmort253
    Oct 28, 2012 at 20:30
  • Nice suggestion, for reference here is a question with lots of code. Oct 28, 2012 at 21:24
  • I'm serious about a StackApp. User scripts can embed a button or mouseover event that would then expand the size of the code box. I don't think it would take that long to do if you wanted to give it a shot. ;) Chris, do you have a screenshot of what you have in mind?
    – jmort253
    Oct 28, 2012 at 21:36
  • @jmort253: No, no screenshot. What I've seen here in the responses is mostly what I had in mind. I'm not familiar with the SO implementation, so I'm trying to keep to the requirement and keep away from any suggested implementation. Oct 28, 2012 at 23:03
  • @ShaWizDowArd, half of that "code" is unnecessary whitespace though... Oct 29, 2012 at 15:06
  • @Ben still, it doesn't matter; a good example for what's being asked here. :-) Oct 29, 2012 at 15:10
  • @ShaWizDowArd: Agreed. Another good example is almost any question on mapreduce problems where the PO has to show source for three or four classes. Oct 29, 2012 at 15:24

3 Answers 3


I wrote a greasemonkey/chrome user script about a year ago that does this. It's up on stackapps if you're interested.

From the link, its features are:

  • Click the code region to have it expand to whatever size it needs
  • Removes vertical scroll altogether (expands to full height)
    • Intelligently expands horizontally
      • Maxes out at window width so as not to make even more scroll bars
      • If it still doesn't fit, it shrinks the font size
  • Click again to return it to normal

I really like this feature request. It focuses purely on making it easier for answerers to focus on looking at a problem and then creating great content. Here is a screenshot of one of the prettyprint windows expanded with some CSS manipulations:

Large code screen

Run this in the console to manipulate the window. This could either launch as a popup, which makes it easy to alt-tab back and forth, or just remain embedded in the page:

$('.default.prettyprint.prettyprinted').css("border","thin solid black");

Of course, there is a downside to this: It may encourage more help vampires to post their entire project. We do know that Q&A tends to work best when it's represented in bite-sized, broken down components that focus on a single problem.


Ok, this question has been around a while! But it is exactly what I was going to ask about. And I have a possible solution. When you are on a web site which includes photos, you can often click the photo and it opens up in a "modal" fashion to take up the entire window, and you see the photo in as large an area as the window allows. Often there will be an X in the upper right corner, and perhaps some zoom features. Pressing the Esc key often can close it. Left and Right arrows can go to the next or previous photo.

Why not do this with code blocks? Add an "expand" button next to (or above/below) the code sample. When clicked, it expands to take the entire window (full width, full height please!). Perhaps with "zoom" buttons so those younger folks can click the "zoom out" to see more at once, and the older folks can click "zoom in" if necessary when they eyes stop working like they used to. And of course you could easily scroll both directions, perhaps there would even be a "copy to clipboard" button to copy the entire sample. And for answers with multiple code blocks, the left and right arrows could bring up the previous or next code block from the question or answer.

You must log in to answer this question.

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