.editorconfig generator: tabs, spaces and line endings
Make every editor on your team use the same indent, line endings and encoding.
An .editorconfig file keeps indent size, line endings and file encoding the same in every editor and for every person on a project. Choose your rules below and save the result in your project folder.
Create your config file
Type your own values. The file below updates as you type, and nothing you type leaves your browser.
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
[Makefile]
indent_style = tab
[*.md]
trim_trailing_whitespace = falseHow this setup works
Step-by-step setup
- Save the lines above as .editorconfig (with the dot) in the top folder of your project.
- Install the EditorConfig plugin if your editor needs one. VS Code needs the "EditorConfig for VS Code" extension, while JetBrains editors and many others read the file on their own.
- Reopen a file and press Tab to see the new indent.
- Commit the file so everyone gets the same rules.
- Keep the same rules in your formatter (Prettier, Black) so they do not disagree.
What the important lines mean
- root = true stops the editor from looking for more .editorconfig files in parent folders.
- [*] applies to every file. A section like [*.py] applies only to those files.
- indent_style and indent_size set tabs or spaces and how wide they are.
- end_of_line sets the line ending: lf or crlf.
Common errors and how to fix them
- My editor ignores .editorconfig
- Some editors need a plugin. In VS Code install the EditorConfig extension. Also check the file is called exactly .editorconfig and sits in a parent folder of the file you edit.
- Formatter and EditorConfig fight each other
- Tools like Prettier read .editorconfig too, but a separate formatter config can override it. Make both use the same indent and line ending.
- Git shows every line as changed
- The line endings changed from CRLF to LF or the other way. Pick one, then run your editor's "convert line endings" or use a .gitattributes file with * text=auto.
- Makefile error: missing separator
- Makefiles need real tabs. Keep the Makefile section so editors do not turn tabs into spaces.
Frequently asked questions
- What is an .editorconfig file?
- A plain text file that sets indent style, indent size, line endings and encoding. Supported editors read it and apply the rules while you type.
- Tabs or spaces?
- Either works if everyone agrees. Spaces look the same everywhere. Tabs let each person choose their own width. Pick one for the project and write it here.
- Do I need it if I use Prettier?
- It is still useful. It makes editors follow the same rules before you format, and it covers file types Prettier does not handle.
More developer configs
- GitHub Actions workflow for Node.jsA ci.yml file that installs, lints, builds and tests your Node.js project on GitHub.
- package.json fileCreate a package.json with the right name, version, module type, scripts and Node version.
- tsconfig.json fileCreate a tsconfig.json for a Node or browser TypeScript project, with strict mode, target and output folder.
- SSH config for multiple GitHub accountsUse two or three GitHub accounts on one computer with separate SSH keys and host names.
- SSH config fileGive servers short names and choose the right key for each.
- .gitconfig setupSet your name, email, default branch and shortcuts once.