SublimeText : Remove trailing spaces on file save

09 Aug 2012

I hate to have trailing spaces in my git codebase. Since I was an netbeans user before, there was an option to remove trailing spaces; but manually we need to command on each file. But after switching into SublimeText I searched for such option in the menu, but didn't find.

SublimeText really surprised me by giving much more easiler way to trim the trailing spaces. In sublime text we  don't need to manually use the option. They are intelligent enough to do this before each time we save the file.

We need to manually enable the option in user settings, since they are disabled by default. Here is how we can enable it.

Goto Preferences -> Settings - User

Add the below line into the file, in between the curly braces ({})

Now save it. You are done.
Now your user specific preferences  file will look something like this,provided if you didn't set any other user specific prefences ;)

Screencast
If you find my work helpful, You can buy me a coffee.