fold
Wrap long input lines at a fixed character width for display-constrained formatting. Breaks lines at exact positions, adapting to terminal width constraints.
Instructions
Wrap long input lines at a fixed character width, breaking at exact positions. Read-only, no side effects. Returns JSON with wrapped text by default; use --raw for plain output. Use for display-constrained formatting or terminal-width adaptation. Not for paragraph-aware reflowing — use 'fmt' to preserve paragraph structure. See also 'fmt'.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| raw | No | Write folded text without a JSON envelope. | |
| paths | No | Files to fold, or '-' for stdin. Defaults to stdin. | |
| width | No | Maximum line width. | |
| encoding | No | Text encoding (default: utf-8). Use 'auto' for BOM/autodetection. | utf-8 |
| max_lines | No | Maximum JSON lines to emit. | |
| break_words | No | Break words longer than the width. | |
| show_encoding | No | Include encoding detection metadata in JSON result. | |
| encoding_errors | No | How to handle encoding errors (default: replace). | replace |
| encoding_profile | No | Locale-aware encoding fallback profile for auto-detection. |