You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add option to duplicate individual files in sketch #4314
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.
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.
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)?
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
Activity
doradocodes commentedon Sep 21, 2026
@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.
clairep94 commentedon Sep 30, 2026
I like this! Would we just add a
-{${n}}suffix?eg. copying
sketch.js--> makessketch-(1).jseg. copying
sketch-(1).js--> makessketch-(2).jsprithq commentedon Sep 30, 2026
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)?
clairep94 commentedon Oct 2, 2026
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