A simple and efficient line wrapping tool for text files written in Go.
- Wrap long lines at a specified width (default: 80 characters)
- Preserve indentation when wrapping
- Process files or standard input
- Output to files or standard output
- Handle Unicode text properly
go install github.com/rRateLimit/linew/cmd/linew@latest
Or build from source:
git clone https://github.com/rRateLimit/linew.git
cd linew
go build -o linew cmd/linew/main.go
linew [options] [file]
-w, --width
: Maximum width for line wrapping (default: 80)-i, --indent
: Preserve indentation (default: true)--no-indent
: Do not preserve indentation-o, --output
: Output file (default: stdout)-h, --help
: Show help message
Wrap lines at 80 characters (default):
linew input.txt
Wrap lines at 100 characters:
linew -w 100 input.txt
Process from stdin and output to file:
cat long_text.txt | linew -o wrapped.txt
Wrap without preserving indentation:
linew --no-indent input.txt
The tool reads text line by line and:
- Splits lines that exceed the specified width
- Preserves word boundaries when possible
- Maintains indentation if enabled
- Breaks very long words that exceed the width limit
Run tests:
go test ./...
Build:
go build -o linew cmd/linew/main.go