52

Is it possible to ignore/exclude file/folder from .editorconfig?

Reason: I have a /vendor folder with third party files. I don't want the folder to inherit any of my .editorconfig configs.

I found the EditorConfig-Properties page and seems like there's no property to exclude folders. Maybe there's a hack to make it possible?

current config

root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab
iDev247
  • 1,761
  • 3
  • 16
  • 36
  • 1
    I'm thinking maybe I could just tighten up the rules. Instead of a catch-all `[*]` I could specify with folders to include instead of trying to exclude folders. Is there a way to do a only-in-root rule? – iDev247 May 18 '15 at 18:35

5 Answers5

54

Another solution to ignore /vendor folder:

  • match the path you want to ignore
  • set unset to property you want to ignore

For example, if you have:

  • /index.html
  • /vendor
  • /.editorconfig

You can match all files in the vendor directory in your .editorconfig and ignore all properties (set to IDE's default):

# top-most EditorConfig file
root = true

# Ignore paths
[/vendor/**]
charset = unset
end_of_line = unset
insert_final_newline = unset
trim_trailing_whitespace = unset
indent_style = unset
indent_size = unset
Mike
  • 14,010
  • 29
  • 101
  • 161
Danail
  • 1,997
  • 18
  • 21
  • 2
    I think this is a much better solution as it keeps all the editorconfig in one place. – Rob Young Dec 16 '16 at 09:00
  • 2
    The "official" way is to set them to `unset`. The editorconfig plugin for VS Code also suggests it as part of its Intellisense. Any invalid value will work though. – Mario Tacke Oct 08 '18 at 22:12
  • for my .jinjalintconfig.py file, if i use unset, ignore, or ignore, I get NameError: name '' is not defined – Akin Hwan Mar 06 '20 at 21:14
  • 1
    This answer should be updated to use the now documented value of `unset`. Otherwise this answer is 100% on point. – David Baucum Jun 02 '20 at 15:27
16

You can create an .editorconfig file in vender/ with a simple root = true line.

xuhdev
  • 8,018
  • 2
  • 41
  • 69
12

In IntelliJ there is a WONDERFUL feature that arrived just a month ago:

ij_formatter_enabled = true/false

Just match a pattern or a file type in your .editorconfig and matched resources are ignored:

[{**/*.sql,**/*.properties,**/File.kt}]
ij_formatter_enabled = false

Thank you JetBrains!

fast-reflexes
  • 4,891
  • 4
  • 31
  • 44
6

Best way I've found is to add this to an otherwise blank .editorconfig in the folder you want to ignore:

[*]
generated_code = true
kzu
  • 1,795
  • 15
  • 16
4

Combining others' answers in this thread to create the following solution to simply turn off the .editorconfig wholesale for the files within a folder, while still keeping it in the base .editorconfig file. Note: this is new as of VS 2019 16.5, according to Microsoft docs (https://learn.microsoft.com/en-us/visualstudio/code-quality/use-roslyn-analyzers?view=vs-2022).

# top-most EditorConfig file
root = true

# Ignore paths
[*/Migrations/*]
generated_code = true
kcanders
  • 101
  • 1
  • 3