Just another WordPress.com weblog

Replace tabs by spaces in files

Before you commit changes to a SVN repository, you might want to replace tabs by spaces in source code. Some text editor can be configured in order to do it automatically during the edition of the file:

Gedit: In the Edit / Preference / Editor menu check the “insert spaces instead of tabs” and set it to as many space characters as you want.

Eclipse: In the Window / Preference / menu and under the “General / Editor / Text Editor” section set the “Displayed tab width” value to what suits your needs and check the “insert spaces for tabs” checkbox.

But sometimes you’re using another editor without this option or you copy paste code from a source that contains tabs characters. In this case you can use this script: