15

Stack Exchange has finally introduced a new copy button on SO (example), and we can request to have it available on other SE sites:

We can also enable this feature on other tech sites that use code blocks, let us know here if this functionality would benefit other Stack Exchange communities.

Let's request to have it on SU? Many posts have code blocks, that'd be convenient to have it.

11
  • 8
    I think this has merit. I do note that I'd rather have SO stress test it first and iron out some bugs, and chances are we're getting this anyway since we're a largeish technologist site Commented Nov 5 at 3:47
  • 4
    Tagging in to mention we're happy to turn this on if the consensus agrees with that course of action. I'll give this a week or so for you all to weigh in and, if there are no issues, I'll turn it on. Commented Nov 6 at 19:56
  • 3
    I added the [featured] tag earlier, just to ensure that the community has the greatest chance to see this discussion and weigh in. :) Commented Nov 6 at 22:58
  • 1
    @JourneymanGeek Bugs are there and they make some existing answers worse, misleading, even harmful. See my comments under the answer. Commented Nov 18 at 9:06
  • @KamilMaciorowski post a question highlighting this bug and I'll status review it Commented Nov 18 at 9:57
  • 3
    @JourneymanGeek "Please remove the language name from the header of the code block" has already been posted on Meta. The reasoning is "wrong detection" rather than "looks like code", still if this gets done exactly as requested then the problems I indicated will disappear. But for now the right thing is to turn the (mis)feature off on SU immediately and follow your wise comment: have SO stress test it first and iron out some bugs. Shall I create a new question here anyway? For the sake of red tape or what? Commented Nov 18 at 10:11
  • 1
    There is no such thing as too much documentation, so yes please create a new question Commented Nov 18 at 10:18
  • @JourneymanGeek After being gaslighted by Staff here and rebuffed here I feel less and less eager to invest/lose my time in trying to improve SE (or in participating at all). The main reason I'm in this thread is I have noticed the misfeature had worsened answers that have my name under them. I have posted three descriptive comments under the answer from the Staff member who turned the misfeature on, not enough for them to turn it off. Maybe I will rewrite the comments as a question later. Commented Nov 18 at 10:39
  • I've had worse ;). If you feel up to getting things started, I'll do my best to try to follow up. Commented Nov 18 at 10:49
  • @JourneymanGeek Your try to cheer me up kinda failed: knowing that it can be worse does not make me want to interact with the Staff, really. Oh well, we will see… Commented Nov 18 at 11:02
  • @JourneymanGeek Here. Commented Nov 18 at 22:34

1 Answer 1

6

I've turned this setting on for this site, so you should now be able to copy code blocks with the new button.

This functionality takes a dependency on syntax highlighting, which means that you will need to adjust the syntax highlighting language settings for the tags you commonly see code in in order for this button to appear. I've done this for your tag as a test and set it to lang-py, and this example question now has the Copy Code button available.

Moderators can change the language highlighting settings for your tags on their own, so I'd coordinate here on Meta regarding edge cases, and use common-sense settings everywhere else.

6
  • 2
    A fragment of this answer of mine now looks like this: i.sstatic.net/psWyvufg.png . The answer says "the line looks like this" and it used to be a line, but now the new feature makes it three lines (sigh1), where bash looks and behaves like the first line of code which is very wrong (sigh2). Additionally when I start editing the answer (to try to get rid of this misfeature) the preview does not show the extra line (sigh3). Our moderator wisely wrote "I'd rather have SO stress test it first and iron out some bugs". Oh well. Commented Nov 15 at 17:45
  • 4
    Well, it can be worse. This answer says "add this to your ~/.bashrc" and now the codeblock starts with bash which was never intended to be there. If copied manually and actually added to ~/.bashrc like the answer says, this will create an infinite loop when Bash starts, not a nice situation at all. There are more answers broken this way. Please turn the setting off until its implementation does not break code in existing otherwise good answers. Commented Nov 15 at 20:57
  • 2
    In this answer all code snippets are for zsh, still the "feature" glues bash in front of each. The last snippet certainly will not work in bash. I'm not against the copy button itself; I'm against gluing bash etc. to code so it looks like a part of the code, while it's not in the code provided by the author. And even if it stood out, so it was clear it's just "language" and not a part of the code, in this case it would be still wrong, because the code is for zsh! Again, please turn the setting off until its implementation does not worsen existing answers. Commented Nov 18 at 9:03
  • 1
    @KamilMaciorowski If you feel strongly that this should be turned off, I'd like to see evidence that there's a large enough number of users that feel the same way. Please make a new meta question and propose that the feature be disabled, and if it gets enough support, please flag and ask a moderator to tag it as status-review. I'll be on the lookout for it and turnaround will be quick. Commented Nov 18 at 15:30
  • @KamilMaciorowski I have encountered the same problems you have, albeit on SO instead of here, and have posted on Meta.SE (link). I'm considering using the lang-none label on all my code blocks from here on. Commented Nov 21 at 21:36
  • @Spevacus could be also taken as a request for improvement to the easy-copy option Commented Nov 28 at 11:15

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.