It has happened multiple times that I am doing a code review and I find issues like trailing white space or tabs instead of spaces. This annoys me because it is something that your editor should do for you for free. It annoys me even more when I ask the developer to configure their editor to remove trailing white space and they tell me they don’t know how to do it. In most scenarios they are using Eclipse or some other fancy IDE that I am not familiar with, so I can’t help them much. EditorConfig will help me with that problem.

From now on I plan to add an .editorconfig file to all my projects and simply ask my colleagues to install the plugin on their IDE.

Lets see how to install the plugin for VIM. Assuming you have pathogen installed you should only need this:

1
2
cd ~/.vim/bundle
git clone https://github.com/editorconfig/editorconfig-vim.git

Now you can add a file named .editorconfig to the root of your project. I’m going to start with something like this for my JS projects:

1
2
3
4
5
6
7
8
9
root = true

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

Currently there is a very short list of things you can configure, and their support varies from plug-in to plug-in. Even so I think this will become a very useful tool for my projects.

[ productivity  vim  ]
Setting the search directory for Ctrlp vim plugin productivity vim
Disable expandtab in Vim productivity vim
Adjusting the width of Nerdtree navigator productivity vim
Temporarily disable Syntastic on Vim productivity vim
Quick Vim setup vim productivity