Editorconfig

Rules for saving files that are defined in a file to be shared across most editors

summary

Working on projects with multiple developers come with it multiple editors… most of the time. Almost always you will end up with a commit that changes a ton of whitespace, newlines, or tabstops. This is because the previous commit is using different settings. While most projects might never run into this, its quite possible some day it will happen.

Editorconfig tries to define these settings in a file and most modern editors have adopted the plugin to be pre-installed as a standard.

how it works

After making a file .editorconfig in a directory (most common place is the top level of a project) those settings are loaded. Upon saving a file, the rules are automatically applied. This makes for trying to align the settings of modern editors and keep the commits down to only the code changes, instead of formatting changes.

common file

# editorconfig.org

# is this the root?
root = true

# setting for all files
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

# all .toml files
[*.toml]
max_line_length = 100

# all .md files
[*.md]
trim_trailing_whitespace = true

# specific directory of *.html files
[layouts/shortcodes/*.html]
insert_final_newline = false

reference

Here is a wiki page of all the EditorConfig-Properties for reference.

Aaron Addleman
Aaron Addleman
Principal Automation Engineer

Fun with programming and infrastructure