EditorConfig for a Multi-Language Project
EditorConfig enforces consistent code style rules across different editors and IDEs without requiring everyone on the team to configure their own editor manually. A single .editorconfig file at the root of the repository defines indentation style, tab size, line ending format, and trailing whitespace rules per file type. This example covers JavaScript, TypeScript, Python, Go, YAML, and Markdown with appropriate conventions for each. Most major editors (VS Code, IntelliJ, Vim) read .editorconfig natively or via a free plugin.
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.{js,ts,jsx,tsx,json,css,scss}]
indent_style = space
indent_size = 2
[*.py]
indent_style = space
indent_size = 4
max_line_length = 88
[*.go]
indent_style = tab
indent_size = 4
[*.{yml,yaml}]
indent_style = space
indent_size = 2
[*.md]
trim_trailing_whitespace = falseFAQ
- Do I need to install a plugin for EditorConfig in VS Code?
- Yes. Install the EditorConfig for VS Code extension. Unlike IntelliJ-based editors which support it natively, VS Code requires the extension to read and apply .editorconfig rules.
- Why does Markdown need trim_trailing_whitespace = false?
- In Markdown, two trailing spaces at the end of a line create a line break (<br>). Removing trailing whitespace breaks this intentional formatting, so it is disabled for .md files.
- What line ending should I use: LF or CRLF?
- Use LF (Unix-style) for cross-platform projects. CRLF (Windows) causes noise in git diffs on non-Windows systems. Set git autocrlf = input on Windows to convert on commit.
Related Examples
Prettier is an opinionated code formatter that removes all debates about style b...
.gitignore for a Node.js ProjectA good .gitignore prevents accidental commits of node_modules, build artifacts, ...
Write a CONTRIBUTING GuideA contributing guide reduces friction for new contributors by explaining how to ...