Skip to content

Add option to duplicate individual files in sketch #4314

Open

Description

@prithq

Increasing Access

When working on a project user might want to duplicate the individual files for some various purposes rather than creating a new file and copy pasting the content.

basically allowing users to duplicate individual files can reduce multiple unnecessary steps and this will improve the user experience

Feature request details

currently the p5.js-web-editor has duplicate functionality but it is for the entire sketch not for individual files.

for example, if sketch has

  • hello.js
  • index.html
  • sketch.js
  • style.css

then if the user wants to duplicate hello.js then when he right clicks on it the user should be able to see

  • rename
  • duplicate
  • delete

I have attached an image showing the current file menu for reference.

Image

when the user clicks duplicate the another copy of the file should be there , so the overall sketch will look like

  • hello.js
  • hello-1.js
  • index.html
  • sketch.js
  • style.css

Proposed behavior

  • Add a Duplicate option to the individual file menu.
  • Create the duplicate in the same folder as the original file.
  • Preserve the original file's contents.
  • Generate a unique filename.
  • Select the newly duplicated file.
  • Mark the sketch as having unsaved changes.
  • Respect the existing file/project permissions.

I would be interested in working on this if the maintainers think this feature fits the Web Editor and approve the proposal.

Activity

  1. doradocodes commented on Sep 21, 2026

    @doradocodes
    Collaborator

    @prithq Thanks for your input! I also think that would be a useful option to have. CC'ing @clairep94 @khanniie for their input as well.

  2. clairep94 commented on Sep 30, 2026

    @clairep94
    Collaborator

    I like this! Would we just add a -{${n}} suffix?
    eg. copying sketch.js --> makes sketch-(1).js
    eg. copying sketch-(1).js --> makes sketch-(2).js

  3. prithq commented on Sep 30, 2026

    @prithq
    Author

    Sounds good! I think using the -(n) suffix would work as well. So copying sketch.js would create sketch-(1).js, and copying that file again would create sketch-(2).js.

    one small question @clairep94 , before I start is for gaps such as sketch.js, sketch-(1).js, sketch-(3).js, should duplication use the first available number which here is (sketch-(2).js) or always increment from the highest existing suffix which here would be (sketch-(3).js)?

  4. clairep94 commented on Oct 2, 2026

    @clairep94
    Collaborator

    Up to you on the design! Perhaps write out the edgecases in your unit test and pick the solution that is simplest
    The end result is that we want no collision

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Feature RequestProposal for adding a new functionality

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions