Skip to content

Add "Copy to Clipboard" Button for Code Blocks in Repository Code Viewer #7

@steuerlexi

Description

@steuerlexi

Feature Request
I’d like to propose adding a "Copy to Clipboard" button next to code blocks in the GitHub repository code viewer (e.g., when browsing source files). This would allow users to quickly copy the entire contents of a file or a selected code block with a single click, improving workflow efficiency.

Proposed Solution
Add a small "Copy" button (e.g., a clipboard icon) in the top-right corner of the code viewer UI, similar to how many documentation sites (e.g., Stack Overflow) or note-taking apps (e.g., TriliumNext) implement it.
When clicked, it copies the entire file’s contents to the clipboard.
Bonus: If a user has selected a portion of the code, clicking the button could copy only the selected text instead of the whole file (context-aware copying).

Benefits
Efficiency: Saves time for developers who frequently copy code snippets for testing, documentation, or sharing.
User Experience: Aligns GitHub with modern UX patterns seen in other coding tools.
Accessibility: Reduces reliance on keyboard shortcuts, benefiting users who prefer mouse-based workflows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions