Aligns text prefixes before '=' for consistent formatting.
A utility to adjust text lines by padding spaces before = based on the longest prefix.
align-equal
This project is based on an idea from Gabriella Gonzalez.
For more details, visit: Gabriella's blog
align-equal is a command-line tool that aligns text based on the = symbol.
It ensures that all = signs are vertically aligned, improving readability.
This program reads text from standard input, processes it, and outputs the aligned result to standard output.
Installation
To install align-equal using cabal, run:
cabal install align-equal
Usage
Using in Vim
align-equal is primarily designed for use within Vim. You can align selected text in visual mode as follows:
- Select the lines you want to align in visual mode (
Vfor line-wise selection). - Run:
:!align-equal - The selected text will be replaced with an aligned version.
Example
Before (Selected Text in Visual Mode):
x = 1
longVariable = 2
short = 3
Command:
:!align-equal
After:
x = 1
longVariable = 2
short = 3
How it Works
align-equal scans the input, detects = symbols, and aligns them by adding the appropriate amount of whitespace.