Skip to content

Add multiple file creation with curly brackets pattern #162893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kuroidoruido
Copy link

Sometimes we need to create some files with little variations (same filename but with different extensions, same file in different directory, etc.). So I add the ability to specify these variation with curly brackets (like it can be done in bash for example).

Examples:

  • typing foo.{ts,css,spec.ts} will create files: foo.ts, foo.css and foo.spec.ts
  • typing {foo,bar}/foo.ts will create files: foo/foo.ts and bar/foo.ts
  • typing {foo,bar}/foo.{ts,css,spec.ts} will create files: foo/foo.ts,foo/foo.css,foo/foo.spec.ts,bar/foo.ts,bar/foo.css and bar/foo.spec.ts

To test this, you can create a new file and type a file name with a pattern like one of the examples above
vscode-multi-file

@kuroidoruido
Copy link
Author

@microsoft-github-policy-service agree

1 similar comment
@kuroidoruido
Copy link
Author

@microsoft-github-policy-service agree

@kuroidoruido
Copy link
Author

@microsoft-github-policy-service agree

@kuroidoruido
Copy link
Author

@microsoft-github-policy-service agree

@kuroidoruido kuroidoruido force-pushed the feat-multi-file-creation branch from 0bd36cd to 47ca60b Compare October 6, 2022 22:01
@lramos15
Copy link
Member

lramos15 commented Oct 7, 2022

This is very neat! Sorry about the angry bot. It makes me wonder if the logic should be expanded even further to support some of the filename expansion like in https://www.npmjs.com/package/brace-expansion

@lramos15 lramos15 added the under-discussion Issue is under discussion for relevance, priority, approach label Oct 13, 2022
@ArturoDent
Copy link

Would these associated changes be available for extension authors? There are lots of extensions that create multiple-file templates for different situations.

@lramos15
Copy link
Member

Would these associated changes be available for extension authors? There are lots of extensions that create multiple-file templates for different situations.

I think the answer to that at least in the near future is no. We are not even sure if we should take this in or leave it up to an extension. An extension can currently do this using the vscode filesystem APIs. The main reason it is being considered is because right now is that if you make a file test/foo.js it will create the folder and the file so we already have a little bit of power user file creation in the product.

@miguelsolorio
Copy link
Contributor

Just to add some comments to the discussion, I do think it would be worth starting with very basic use cases since this is still considered a "niche" feature (similar to creating files in new folders i.e. foo/bar.js). So going with something like foo.{ts,css,spec.ts} or foo.ts,bar.css,spec.ts seems like a good starting point.

I'd avoid getting too complex in supporting every expansion known as the cost might outweigh the benefit.

@vivodi
Copy link

vivodi commented Dec 29, 2024

Is this still relevant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants