7

Please, copy-cat Github's easy "Copy to Clipboard!" for code-snippets in questions and answers. Copying code snippets, like long code, is tremendously hard. Format corruptions and inaccurate copying between SO and an editor are highly irritating. I am not encouraging you to stealing, but remixing for the sake of usability.

Arguments for

  1. easier on devices such as iPhone, PDA and laptops (not everyone has a scrolling mouse)
  2. would-be-as-unnoticed as the links: "link" or "flag".
10
  • 1
    1) Not copying something properly != data corruption. 2) Don't put reasons against as you're clearly biased to the idea, and it shows. Jul 29, 2009 at 2:29
  • Have you considered the licensing implications? SO is not place for large comprehensive code samples.
    – waffles
    Jul 29, 2009 at 2:43
  • @Sam: How is your point related to the suggested feature? Are you implying such a small change would result in "large comprehensive code samples"? Far fetched. This is an usability issue, not law issue. New decives require more innovative UIs. It is a fact, and I hope you could look out how many already people own such devices. The improvement would prepare for the future, not for the past.
    – user131971
    Jul 29, 2009 at 2:50
  • Wait... people are copying long blocks of code around on the iPhone now?
    – Shog9
    Jul 29, 2009 at 3:32
  • 6
    @Shog9: Obviously. I wrote a c++ complier for jailbroken iPhones and now I do my application development solely on the 4" touch screen. Coding has never been more fun! Jul 29, 2009 at 3:44
  • If your snippet is long enough to want this feature just chuck it here: gist.github.com
    – waffles
    Jul 29, 2009 at 4:03
  • @Shog9: @Ian: Your humour nicely softens the important topic, Jeff was stressing. Big code samples could also be a problem there. However, please do not mix it with the suggested-feature, it is totally unrelated thing. I may sense Jeff's dilemma here, he does not want artifical obstacles to restrict the legth of snippets. Then again, such decision may endanger the usability of some platforms. How big development challenge would it be to add a Google-green bottle thing to SO? Is SO designed for such extensions?
    – user131971
    Jul 29, 2009 at 5:22
  • In all seriousness, this is a perfect use for something like Greasemonkey.
    – Shog9
    Jul 29, 2009 at 6:15
  • 2
    @Ian - let me guess. You're on a boat, too? Apr 8, 2010 at 14:36
  • 1
    Boat programming? who does that??
    – snicker
    Apr 8, 2010 at 16:19

3 Answers 3

8

The main issue is this: if you're placing LONG code samples on Stack Overflow, you're doing it wrong!

Github is a site for sharing code, that's all it does. We are different.

Any features we add to encourage adding lots of code would be taking our website in an unhealthy direction.

7
  • @Jeff: Good point, but have you considered other arguments? I doubt the incentive for long code snippets because of such a slight improvement. If you really would like to restrict the length of snippets, why is there no restriction? The argument is unrelated. The real problem is usability: not everyone has red pads, scrolling pads or similar. Not everyone can cleanly copy-paste snippets. Laptops and JS-enabled mobile device require more innovative UIs. A small ball or similar is not that big change that it would encourage "LONG code samples".
    – user131971
    Jul 29, 2009 at 3:47
  • By the word "restriction", I mean restrictions on the leght of the snippets.
    – user131971
    Jul 29, 2009 at 3:49
  • Hopefully, you see the real underlying problem. My arguments are rather powerless as an outsider agaist the argument of you, the moderator. How can I know if you have falsified your proposition? I really appreciate your activity, but objectivity is Golden. I opened a related question to encourage such virtue: meta.stackexchange.com/questions/10620/….
    – user131971
    Jul 29, 2009 at 4:00
  • @Jeff: Getting things (text, code, links, images etc) in and out of SO is the most annoying part of SO ATM. Though that doesn't mean SO isn't a great site. I mean what about having the source of the question available while creating/editing an answer? Jul 29, 2009 at 5:07
  • 4
    we are the twitter of code sharing sites. Keep it short, keep it concise, keep it simple -- and link to outside resources for additional detail. Jul 29, 2009 at 6:22
  • 7
    "twitter of code sharing sites"... Useless by itself, but ironically self-absorbed?
    – Shog9
    Jul 29, 2009 at 6:52
  • 4
    Shog9 has won this thread.
    – TheTXI
    Jul 29, 2009 at 11:25
2

If you take a look at the questions under C++, almost all of them contain significant code snippets. On the occasions when I try to answer these questions, my first step is to copy their code snippets and paste them into my IDE so I can work with them. For a lot of questions, it takes a substantial amount of code to get at the context of the problem.

It would be handy to have a single-click to copy it, rather than having to use (somewhat) precise mouse gestures to select them.

-2

What? Copying that block of code (assuming you were talking about the SQL in the accepted answer) is dumb as bricks. You just click at the beggining and use the scroll wheel to the end of the frame, and then you drag to the final line of it.

-1, it is not necessary at all, and a button to copy the code will distract more than its usage.

6
  • 1
    You misunderstand the word "copy-cat". I do not mean to "copy" the dummy icon. It could be links like "add to comment", "link" and "flag". As for "scroll wheels", did you know that users may have laptops or PDA devices? The scrollbars are totally unusable with them. Hope you can see a wider perspective.
    – user131971
    Jul 29, 2009 at 2:12
  • 2
    Who would be copying large blocks of code on a PDA? Secondly, you can click on the start of the code block, move the scroll bar to the very bottom, press the shift key, then click the last line. Magically, everything will be selected, on laptops too! I hope I just blew your mind. Jul 29, 2009 at 2:19
  • What if you have several code-blocks? How could you discern which block to copy if you have links like add comment? Besides, if you are in a PDA, you may not even have JavaScript to copy with buttons. If you are in a notebook, the great majority of modern (3-5 years) have scroll bars that activate upon moving the pad over the rightmost area. If you don't even have those, chances are you are not even developing in such a hard-to-use machine. Jul 29, 2009 at 2:22
  • I don't think it needs to be that complicated, a simple UI tidbits can help.
    – chakrit
    Jul 29, 2009 at 2:42
  • @Manuel: You first point is good, while others are debatable. Have you tested newer models such as iPhone? I would not count much for a manufacturer. Not many modern mobile devices, or even desktops or laptops, have red pads. As for the argument of obscurity, Jeff can surely do unnoticed copying; a tiny ball or something like that would be sufficient. I am sorry, but new devices require more creative innovations. Perhaps, it is a trade-off, but I would give a try. Experimental SO?
    – user131971
    Jul 29, 2009 at 2:42
  • It's very important. -1 for your 'answer'. Nov 22, 2009 at 12:59

You must log in to answer this question.