LoginSignup
5
2

More than 3 years have passed since last update.

EditorConfigのおすすめ設定

Posted at

EditorConfigとは :thinking:

  • 様々なテキストファイルのコーディングスタイルを統一してくれるツール
    • インデントや文字コードなどを揃えることができる。
    • 複数人の開発だけでなく、後々保守などで別担当者が資産を触る場合もコーディングスタイルに迷わ無くてすむ。
  • かなり他多様なエディタやIDEにバンドルされている。 [公式サイト]

おすすめ設定 :nerd:

/.editorconfig
# http://editorconfig.org
root = true

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

[*.md]
max_line_length = 0
trim_trailing_whitespace = false

補足

[*]
charset = utf-8
end_of_line = lf

最近のプロジェクトであればこの辺はスタンダードかなと。

indent_size = 2
indent_style = space

ハードタブは細かい余白の調整ができなかったりするので、ソフトタブ(スペース)派です。

max_line_length = 120

80だと少し短いので120にしてます。

trim_trailing_whitespace = true

行末の余計なスペースは無駄なので削除します。

insert_final_newline = true

なんとなくでやったけど、ちゃんと理由があるらしい。
POSIXの仕様では「テキストファイルの末尾は改行(newline)で終わる」のが正しい、を確認してみた。

[*.md]
max_line_length = 0
trim_trailing_whitespace = false

Markdownは行の末尾のスペースや改行有無が出力結果に影響するので、EditorConfigで勝手に変更されないように。

5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2