Jeto
Jeto

Reputation: 14927

EditorConfig: applying rules to multiple, specific folders

Let's say I have a project with the following folders:

/
  /folder1
  /folder2
  /folder3
  /folder4
  /folder5

Question

Is there a way to have my .editorconfig file at root (/) level but only apply the same rules to (all files within) folder1, folder3 and folder5 but not the other two?

What I could do (but doesn't seem ideal)

What I would like to (be able to) do

Create an .editorconfig at root level, and list the folders rules should be applied to. I didn't find a way to do something like this:

[/folder1/**]
[/folder3/**]
[/folder5/**]
end_of_line = lf
insert_final_newline = true

Invalid because you cannot combine sections like that.

Or, using the {s1,s2,s3} format:

[{/folder1/**, /folder3/**, /folder5/**}]
end_of_line = lf
insert_final_newline = true

But it doesn't seem to be valid either (only simple file name patterns seem allowed).

Is there any other way to achieve this? I didn't find anything on the docs or elsewhere, but I may have missed something obvious.

Upvotes: 15

Views: 4910

Answers (1)

Seth Falco
Seth Falco

Reputation: 630

It was introduced to EditorConfig Core 0.11.0 in 2013. The way to do it is as follows (Source):

[{package.json,.travis.yml}]
indent_style = space
indent_size = 2

I tested the following configuration in Visual Studio Code and can confirm it works.

root = true

[{packages/**,plugins/**}]
indent_size = 8

If this does not work for you, it likely depends on the implementation/client. It's best to make a feature request to support the feature.

Upvotes: 12

Related Questions