Stefans Tools

Useful open source tools that make your life easier

tabspace

tabspace is a small command line tool that converts tabs to spaces or spaces to tabs automatically in files. It also removes spaces at the end of lines.

It works with ANSI, UTF-8 and even UTF-16 (on Windows mostly referred to as Unicode) files alike.

The conversion is done so that the alignment always stays the same - the conversion does not simply replace the characters, but uses an algorithm to find out how the replacement has to be done.

The command line is:

tabspace [/path:"path\to\convert"] [/checkonly] [/usetabs]
         [/tabsize:4] [/leaveeol] [/ext:"extension;list"]
/path
specifies the path where all the files are to be converted
/checkonly
if specified, the files are not modified but only an info is shown
/usetabs
convert spaces to tabs instead of tabs to spaces
/tabsize
specifies the tab size, defaults to 4
/leaveeol
if specified, whitespaces at the end of lines are not removed
/ext
a list of file extensions to scan, other extensions are ignored. Defaults to c;cc;cpp;cs;cxx;h;hpp;hxx
/include
a list of patterns to include, separated by ;. If this is set, /ext must not be set!
For example c:\sub1\*.*;*\sub2\*.cpp.
/exclude
a list of patterns to ignore, separated by ;.
For example c:\sub1\*.*;*\sub2\*.cpp.

You can download the tool from here. The source code is here.