ブログ

読んで思い出す。忘れるために書く

EditorConfig で Tab vs Space インデント戦争を終わらせる(参考リンク)

まとめ

EditorConfig をチームで導入して、それぞれ好きなエディタを使いつつも 統一的な書き方を進めていこう

設定ファイル?

改行は CRLF, LF にするのかとか 文字コード、ファイルの末尾に空行を入れるか、インデントはタブかスペースか、インデントのサイズは... と言った具合に設定できる

https://editorconfig.org/#example-file から引用

# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,py}]
charset = utf-8

# 4 space indentation
[*.py]
indent_style = space
indent_size = 4

# Tab indentation (no size specified)
[Makefile]
indent_style = tab

# Indentation override for all JS under lib directory
[lib/**.js]
indent_style = space
indent_size = 2

# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2

最初からエディタの機能として統合済みのモノから、プラグイン導入で対応できるエディタまで多数ある : https://editorconfig.org/#download

Links