The guide
A Style File Is a Search Path of Globs, and It Only Counts When the Bytes Agree
How .editorconfig files are found and read, why the closer and later rule wins, where the slash rule surprises people, and what indentation, line breaks and charsets look like at the byte level.
- 0.17.2 the specification version this page follows
- 1,024 characters of section name every core must accept
- EF BB BF the three bytes of a UTF-8 byte order mark
- 0D 0A the two bytes of a CRLF line break
Read the full guide Fold the guide
A team agrees on tabs or spaces once, writes it down, and then forgets that the decision lives in a small text file nobody reads. That file is an .editorconfig, an open file format with a written specification. It does not format anything by itself. It is a list of patterns and settings that an editor plugin reads when a file opens, and its whole value depends on two questions: which of its rules apply to a given file, and whether the files on disk actually obey them.
Both questions have exact answers. Version 0.17.2 of the EditorConfig specification defines the parsing, the path matching, and which value wins when rules collide. The answers are rarely the ones people guess.
A search path, read from the top down
When a file is opened, the search starts in that file’s own folder and walks upward, looking in each parent for a file named .editorconfig in lowercase. The specification treats folders that do not exist as if they existed and were empty. The walk ends at the filesystem root, or earlier at the first file whose preamble, the lines before any section, sets root = true.
What happens next is the part that trips people up. The files found are not read closest first. Every matching section contributes its pairs, and the most recent pair read wins. Inside one file a later section beats an earlier one. Across files, pairs from the closer file are read last, so the closer file wins. The project website puts it plainly: properties from matching sections are applied in the order they were read.
Two small words do a lot of work. A value of unset removes the effect of a pair even if a farther file set it, so the editor falls back to its own default. And root only counts in the preamble; written inside a section it is just another pair.
Here is a worked example you can reproduce on this page, since it is the example that loads first. A fictional project has three files. The top one sets root = true, charset = utf-8, end_of_line = lf and trailing whitespace trimming for common source files. The src folder adds a section named legacy/** that sets end_of_line = crlf and trim_trailing_whitespace = unset. The src/legacy folder has a section [*.c] with indent_style = tab and tab_width = 8. For the path src/legacy/parser.c, three files are read, nine sections are tested, and three match.
The result is seven keys. The line ending is crlf, because the src file is read after the top file. Trimming is unset, so it has no effect. Indentation is tab, and indent_size comes out as 8, a value nobody typed: with indent_style = tab and no indent_size, the core tests expect indent_size = tab, and the specification then gives indent_size = tab the value of tab_width. Checking the file itself finds two problems on line 4: eight spaces where a tab fits, and an LF line break inside a CRLF file.
The slash rule and other glob surprises
Section names are globs, a pattern language that goes back to the earliest Bell Labs versions of Unix, where a separate program called /etc/glob expanded wildcards for the shell. EditorConfig keeps the familiar pieces. A star matches any run of characters except a slash. A double star matches across slashes. A question mark matches one character, again not a slash.
The surprise is where a pattern is anchored. If a section name contains a slash anywhere outside square brackets, it is matched from the folder of the .editorconfig that holds it. If it contains no slash, it may match at any depth below. So .c matches src/deep/a.c, while subdir/.c matches only files directly inside subdir. A leading slash then changes nothing, which is why /subdir/.c and subdir/.c must behave the same. A corollary follows. A section name ending in a slash matches nothing, because no file path ends that way.
Brackets and braces have their own fine print. Inside [seq] characters are taken literally, so [ab*c] means one of four characters. Braces list alternatives that may nest, as in {a,{b,c}}, but a single item in braces, such as {single}, matches the braces themselves. The form {num1..num2} matches whole numbers between the two bounds. The core tests add details the prose leaves open: 060 does not match {3..120}, and a name whose braces are unbalanced matches every brace literally.
Comments are another trap. The file looks like an INI file, an informal format with many dialects, and some of those dialects let a comment follow a pair on the same line. The specification ruled that out in version 0.15.0. Only a line that begins with a semicolon or a hash is a comment, so foo = editorconfig ;) sets foo to the whole string, smiley included.
Even the project’s own overview page words some of this more loosely than the specification does. It describes the question mark as matching any single character, while the specification adds that it never matches a slash. When two documents differ, the specification and its conformance suite decide. The specification says a conforming core must pass the tests in the core test repository, a collection of small configuration files, paths and the output each path must produce. It is the most useful single document for settling a glob argument.
There are limits worth knowing as well. Cores must accept section names of at least 1,024 characters, keys of 1,024 and values of 4,096; beyond that, each implementation may set its own ceiling. A pattern that looks harmless can also be expensive for a naive matcher, which is why this page matches globs with a small state machine instead of building a regular expression from what you type.
Indentation is three settings, not one
Indentation arguments are old, and one long-standing style assumes tab stops every eight columns. EditorConfig splits the question into three keys. indent_style says which character to use. indent_size says how many columns one level of indentation spans. tab_width says how many columns a tab character represents, and it defaults to indent_size.
The specification explains the tab style with a careful example. With indent_style = tab, indent_size = 4 and tab_width = 3, one level of indentation cannot be made of tabs alone, so it is one tab followed by one space. The rule is as many hard tabs as possible, with the rest filled by spaces. With indent_size = 8 and tab_width = 4, spaces are never needed. With indent_size = 4 and tab_width = 8, the first level is four spaces and the second level is one tab.
That rule makes a checker possible. Under the tab style, leading whitespace that is a run of tabs followed by fewer spaces than one tab width is correct. A space before a tab is wrong, and so is a run of spaces as wide as a tab. Without a tab width, only the first of those can be judged, and an honest checker says so instead of guessing.
What the bytes actually say
Line endings are a fossil from the teleprinter. Printing terminals needed a carriage return to move the print head back and a line feed to advance the paper, so many early systems stored both, CR then LF, bytes 0D 0A. Multics chose a single LF and translated it in a device driver, and Unix-like systems kept that choice. Classic Mac OS used a lone CR. A file can hold all three, and a checker has to count each kind separately. A CRLF that straddles two slices of a large file must still be read as one break.
Character sets hide in the first bytes. The byte order mark is the code point U+FEFF encoded at the start of a file. In UTF-16 it tells big-endian FE FF from little-endian FF FE. In UTF-8 it is the three bytes EF BB BF, and the Unicode Standard permits it there but neither requires nor recommends it, which matches the specification calling utf-8-bom discouraged.
UTF-8 itself uses one to four bytes per code point. Since RFC 3629 its encoded surrogates are invalid, and overlong forms, which spell a code point with more bytes than needed, are treated as errors. ISO/IEC 8859-1, known as Latin-1, dates from 1987, encodes 191 characters and lines up with the first 256 Unicode code points, so a checker has little to reject in it beyond a stray byte order mark.
The last two rules sit at the very end of lines and files. trim_trailing_whitespace means no spaces or tabs, U+0020 and U+0009, just before a line break. insert_final_newline = true means the file ends with a break, and the specification adds that an empty file needs none.
Why a style file needs a check
A style file states intent. Editors apply it when a file is saved, if a plugin is installed and if that plugin supports the key; the specification tells plugins to ignore keys and values they do not recognise. Files written before the rule existed, generated by tools, or pasted from elsewhere keep whatever bytes they had. Only a byte-level read tells you whether the promise holds.
This page reads files on your device. A folder chosen through a directory picker arrives as a list of files with paths relative to it, invalid UTF-8 is counted the way the browser’s TextDecoder would replace it, and the heavy reading runs in a web worker so the page stays responsive. Nothing is uploaded, and fixed copies are offered as downloads rather than written back.
It cannot tell you what a particular editor will do. It follows the specification and the core tests, not any plugin. Keys outside the specification, such as max_line_length, are reported as found and checked only when you switch that on. Wide characters count as one column. A file with a zero byte in its first 8,000 bytes is treated as binary and skipped, a practical rule rather than a standard one. Within those limits the answers are exact, and so is the list of lines that disagree with them.
Sources
Every source consulted for this guide. Links checked October 30, 2026.
- EditorConfig Specification EditorConfig Team, version 0.17.2
- editorconfig/specification: Specification of EditorConfig file format editorconfig/specification on GitHub (BSD-2-Clause)
- editorconfig/editorconfig-core-test: Testings for EditorConfig Core editorconfig/editorconfig-core-test on GitHub (BSD-2-Clause)
- EditorConfig EditorConfig project website (CC BY 3.0)
- EditorConfig - Wikipedia Wikipedia (CC BY-SA)
- glob (programming) Wikipedia (CC BY-SA)
- INI file - Wikipedia Wikipedia (CC BY-SA)
- Newline - Wikipedia Wikipedia (CC BY-SA)
- Byte order mark - Wikipedia Wikipedia (CC BY-SA)
- UTF-8 - Wikipedia Wikipedia (CC BY-SA)
- ISO/IEC 8859-1 Wikipedia (CC BY-SA)
- Indentation style Wikipedia (CC BY-SA)
- Whitespace character Wikipedia (CC BY-SA)
- TextDecoder - Web APIs MDN Web Docs (Mozilla, CC BY-SA)
- HTMLInputElement: webkitdirectory property MDN Web Docs (Mozilla, CC BY-SA)
- Web Workers API MDN Web Docs (Mozilla, CC BY-SA)