89

Can we please, finally, have a Select All / Copy All button for code on Stack Overflow?

Yes, this question, again.

Shortcut or button for copying posted code from Stack Overflow

The main reason I am asking this again is because this feature request has been ignored (not denied that I am aware of, but then I'm not sure how obvious it would be that it was denied) for years. There is literally a comment from three years ago complaining about how this feature request had already existed for two years.

Meanwhile, with tablets and smartphones saturating third-world countries in which access to computers is scarce and Internet connectivity was practically non-existent five years ago (see: Burma) it is more important than ever from a usability standpoint. I personally save snippets relevant to a problem I'm looking to solve while on a smartphone, and a select all or copy code button would be very helpful.

Pros:

  • Even on the computer selecting a single line that extends beyond the right border can be an exercise in frustration.
  • Selecting large amounts of code is cumbersome.
  • Selecting anything on a tablet/phone is cumbersome.
  • It is all-around faster for everyone planning on pasting into an IDE or etc.
  • It is faster for people trying to help a newer user by creating a jsfiddle, which typically requires the copying of 3 different large blocks of code.
  • It is more accurate for pasting anywhere. I have often accidentally copied other things or just missed a semicolon, etc.

Cons:

  • It normally only takes a few seconds and a few more steps, never mind the caveats mentioned above or tablets/phones.
  • People are lazy and we should fight against laziness. And air conditioning, and credit.
  • This would encourage people to copy-paste code from one answer into another, because even though a one-hit button would only save three or four steps and nobody should sweat the few seconds it normally takes, those few seconds will somehow deter someone from copy-pasting and cause them to write out their own answer for like 10 minutes.
9
  • 11
    Here is a thought: add a Copy Code button to Questions but not to Answers.
    – Jongware
    Commented May 19, 2014 at 22:12
  • 1
    Should be able to hold down the shift key and use arrow keys to select more text after you have started a selection with your mouse.
    – Joe W
    Commented May 19, 2014 at 22:17
  • 6
    Is this ever going to be implemented? Commented Jan 19, 2016 at 15:48
  • @adolfgarlic Nobody knows. I'm as frustrated about it as you but not much we can do here, short of taking the CC licensed content and doing it ourselves. Commented Mar 29, 2016 at 10:52
  • 9
    github.com/MrMino/StackOverflowCtrlC <- Let me just leave this right here. Commented Apr 11, 2016 at 3:07
  • 2
    @BłażejMichalik wish I had the +100 button ;)
    – amonk
    Commented Jun 22, 2017 at 9:00
  • 1
    The best illustration of why there is a need for this can be found in this video: youtube.com/watch?v=U6SfRPwTKqo Commented Jul 27, 2018 at 16:20
  • 4
    It is virtually impossible for me to select code from SO on my laptop with no external mouse/scrollwheel. Makes no sense to me on a site about programming. Commented Jun 20, 2020 at 13:16
  • 2
    Useful userscript
    – Spectric
    Commented Mar 9, 2021 at 1:56

4 Answers 4

44

Feb-2019: From the comments above: try https://github.com/MrMino/StackCtrlC, it works!


The original question Shortcut or button for copying posted code from Stack Overflow found quite a lot of agreement and all the top 10 answers are positive.

The question should therefore be rather why it wasn't implemented since 2009 when the feature was requested? I doubt it's the complexity of implementation. Maybe it just went off the radar and then this reminder is very valuable.

I found this question because I wondered about the same (needing three times to select a code block with scrollbars and not copying too little or too much).

I agree with the Pros in the question but I see also that some people would not care. I don't think they are a majority but it's like preferring full fledged IDEs or text editors. The more choice the better. So if there is concern that it might annoy those who don't need it make it optional when it is a button or make it just a shortcut but put it in the development pipeline.

In the case of a shortcut just do it. I would be thankful.

5
  • 2
    I completely agree. It would be very convenient. I was in fact just about to post the same question. What type of implementation could this feature have by the way? Commented Sep 25, 2015 at 10:26
  • 1
    @JasonStack Good question. Copying to the clipboard is a bit of a problem. and might not be supported everywhere, but selecting the current code box (so you just have to hit ctrl.+c) should be straightforward to implement. I think I even saw this feature already on other websites. Commented Sep 25, 2015 at 12:17
  • 2
    I've had the same question, but the quickest way to solve this would have been a chrome extension. I found a nice one here by rainsoft.io. It adds the functionality until StackOverflow does.
    – Chris - Jr
    Commented Apr 20, 2017 at 13:25
  • @Chris-Jr: That link (chrome.google.com/webstore/detail/clipboardy/…) gives a 404 Commented Dec 22, 2021 at 2:29
  • 1
    A Chrome extension: Stack Overflow Copy Code
    – user4351667
    Commented Jan 25, 2022 at 6:40
3

As a workaround until such a feature is added to the sites, there is a userscript by Ghost over at the sister site Stack Apps which adds the ability to copy code from code blocks. You can find it here: Copy Code Exchange - copy code to clipboard from Stack Exchange sites!

1
  • 1
    Pity phone browsers generally don't support user scripts...
    – PM 2Ring
    Commented Feb 29 at 4:20
0

This answer says copy-to-clipboard "simply will not be implemented due to security concerns".

There is a Chrome extension and a Firefox extension in this GitHub repo (From this answer).

0

For now, use Click Copy {Code}. It's a Chrome extension that simplifies your workflow by copying the content of code blocks on any website with a double-click. Check out the project's source on GitHub: Click-Copy-Code.

You must log in to answer this question.

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