kanta's spike

タブサイズや行内文字数などのエディタ基本設定をリポジトリに登録したい。

ただし、リポジトリの利用者が使用するエディタは不明なため、なるべく汎用的な方法でエディタ基本設定を管理したい。

解決策

.editorconfigを利用すると、各種環境で利用可能なエディタ設定を記述できる。 具体的な記述方法は、EditorConfigにある。

今回は、参考として、facebook/react プロジェクト.editorconfigを紹介する。

# https://editorconfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

[*.md]
max_line_length = 0
trim_trailing_whitespace = false

[COMMIT_EDITMSG]
max_line_length = 0

多くのエディタが標準で.editorconfigに対応しているが、 vscodeの場合、.editorconfigを利用するためには別途プラグインが必要になる。

そのため、EditorConfigの本家が公開しているプラグインである、EditorConfig for VS Codeを導入する必要がある。

参考

作成日: 2023/09/07