Skip to content

Instantly share code, notes, and snippets.

@beeyev
Last active February 20, 2026 09:29
Show Gist options
  • Select an option

  • Save beeyev/da5a065d01a506d0b3d42e794f7aadf9 to your computer and use it in GitHub Desktop.

Select an option

Save beeyev/da5a065d01a506d0b3d42e794f7aadf9 to your computer and use it in GitHub Desktop.
editorconfig best practice
# EditorConfig
# https://gist.github.com/beeyev/da5a065d01a506d0b3d42e794f7aadf9
# Top-most EditorConfig file
root = true
# General rule: Unix-style newlines with UTF-8 encoding
[*]
charset = utf-8
end_of_line = lf
indent_style = space
trim_trailing_whitespace = true
insert_final_newline = true
# PHP, CSS, SCSS
[*.php]
indent_size = 4
[*.css]
indent_size = 4
[*.scss]
indent_size = 4
# Bazel
[*.bazel]
indent_size = 4
[*.bzl]
indent_size = 4
# YAML-based files
[*.yml]
indent_size = 2
[*.yaml]
indent_size = 2
[*.sls]
indent_size = 2
# NEON Configuration files
[*.neon]
indent_style = tab
indent_size = 4
[*.neon.dist]
indent_style = tab
indent_size = 4
# CoffeeScript & CJSX
[*.coffee]
indent_size = 2
tab_width = 2
[*.cjsx]
indent_size = 2
tab_width = 2
# Markdown & Text files (whitespace is important)
[*.md]
indent_size = 4
trim_trailing_whitespace = false
[*.markdown]
indent_size = 4
trim_trailing_whitespace = false
[*.mdx]
indent_size = 2
trim_trailing_whitespace = false
[*.txt]
indent_size = 4
trim_trailing_whitespace = false
# Makefiles, Caddyfiles, Git configuration
[Makefile]
indent_style = tab
tab_width = 4
[Caddyfile]
indent_style = tab
tab_width = 4
[*.Caddyfile]
indent_style = tab
tab_width = 4
[.gitconfig]
indent_style = tab
tab_width = 4
[.gitconfig.local]
indent_style = tab
tab_width = 4
# Python (PEP 8)
[*.py]
indent_size = 4
# Shell Scripts (Google Style Guide)
# https://google.github.io/styleguide/shell.xml#Indentation
[*.bash]
indent_size = 2
[*.sh]
indent_size = 2
[*.zsh]
indent_size = 2
[*.ps1]
indent_size = 4
# Go
# https://golang.org/cmd/gofmt/
[*.go]
indent_style = tab
# Explicit tab width for Go (common convention)
indent_size = 4
[go.mod]
indent_style = tab
indent_size = 4
[go.sum]
indent_style = tab
indent_size = 4
# Dockerfiles
[Dockerfile]
indent_size = 4
[Dockerfile.*]
indent_size = 4
[Dockerfile-*]
indent_size = 4
# Environment Files
[*.env]
insert_final_newline = false
trim_trailing_whitespace = false
[.env]
insert_final_newline = false
trim_trailing_whitespace = false
[.env.*]
insert_final_newline = false
trim_trailing_whitespace = false
# JavaScript, JSON, JSX, TypeScript
# https://github.com/feross/standard
[*.cjs]
indent_size = 2
[*.js]
indent_size = 2
[*.json]
indent_size = 2
[*.jsonc]
indent_size = 2
[*.jsx]
indent_size = 2
[*.mjs]
indent_size = 2
[*.ts]
indent_size = 2
[*.tsx]
indent_size = 2
[*.vue]
indent_size = 2
[*.svelte]
indent_size = 2
# XML, XSD, and similar
[*.xml]
max_line_length = off
indent_size = 2
[*.xml.dist]
max_line_length = off
indent_size = 2
[*.xsd]
max_line_length = off
indent_size = 2
# TOML
[*.toml]
indent_size = 2
# INI and properties
[*.ini]
indent_size = 2
[*.cfg]
indent_size = 2
[*.conf]
indent_size = 2
[*.properties]
indent_size = 2
# SQL
[*.sql]
indent_size = 4
# Terraform, HCL, Nomad
[*.tf]
indent_size = 2
[*.tfvars]
indent_size = 2
[*.hcl]
indent_size = 2
[*.nomad]
indent_size = 2
# Composer JSON (uses 4 spaces)
[composer.json]
indent_size = 4
# Diff & Patch files (preserve formatting)
[*.diff]
insert_final_newline = false
trim_trailing_whitespace = false
[*.patch]
insert_final_newline = false
trim_trailing_whitespace = false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment