.editorconfig: one formatting baseline for every editor
Teams lose surprising amounts of time to invisible differences: one person's editor indents with tabs, another's with four spaces, a Windows machine saves CRLF line endings, and every diff fills with whitespace changes. An .editorconfig file in the root of a project sets those basics once, and most editors follow it automatically.
Choose the indent style and size, the character set, the line endings and the whitespace rules, and this generator writes the file.
How to use it
- Choose the indent style, tabs or spaces, and the indent size.
- Choose the charset, usually utf-8, and the end of line, usually lf.
- Keep trim trailing whitespace and insert final newline switched on unless you have a reason not to.
- Save the result as .editorconfig in the root of your repository and commit it.
Example: a common web-project baseline
Spaces, size 2, utf-8, lf, trim whitespace, final newline
root = true [*] indent_style = space indent_size = 2 charset = utf-8 end_of_line = lf trim_trailing_whitespace = true insert_final_newline = true
root = true tells editors to stop looking for further .editorconfig files in parent folders.
Which editors support it
JetBrains IDEs, Visual Studio, GitHub's web editor, Xcode, BBEdit and many others read .editorconfig natively. VS Code needs the free EditorConfig extension, and Vim and Emacs have plugins; Neovim supports it out of the box since version 0.9. Without support, the file is simply ignored, so adding it never breaks anything.
Different rules per file type
Sections use glob patterns, so you can add more below the generated [*] section. Makefiles require real tabs, so add [Makefile] with indent_style = tab. Markdown uses two trailing spaces for a line break, so many projects add [*.md] with trim_trailing_whitespace = false. Later sections override earlier ones for matching files.
EditorConfig and formatters
EditorConfig handles the basics as you type; formatters such as Prettier, Black or gofmt rewrite whole files to a style. They work well together, and Prettier reads indent and line-ending settings from .editorconfig when its own config does not set them, which keeps the two in agreement.
Questions
Why lf line endings?
Linux and macOS use LF, Git stores LF internally and most tools expect it. Windows editors handle LF fine today.
Does it reformat existing files?
No. Editors apply the rules as you edit. Run a formatter once to bring existing files in line.
Is anything uploaded?
No. The file is generated in your browser.