/code-format

A shell script that can batch process source code formats.

Primary LanguageShellMIT LicenseMIT

code-format

MIT

A shell script that can batch process source code formats. Currently it can delete trailing spaces, convert tab indents to 4 spaces indent, and convert end-of-line from windows style (CRLF) to unix style (LF).

For MacOS

Install gnu-sed first.

brew install gnu-sed

Usage

Format a single file:

$ ./code_format.sh test.cc

A folder:

$ ./code_format.sh test/

Supported formats

When converting a directory, it only looks for the file format listed in format_list.conf, and all other formats will not be converted. You can modify format_list.conf to any you need to convert. Now like this:

$ cat format_list.conf
c
cpp
cc
h
hpp
conf
txt
ini
proto
mk
sh
py

TODO

Convert arbitrary file encoding to UTF-8.