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

This question already has an answer here:

Many a time and oft there is a real need for long sequences of code, especially stack traces or error logs. This also happens in other SE sites, TEX being a good example. Unfortunately, these long code blocks can reduce the readability of the question, and let important non-code text ignored.

Do you think that adding a show\hide (or collapse\expand) button would be a good idea?

Addendum

My first idea was to have only a collapse\expand button, but reading the comments and other questions made me think that other functionality could be added:

  1. Expand\Collapse
  2. Copy to clipboard
  3. Open in a new window
  4. Toggle line numbers on and off - simplifies referring to a specific line in an answer.

Syntax Highlighter evolved might be a good example.

UPDATE:

This is really annoying in Server Fault questions with long logs or configuration files. The question itself virtually undetectable between all the long code snippets.

share|improve this question

marked as duplicate by Shadow Wizard feature-request Dec 24 '15 at 7:31

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.

1  
Besides the vertically scrolling problem there is also the horizontally scrolling problem. I don't like horizontal scrollbars. It would be great to be able to open large scripts in a separate windows or tabs or scripted windows. – Stefan Steinegger Mar 2 '11 at 9:21
    
@Stefan, for new windows see View code in new window. – Arjan Mar 2 '11 at 9:40
2  
1  
It's not only for code. I can remember of a few times where I wished there was a way to collapse some of the stuff that I was going to write (usually images and graphs, but not only). – Borror0 Mar 2 '11 at 10:00
1  
@Borror0, true. (Another example: responses from command line commands might not be too interesting for most readers.) Maybe this could be solved by using the "spoiler" formatting, if that would not occupy the full height in its hidden state? And then also allows for permanently triggering the visible state (maybe related to Can we have the spoiler text show on click too?). – Arjan Mar 2 '11 at 10:10
    
Isn't that specific example too localised for a Q&A site such as Server Fault? – Arjan Mar 28 '11 at 12:30

Here is the greasemonkey script that can only expand/collapse code blocks

Install - Source - (only tested on firefox 3.6 and chrome 11 dev)


Screen shots 1

enter image description here

to

enter image description here


Screen shots 2

enter image description here

to

enter image description here


share|improve this answer
    
+1 Truly great hack. – Adam Matan Mar 6 '11 at 16:40

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