Thanks for the tip. I use gedit and didn't find any such option but will change it for Eclipse and there I will search for an option to automatically remove whitespaces in code.