What is EditorConfig?

Normally, in a developers team, it comes important (when more developers are involved, more important comes) the fact of define and maintains a consistent coding style.

Lots of text editors and IDE’s provide the way to set things like charset, indentation, end of the line and etcetera. But the way that sets the charset in Sublime Text could be different in Atom or WebStorm.

The editorConfig project comes to solve this mess, take a look at the description of the project.

“The EditorConfig project consists of a file format for defining coding styles and a collection of text editor plugins that enable editors to read the file format and adhere to defined styles.”

How looks an editor config file?

# editorconfig.org
root = true

# Javascript configuration
charset = utf-8
indent_style = space
indent_size = 4

# Json configuration
charset = utf-8
indent_style = space
indent_size = 2

The .editorConfig file should be in the root of your project.

Supported properties

The supported properties are good enough, here an example of the most used by me:

  • Indent style.
  • Indent size.
  • End of a line.
  • Charset.
  • Trim trailing white space.
  • Final new line.

Not all properties are supported by every plugin, in his wiki you can check a complete list of properties.

Native support? I need a plugin?

Some text editors and IDE’s have native support to read the .editorconfig file, check on the download page if yours need a plugin.