Last Updated: February 25, 2016
·
3.111K
· subosito

Many editors, many developers, one convention.

Wether we are using Vim, Sublime Text, Textmate, Emacs, or any other editors, one thing we should take care, consistent coding convention. If you're coding Ruby, you are better using two spaces and for javascripts you are better using four spaces.

In short words, follow the standard code conventions for each language you write. Following standard is better for you, for your productivity and for collaborative development.

But, how do we make bunch of editors consistent? Every editor has own configuration and should I tell people to follow the conventions manually? or any better way to do that?

Yes, you're safe now. Thanks for the editorconfig project. This project saves our life. Why?

Instead of telling people to change configuration and bla bla bla. You can create a .editorconfig file inside your project directory. Here's the sample:

# .editorconfig
root = true

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

[*.markdown]
indent_size= 4
trim_trailing_whitespace = false

[*.{js,php}]
indent_size= 4

With .editorconfig above, all files inside project directory, will be two spaces by default, except for .markdown, .js, and .php which use four spaces.

Put the .editorconfig to the root of the project directory. Then Install editorconfig plugin for your editor. As long as the editors have plugin installed, it will be making your codes more consistent.

3 Responses
Add your response

mantap

over 1 year ago ·

@ardianys Monggo diimplementasikan :)

over 1 year ago ·

Great TIP!

over 1 year ago ·