- 统一前导空白字符(空格和 Tab)为 Tab:
将每行代码开头的所有前导空白字符(空格或 Tab)转换为 Tab 字符(\t)。 - 移除每行末尾的空白字符(空格和 Tab) : 删除每行末尾的所有空白字符(空格或 Tab)。
处理前:
// 4 个空格
→ // 1 个 Tab + 2 个空格
Hello World ← 末尾空格 处理后:
→ // 统一为 Tab
→ → // 仅保留 Tab
Hello World ← 末尾空格已删除 - Normalize leading whitespace (spaces and tabs) to tabs:
Convert all leading whitespace characters (spaces or tabs) at the start of each line to tab characters (\t). - Remove trailing whitespace (spaces and tabs) from each line:
Trim any trailing whitespace characters (spaces or tabs) at the end of each line.
Before:
// 4 spaces
→ // 1 tab + 2 spaces
Hello World ← Trailing spacesAfter:
→ // Normalized to tabs
→ → // Tabs only
Hello World ← Trailing spaces removed用法:./simple-formater -dir <directory>
选项:
-dir string
要遍历的根目录路径(必填)
-h 显示帮助信息(等同于 -help)
-help
显示帮助信息
<bug report> https://github.com/wiselike/simple-formater/issues