Feature request: Code copy button on Markdown code snippets

This is a minor quality-of-life thing but it would be nice to be able to instantly copy the contents of code blocks. It makes documentation a bit easier to use.

For example:

59 Likes

Hi @yarian,

Thanks for this feedback; great idea! We’re always working to improve GitHub and the GitHub Community Forum, and we consider every suggestion we receive. I’ve logged your feature request in our internal feature request list. Though I can’t guarantee anything or share a timeline for this, I can tell you that it’s been shared with the appropriate teams for consideration.

Cheers!

11 Likes

I second this request.  I use the wiki to store bits of helpful troubleshooting code and what not and being able to click a button to copy it vs the mouse would be extremely handy.

9 Likes

I’d like to copy that!
https://github.com/styled-components/styled-components#badge

3 Likes

I’d like to have it too.

Definitely a much needed and easy to implement feature for Github! :grinning:

+1. Our users are requesting this as we have a lot of ‘code snippets’

+1. I’d also like to see this feature being implemented

+1 Would be a subtle but significant QoL improvement for github enthusiasts

I’d like to have it too.

+1
Would be really helpful for the community

2 years on, is this anywhere on the horizon? Thanks!

+1
This would be a great addition

1 Like

So my vote regarding this feature would be something like this:

yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes
 please please please please please please please please please please 
   ---------------- feels like a missing feature tbh ---------------
 please please please please please please please please please please 
yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes

sql sith is begging

+1, would make getting code from wiki’s much easier.

GitHub now supports this feature: https://twitter.com/natfriedman/status/1391862005095485440

How to use it? any docs available?

The docs seems not to be available yet. But all you need to do is just writing a Markdown document with a code block GitHub automatically adds a copy button to each code block.

I created a simple test repository: GitHub - shuuji3/github-markdown-copy-button-test: https://github.community/t/feature-request-code-copy-button-on-markdown-code-snippets/711/14 This feacure is enabled not only README.md but every Markdown documents.

Thanks, I just checked it was automatically added to my repositories and it works fine.

1 Like