EditorConfig maintains consistent coding styles between different editors and IDEs across engineering teams.
Standard Project Baseline
Place an .editorconfig file in the root of your project:
# Topmost EditorConfig file declaration
root = true
# Global defaults for all files
[*]
indent_style = space
indent_size = 2
tab_width = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
# 4-space indentation for Python
[*.py]
indent_size = 4
# Tab indentation for Go and Makefiles
[*.go]
indent_style = tab
[Makefile]
indent_style = tab
# Markdown files preserve trailing whitespace for linebreaks
[*.md]
trim_trailing_whitespace = false
Supported Properties
| Property | Allowed Values | Description |
|---|---|---|
root |
true |
Stops parent directory recursive search |
indent_style |
space | tab |
Indentation character type |
indent_size |
Integer | tab |
Number of columns for indentation |
tab_width |
Integer | Columns used to represent a tab (defaults to indent_size) |
end_of_line |
lf | crlf | cr |
Newline character sequence |
charset |
utf-8 | utf-16be | utf-16le | latin1 |
File encoding |
trim_trailing_whitespace |
true | false |
Remove whitespace before newlines |
insert_final_newline |
true | false |
Ensure file terminates with a newline |
max_line_length |
Integer | off |
Maximum column width guideline |
Glob Pattern Matching
*: Matches any string of characters, except path separators (/).**: Matches any string of characters across directory paths.?: Matches any single character.[seq]: Matches any character inseq.[!seq]: Matches any character not inseq.{s1,s2,s3}: Matches any of the comma-separated strings (e.g.{package.json,.travis.yml}).