Skip to content

Latest commit

 

History

History
60 lines (40 loc) · 2.13 KB

use_editorconfig.md

File metadata and controls

60 lines (40 loc) · 2.13 KB

Use EditorConfig

EditorConfig is a magnificent tool.

It lets you control aspect of file types such as:

  • Encoding (charset)
  • Line endings (end_of_line) and (trim_trailing_whitespace)
  • Line length (max_line_length)
  • File ending (insert_final_newline)
  • Indentation style (indent_style)
  • Indentation size (indent_size)

👉 Do note that all implementations might not support all properties.

The properties can be specified for file types:

All files:

[*]
# properties

Or file patterns:

[*.{js,py}]
# properties

And finally:

You can use it globally on a project basis, by specifying if you file is the root in your project by adding the file: .editorconfig to your project directory.

# top-most EditorConfig file
root = true

And you can then add the global definition (.editorconfig) to your $HOME directory.

It integrates with most editors like Visual Studio Code, Sublime Text, Atom or Vim, check the list on the EditorConfig site.

Do note that the rule of thumb is not to change everything, but just the new adjustments, when you change or add a property, because this could cause misleading file diffs and hence commits.

If you want to change everything according to your EditorConfig property settings, check out eclint (Editor Config Linter), see my TIL on eclint. Do note eclint is no longer actively maintained so alternatives like ec (editorconfig-checker).

You can also enable use of EditorConfig for GitHub Actions, see my TIL on EditorConfig GitHub Action

References