How to use the EditorConfig generator
- Choose Indent with: Spaces or Tabs, and set the Indent size (1–8).
- Pick Line endings (LF or CRLF) and the Charset: UTF-8, UTF-8 with BOM or Latin-1.
- Keep Trim trailing whitespace and Final newline ticked unless you have a reason not to. Set Max line length if you want a ruler, or leave 0 for off.
- Tick the exceptions you need: Keep trailing spaces in Markdown, YAML: 2 spaces, Python: 4 spaces and Makefiles: tabs.
- Save the output as
.editorconfigin the root of your repository.
What it does and when to use it
When people on one project use different editors, small differences creep in: tabs in one file, spaces in the next, Windows line endings in a third. An .editorconfig file makes every supporting editor use the same basic settings for each file type.
Use it at the start of any shared project, or when diffs are full of whitespace noise. It works alongside the Prettier config generator, which reformats code, and the ESLint config generator, which checks it. If you use a Makefile, keep the tab rule ticked so editors do not turn the tabs in the Makefile generator output into spaces.
How it works
The file is plain INI-style text read from top to bottom. A [*] section sets the defaults for all files, and later sections with a glob such as [*.py] override them for matching files. The EditorConfig site lists every property.
- With Spaces, the tool writes
indent_sizewith your number. - With Tabs, it writes
indent_size = tabandtab_widthwith your number, so the width of a tab is defined too. - Max line length is written only when it is above 0.
- The Makefile section matches
Makefile,makefileand*.mk, because make fails on lines indented with spaces.
Worked examples
Default settings. Two-space indentation and LF, with all three exceptions:
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
followed by [*.md] with trimming off, [*.{yml,yaml}] with 2 spaces and [{Makefile,makefile,*.mk}] with tabs.
Tabs for a Python-and-Go team. Indent with Tabs, size 4, Python ticked, the other exceptions off. The [*] section has indent_size = tab and tab_width = 4, and a [*.py] section switches Python files back to 4 spaces, as PEP 8 recommends.
Windows-oriented project. CRLF, UTF-8 with BOM, max line length 120. The defaults read end_of_line = crlf, charset = utf-8-bom and max_line_length = 120.
Limits and tips
- Existing files are not changed. Editors apply the settings as you edit; reformat old files once with a formatter.
- Line endings in Git are also affected by
core.autocrlfand.gitattributes; keep them consistent with this file.
Frequently asked questions
Which editors read .editorconfig?
What does root = true do?
Why does Markdown keep trailing whitespace?
Is max_line_length enforced?
Do I still need Prettier if I have EditorConfig?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.