Consistent Coding Styles with EditorConfig

  • Jul

Maintainability is a key aspect you must keep in mind when you are coding. But "maintainability" may include a lot of things, from the basics to the most advanced standards and practices. The goal of this post is not to cover all of them but to give you a good point to start.

If two or more colleagues write code for the same project, they should follow certain rules to ensure the the code legibility between themselves. Things as simple as use the same indentation size may be the difference between a readable file and a real headache.

EditorConfig is a tool that helps developers to get this consistency by centralizing coding styles. It's composed by a configuration file with rules that will be shared to all the team members, and a plugin that ensures the application of these rules in your code editor.

The ".editorconfig" file contains rules like whether to use spaces or tabs for the indentation and its size, the charset, the trimming of trailing spaces, etc. You can also create several configuration files to override some rules in a specific directory. What is more, it's possible to use regexps to define the files will receive certain rules.

There are plugins for all major editors. In case you don't find one, you always can create it.

Start to bring order to your shared projects with EditorConfig!

Posted on July 3, 2014, 3:04 p.m.