Ramblings from a software developer

EnTabFile – a Windows tool to EnTab a source file

EnTabFile is a tool to convert the spaces at the start of each line in a file to tabs. This allows them to work better in editors that support proper tabs. It is primarily designed to be used as a command line tool, but supports manual operation too.

How EnTab works

This tool is quite simple – it just removes spaces at the start of each line of an ANSI text file and replaces them with tab characters. It does not replace any spaces anywhere else in the line – it stops once it find anything that isn’t a space.

The number of spaces used for each tab is settable in the user interfaace, but the tool is really designed to be used from the command line as part of a bigger process – perhaps source code reformatting using something like DelForExp. Set DelForExp to output 4 spaces for each tab, and then use EnTabFile to convert every 4 spaces into a tab.

Note that if an incomplete set of spaces is found, a tab will still be output. Thus if there are 6 spaces and the tab setting is 4, then 2 tabs will be output. No spaces are ever left at the start of a line.

For safety, it will save an original copy with the extension “.pretab” that you can use to compare. If it already exists, no copy is made so that the entab can be done multiple times and the original is still there.

Manual use:

Run the application, and type in the name of the file you wish to entab. You can click the ‘…’ button to use a browser.

Select the number of spaces per tab.

Click “Entab” and it will be loaded, converted, and saved. A progress bar shows the activity.

Command line use:

Run the application with the filepath for the file you want converted. The full path should be specified for proper operation of the backup.

Only a single file can be specified on the command line.

You can specify the tab size using the command line switch /1, /2 /3 /4 /5 /6 /7 or /8.

With a command line, the app will convert the file (if it exists!) and then close immediately.

Delphi Integration:

For use within Delphi, you can add it to the Tools menu. The following are suggestions:

Title: EnTab this file
Program: [PATH TO FILE]\EnTabFile.exe
Working Directory: [PATH TO FILE]
Parameters: $SAVE $EDNAME

Note that if run after DelForExp, you will have to save before it can convert. After Entabbing, Delphi will say the file has changed and do you want to reload. The answer should always be yes or the tabs will not be loaded!

Download

A zip file with these basic instructions and the self-contained application are available via the link: EnTab for Windows. No installer is needed – just put the file in a suitable location, unzip it, and start using it.