detab -- convert tabs to spaces two different ways
detab.pl is a perl program which detabs a text file using two different methods for converting tabs to spaces. The two methods are 1) a column-based mode which attempts to insert spaces to a "virtual" tab location and 2) a literal number of spaces per tab character.
- Show detab.pl code
- Download: detab.pl
Limitations
- This is written in Perl so needs Perl available.
- It is a command line program and would generally run on Linux or Unix.
- The program gives two methods of tab replacement. Probably you'll need to try both to see which one comes closer to how the original file was formatted when using tabs. If custom tab stops are used, such as in MS Word, then the replacement of tabs in a text file won't be consistent.
Example
For example, if you have text like
"Test[tab]some stuff"
then with 8 chars per tab, in column mode, you'll get
"Test^^^some stuff"
^
column 8...but in literal mode, you'll get
"Test^^^^^^^^some stuff"
8 spaces
Back to Kent's Perl Page Last-modified: Sun Aug 10 12:11:33 EDT 2025