0

One of the features added in the October 2025 Community Asks sprint is a Copy Button for code blocks:

  • Copy Button on Stack Overflow - As of today, users will be able to copy blocks of code directly from posts on Stack Overflow, by clicking the new Copy button in the top right corner of the code block:

    Image of a code block on Stack Overflow with a Copy
button

    The copy will include three lines of attribution, which will be rendered as comments using the format appropriate for the language of the code block in question.

A fairly large number of posts here have:

  1. commands to be copy-pasted and run by the answers for solving various issues, or for reproducing them
  2. scripts for various tasks

Both sets would greatly benefit from having a copy button. IMHO this is especially helpful for the first case where new users in particular might make potentially dangerous mistakes while typing in commands by hand or accidentally selecting only part of a command.

(This post is identical to the one I made on Ask Ubuntu Meta as I think the circumstances are the same for both sites.)

0

1 Answer 1

0

Posting this separately as an additional feature request: I'm not too sure if this will be helpful for us:

The copy will include three lines of attribution, which will be rendered as comments using the format appropriate for the language of the code block in question.

As mentioned, a major use case for code blocks here is for commands to be run by the user, and I don't think it would be helpful for the user's command line history or the active command line prompt itself to be flooded with such comments. Imagine copying a one-line command and having four lines, three of them comments, pasted into the prompt. Doesn't feel particularly user-friendly.

So if this feature is enabled, I'd like to keep the attribution feature either:

  • disabled altogether, or
  • disabled for code blocks using shell languages (bash, sh, etc.)
  • conditionally enabled (maybe by some custom language marker - lang-sh attribution-enabled or something like that)

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.