Have you ever found yourself switching between projects with vastly different coding styles or (gasp!) no consistent style at all? Most editors and IDEs allow for settings at both the user and project level, but neither of those options are ideal. Often there isn’t a settings file for the project and even if there were, it’s probably for an editor that you don’t use. The only other option is to have the editor auto-detect the settings, but that’s far from perfect.
Thankfully, help has arrived in the form of EditorConfig, which is a file wherein one may define and then maintain a consistent coding style.
A description of the project:
EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs. 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. EditorConfig files are easily readable and they work nicely with version control systems.
Example EditorConfig file
The following is the
.editorconfig file for this website:
Here’s a shortlist of supported properties. See the project’s website for an exhaustive list, although note that not all browser plugins support all properties.
- Indent style
- Indent size
- End of line
- Trim trailing whitespace
- Insert final newline
Editor and IDE Support
There are plugins available for a host of editors and IDEs, although there are unfortunately some notable exceptions. I’m glad that my preferred editor, Sublime Text, is supported. It will be a glorious day in development land when there’s universal support for EditorConfig.
It’s 2013, so why are we still debating tabs versus spaces?! Set a standard and stick with it.