This simple tool removed tabulators and trailing spaces in text files. The main usage is in conjunction with version controlled text files. During the editing of the text files, traling spaces may be left behind and some editors replace sequences of spaces with tabs. Although these characters are in most cases invisible when you look at the file, they do usually matter for your version control system. This tool removes spaces and tabs in files and is capable of doing a backup and then overwrite your files with the changed version. I use this regulary, before doing a "commit" of a file to my version control system.
filter out all tabs:
txtcleanup.py -u < myfile > result
filter out trailing spaces at the end of lines:
txtcleanup.py -s < myfile > result
filter out tabs and trailing spaces:
txtcleanup.py -su < myfile > result
remove tabs and trailing spaces in your file (with backup of the original):
txtcleanup.py -suf myfile
--summary | print a one-line summary of the scripts function |
-f FILE, --file FILE | |
specify the file to read from. If this option is missing, all left-over arguments on the command line are interpreted as filenames. If this option is missing and there are no left-over arguments on the command line, the program reads from standard-in. | |
-i, --inplace | if this option is given and if filenames are provided (see above), the changes are made in-place. The given files are changed but the original versions of the files are renamed to FILE.old. |
-s, --unspc | if this option is given, the program removes traling spaces, these are spaces in lines that are only followed by line-end characters, nothing else |
-u, --untab | if this option is given, the program replaces tabulators with spaces. Note that the default tabulator size (see also "--tabwidth") is 8 characters. |
--tabwith TABWIDTH | |
this option is used to change the default tabulator size, which is 8, to a different value. | |
-S, --stats | with this option, the program prints short statistic (number of lines versus changed lines) to standard-error. |
--max LINENO | change up to LINENO lines. This may be useful when txtcleanup.py would change many lines but this would be a too large change with respect to version control. |
-doc | print reStructuredText documentation (THIS text :-)...). Use "./txtcleanup.py --doc | rst2html" to create a html documentation. |