What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 130 Stack Exchange communities.

Possible Duplicate:
Shortcut for copying posted code from Stack Overflow

Why isn't there a copy code option in the code samples block?

I would like to see a copy link over the code block (in posted questions) that helps us to copy the code to the clip board and paste it directly to the IDE.

share|improve this question

marked as duplicate by Grace Note, ChrisF, Ladybug Killer, Gelatin, Jon Seigel Oct 12 '10 at 17:32

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.

    
Welcome to MSO, @Homam! I don't quite understand what you're asking for; what would a "Copy code option" do? –  Pops Oct 12 '10 at 13:47
    
@Popular Demand: sorry, I edited it. –  user152128 Oct 12 '10 at 13:48
    
@Homam, no worries, thanks, I get it now. –  Pops Oct 12 '10 at 13:49
    
This request is basically a variant phrasing of Shortcut for copying posted code from Stack Overflow. Which was never declined, so I suggest you vote it up if you want to support any kind of implementation of this feature. –  Grace Note Oct 12 '10 at 13:57
    
@Grace Note: I'll do that as soon as I can –  user152128 Oct 12 '10 at 14:05
    
I thought the only reason why you'd need a button like that is that if you're using something like syntaxhighlighter.js v2, then there's no easy way to select the original code without selecting all the extra markup that comes with it. –  Yi Jiang Oct 12 '10 at 15:38
    
@YiJiang, for the sake of completeness, this is possible by clicking on the revisions link, then viewing the source, then manually copy/pasting... but you're totally right, there is no easy way. –  Pops Oct 12 '10 at 16:59

1 Answer 1

Posting entire programs on SO is discouraged. Unless the program is extremely small/simple, putting the whole thing up takes up a lot of space and makes it hard for other users to track down where the issues actually are. Anecdotally, large code posts tend to indicate a lack of effort or outright apathy on the part of the OP.

Without whole programs/large batches of code being posted, I don't see much value in a "copy code" button. You wouldn't be able to run anything, anyways. In the rare case where you want to, say, check the syntax of a short snippet, and the SO code highlighter isn't doing a good enough job, you can still manually copy/paste into your IDE fairly easily.

share|improve this answer
    
+1 for beating me by a full minute :P –  Diago Oct 12 '10 at 13:57
    
@Diago, would I have gotten +0.5 if I had beaten you by only 30 seconds? (Don't lie, I know you mods can do that if you want.) –  Pops Oct 12 '10 at 14:10
    
@Pop I was contemplating it. But your a good person. You need the boost. –  Diago Oct 12 '10 at 14:13
3  
"Posting entire programs on SO is discouraged." Sure, but posting runnable examples is encouraged. –  sepp2k Oct 12 '10 at 16:34
    
@sepp2k, I admit I don't spend enough time on SO, but I can't think of a time when I've seen a useful runnable example. –  Pops Oct 12 '10 at 16:57
1  
@Popular: They're useful in that they require the problematic code to actually be in the snippet the asker included in the question. If you create a runnable code sample which exhibits the error, you know the question contains the information needed to find the error. If you just post the snippet that you think causes the problem, you might be wrong and the question becomes unanswerable. You can't test that the code in the snippet causes the problem, because the snippet isn't runnable. –  sepp2k Oct 12 '10 at 17:43
1  
Also they make it easier for the answerer to test his solution before posting it. He can just copy the sample, apply the suspected fix and then run it to see that the problem is in fact gone. –  sepp2k Oct 12 '10 at 17:44
    
@sepp2k, I'm not arguing about whether runnable samples could be useful; I agree with you that they can be. I'm saying that I've never seen anyone post one, that I can remember. –  Pops Oct 12 '10 at 17:49
    
The answer is not for the question at all. OP asked for copying a code from SO and pasting it into IDE, and not other way round. –  Stan Dec 24 '12 at 8:47