# EditorConfig

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/EditorConfig
> Markdown URL: https://mediated.wiki/source/EditorConfig.md
> Source: https://en.wikipedia.org/wiki/EditorConfig
> Source revision: 1350885140
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{Short description|Specification and file format}}
{{Primary sources|date=May 2024}}
{{Infobox file format
| name          = EditorConfig
| type          = [INI](/source/INI_file) configuration file
| url           = {{URL|https://editorconfig.org/}}
| standard      = {{URL|https://spec.editorconfig.org/}}
| free          = Yes
| open          = Yes
}}

'''EditorConfig''' is an open specification and file format for [syntax highlighting](/source/syntax_highlighting), [text editor](/source/text_editor)s and [integrated development environment](/source/integrated_development_environment) (IDEs) that aims to maintain a consistent coding style, particularly aimed at groups working together.<ref>{{Cite web |last=Hombergs |first=Tom |date=2021-02-15 |title=Painless Code Formatting with EditorConfig |url=https://reflectoring.io/painless-code-formatting-with-editor-config/ |access-date=2024-04-24 |website=reflectoring.io |language=en-us}}</ref><ref>{{cite web |title=Define consistent coding styles with EditorConfig |url=https://learn.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options?view=vs-2022 |website=Microsoft Build | date=April 2024 |publisher=Microsoft |access-date=April 1, 2024}}</ref> It can help keep multiple editors as well as individuals using the same conventions. It stores configurations in a file which can be shared by multiple people or used in multiple editors (by the same person or by many).<ref>{{cite web |title=EditorConfig |url=https://twitter.com/EditorConfig |website=X (Formerly known as Twitter) |access-date=24 April 2024}}</ref><ref>{{cite web |last1=The Codeholic |title=What is .editorconfig - EditorConfig full Guide |url=https://www.youtube.com/watch?v=EvGXkL31CpI |website=YouTube |access-date=24 April 2024}}</ref> It defines rules for how to format different programming languages or other structured text files with conventions such as what character to end a line with and how to manage indentation.<ref>{{cite web |title=Configuration files for code analysis rules |url=https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/configuration-files |website=Microsoft Build |date=6 October 2023 |access-date=24 April 2024}}</ref>

==Concept==
The project web site states "EditorConfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs. The EditorConfig project consists of a file format for defining coding styles and a collection of text editor plugins that enable editors to read the file format and adhere to defined styles. EditorConfig files are easily readable and they work nicely with version control systems."<ref>{{cite web |title="EditorConfig" | url=https://editorconfig.org/ |website=EditorConfig |access-date=23 April 2024}}</ref>

==Specification==

Source:<ref>{{cite web |title="EditorConfig Specification" |url=https://spec.editorconfig.org/ |access-date=24 April 2024}}</ref>

The configuration is typically stored in a [UTF-8](/source/UTF-8) encoded text file: {{Mono|.editorconfig}}.  Some tools allow saving their style preferences as an EditorConfig file.<ref>{{cite web |url=https://learn.microsoft.com/en-us/visualstudio/ide/code-styles-and-code-cleanup?view=vs-2022#code-styles-in-editorconfig-files | title=Code style options and code cleanup - Visual Studio (Windows) | date=15 May 2023 }}</ref>
Each line:
* May be blank (only [whitespace character](/source/whitespace_character)s)
* A [comment](/source/Comment_(computer_programming)) that begins with <kbd>;</kbd> or <kbd>#</kbd>
* A section header, which starts with a square bracket [, and ends with a square bracket ].
** A section header may not have any non-whitespace characters outside of the brackets
** It may contain any characters between the brackets including whitespace/tabs
** It uses forward slash characters <kbd>/</kbd> as path separators
*** Backslashes <kbd>\</kbd> are prohibited, even on Windows.
* [Key–value](/source/Key%E2%80%93value) pair, with a <kbd>=</kbd> separating the key from the value
Any other line format is invalid. It does not support in-line comments. If there is a <kbd>;</kbd> or <kbd>#</kbd> character anywhere other than the start of line it is considered to be part of the text of the line.  It does not support any character escaping.

===Parts/sections of file===
* Preamble:  ''optional'' <code>key=value</code> pairs that precede the first section.
* Section Name: String between <kbd>[  ]</kbd>
* Section: the key value pairs that follow a section name until the start of the next section.

===[glob](/source/glob_(programming)) expressions===
Section names are file path globs, using a format similar to {{Mono|.gitignore}}, and are based on Unix conventions.
{| class="wikitable"
|+ File name globs
|-
! Characters !! Matched files
|-
! <kbd>*</kbd>
| Any string (of any length) except path separators (<kbd>/</kbd>
|-
! <kbd>**</kbd>
| Any string of characters
|-
! <kbd>?</kbd>
| Any ''single'' character
|-
! <kbd>[seq]</kbd>
| Any ''single'' character in the seq
|-
! <kbd>[!seq]</kbd>
| Any ''single'' character '''not''' in seq
|-
! <kbd>{s<sub>1</sub>,s<sub>2</sub>,..s<sub>n</sub>}</kbd>
| ''Any'' of the comma-separated list of strings.  This can be nested. There must be more than one string in the list, as {somestring} will match the literal value '<kbd>{somestring}</kbd>' (which is probably not what was intended).
|-
! <kbd>{n<sub>1</sub>..n<sub>2</sub>}</kbd>
| Matches an integer number between n<sub>1</sub> and n<sub>2</sub> (i.e. matches <math>i \isin \mathbb{Z} | n_1 \le i \le n_2</math>)
|}

===File location===
EditorConfig plugins look for a file named {{Mono|.editorconfig}} in the same directory that contains an existing file, and in parent directories of that one until it hits the root file path (e.g. {{Mono|/}} in [Linux](/source/Linux)/[Unix](/source/Unix)/[macOS](/source/macOS) or {{Mono|C:}} in the case of Microsoft Windows, or it finds an {{Mono|.editorconfig}} file that contains a line that states <code>root=true</code>.

The most recent rules found take precedence in the order they are read.  So rules in the same directory as the file would over-rule rules from higher level directories.

===File format===
Editor config uses the common [INI](/source/INI_file) configuration file format.

===Style options===
{| class="wikitable"
|+ Configuration options
|-
! Key !! Settings to configure the option
|-
! indent_style
| Set to use  <kbd>"tab"</kbd> or <kbd>"space"</kbd> to use tab characters or spaces
|-
! indent_size
| Integer that defines how many spaces per tab, or how wide a tab stop is.
|-
! tab_width
| This usually isn't specified as it defaults to the {{Mono|indent_size}}
|-
! end_of_line
| Set to <kbd>"[lf](/source/Line_feed)"</kbd> , <kbd>"[cr](/source/Carriage_return)"</kbd>, or <kbd>"crlf"</kbd> to control how [line breaks](/source/Newline) are represented.
|-
! charset
| [Character encoding](/source/Character_encoding) "[latin1](/source/latin1)", "[utf-8](/source/utf-8)", "utf-8-bom", "utf-16be" or "utf-16le" to control the character set.
|-
! trim_trailing_whitespace
| If set to "{{Mono|true}}" will remove any whitespace characters preceding newline characters
|-
! insert_final_newline
| If "{{Mono|true}}" will end files with a newline, "{{Mono|false}}" will prevent it.
|-
! root
| Special property (e.g. specified at the top of the file outside of any sections). Set to "{{Mono|true}}" to stop {{Mono|.editorconfig}} files search on current file. (I.e. don't keep looking for any more EditorConfig files in higher level directories.
|}

Some tools support additional options such as {{Mono|max_line_length}} (which forces a hard line wrap after the specified number of characters) (supported by [Emacs](/source/Emacs), [Vim](/source/Vim_(text_editor)), [Atom](/source/Atom_(text_editor)), and several others)

==Implementation==
Many popular editors have adopted support of the specification.<ref>{{cite web |title="What is .editorconfig ?" |url=https://www.geeksforgeeks.org/what-is-editorconfig/ |website=Geeks for Geeks |access-date=24 April 2024 |date=7 March 2024}}</ref>  The [GitHub](/source/GitHub) page for the project has libraries written in [Go programing language](/source/Go_(programming_language)),<ref>{{cite web |url=https://github.com/editorconfig/editorconfig-core-go |title=Editorconfig/Editorconfig-core-go |website=[GitHub](/source/GitHub) |access-date=24 April 2024 }}</ref> [C programing language](/source/C_(programming_language)),<ref>{{cite web |url=https://github.com/editorconfig/editorconfig-core-c |title=Editorconfig/Editorconfig-core-c |website=[GitHub](/source/GitHub) |access-date=24 April 2024 }}</ref> and [Python programming language](/source/Python_(programming_language)),<ref>{{cite web |url=https://github.com/editorconfig/editorconfig-core-py |title=Editorconfig/Editorconfig-core-py |website=[GitHub](/source/GitHub) |access-date=24 April 2024 }}</ref> and there is a [Node.JS](/source/Node.JS) library as well.<ref>{{cite web |url=https://www.npmjs.com/package/editorconfig |title=Editorconfig |date=2 July 2023 |access-date=24 April 2024 }}</ref> There is a comprehensive listing of editors available on the project site.<ref>{{Cite web |title=Projects Using EditorConfig |url=https://github.com/editorconfig/editorconfig/wiki/Projects-Using-EditorConfig |access-date=2024-04-24 |website=GitHub |language=en}}</ref>

===Editors reported to work without use of a plug-in===
[Gitea](/source/Gitea), [GitHub](/source/GitHub), IntelliJ IDEA,<ref>{{cite web |url=https://www.jetbrains.com/help/idea/editorconfig.html |title=EditorConfig {{pipe}} IntelliJ IDEA }}</ref> PyCharm, BBEdit, Xcode 16, and editors by [JetBrains](/source/JetBrains),<ref>{{cite web |url=https://plugins.jetbrains.com/plugin/7294-editorconfig/ |title=EditorConfig - IntelliJ IDEs Plugin {{pipe}} Marketplace |access-date=24 April 2024 }}</ref> [Kate](/source/Kate_(text_editor)), [Emacs](/source/Emacs)<ref>{{cite web |url=https://www.gnu.org/software/emacs/news/NEWS.30.1 |title=GNU Emacs NEWS, New Modes and Packages in Emacs 30.1 |date=2025-02-23 |access-date=2025-07-16 }}</ref>, [Komodo](/source/Komodo_IDE), [Visual Studio](/source/Visual_Studio), [Vim](/source/Vim_(text_editor))/[Neovim](/source/Neovim).

===Editors which require a plug-in===
Some editors require installation of a [plug-in](/source/Plug-in_(computing)):
[Eclipse IDE](/source/Eclipse_IDE), [Atom](/source/Atom_(text_editor)), [Geany](/source/Geany), [JEdit](/source/JEdit), [Notepad++](/source/Notepad%2B%2B), [NetBeans](/source/NetBeans), [Visual Studio Code](/source/Visual_Studio_Code),<ref>{{cite web |url=https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig | title=EditorConfig for VS Code - Visual Studio Marketplace |access-date=24 April 2024 }}</ref> [Sublime Text](/source/Sublime_Text)

===Build environment which require a plug-in===
[Apache Ant](/source/Apache_Ant), [Gradle](/source/Gradle), [Apache Maven](/source/Apache_Maven)

===Editors which don't support EditorConfig===
There is no list maintained of all the various text editors or IDEs which do not support EditorConfig (e.g. [Spyder IDE](/source/Spyder_IDE)<ref>{{cite web |title=Add support for .editorconfig #2464 |url=https://github.com/editorconfig/editorconfig/wiki/FAQ |website=Syder-ide Github |date=June 2, 2015}}</ref> has had support mentioned in the past, but does not seem to yet include it.<ref>{{cite web |url=https://github.com/editorconfig/editorconfig/issues/465 |title='EDITORCONFIG' environmental variable for global config · Issue #465 · editorconfig/Editorconfig |website=[GitHub](/source/GitHub)|access-date=24 April 2024  }}</ref><ref>{{cite web |url=https://docs.spyder-ide.org/current/panes/editor.html |title=Editor — Spyder 5 documentation |access-date=24 April 2024 }}</ref>

===Other software development tools which implement EditorConfig===
Prettier<ref>{{Cite web |date=2022-01-25 |title=How I Setup ESLint, Prettier, and EditorConfig for Static Sites |url=https://dev.to/npranto/how-i-setup-eslint-prettier-and-editorconfig-for-static-sites-33ep |access-date=2024-04-24 |website=DEV Community |language=en}}</ref>

==References==
{{Reflist}}

Category:Configuration files

---
Adapted from the Wikipedia article [EditorConfig](https://en.wikipedia.org/wiki/EditorConfig) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/EditorConfig?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
