How does it work?
This tool aligns carets or selections into a vertical line by inserting spaces. It's useful for formatting code or text to improve readability and visual alignment.
The alignment follows these rules:
- Each line is processed separately
- The tool looks for a special marker (default: |) that represents the caret position
- It finds the line with the rightmost caret position
- It adds spaces to all other lines to align their carets with the rightmost one
- Lines without a caret marker are left unchanged
- You can choose to keep or remove the caret markers in the output
Example
Consider this code with caret markers (|) at different positions:
var x| = 10;
const longVariableName| = "hello";
let y| = true;
const anotherVar| = 42;After aligning the carets (with markers preserved):
var x | = 10;
const longVariableName| = "hello";
let y | = true;
const anotherVar | = 42;After aligning the carets (with markers removed):
var x = 10;
const longVariableName = "hello";
let y = true;
const anotherVar = 42;Parameters
- Text with carets: The input text containing caret markers to align
- Caret marker: The character or string that represents the caret position (default: |)
- Preserve caret markers: Option to keep or remove the caret markers in the output
This tool is useful for:
- Aligning variable assignments in code
- Creating neatly formatted tables or columns
- Aligning comments in code
- Formatting data for better readability
- Preparing text for presentations or documentation
Common Use Cases
Aligning Variable Assignments
Before:
var x = 10;
const longVariableName = "hello";
let y = true;
const anotherVar = 42;After (with = as the marker):
var x = 10;
const longVariableName = "hello";
let y = true;
const anotherVar = 42;Tip:
You can use any character or short string as the caret marker. Common choices include "|", "=", "//", or even a unique sequence like "###" that doesn't appear elsewhere in your text.
Related Tools
- Align Left - Align text to the left margin
- Align Right - Align text to the right margin
- Align Center - Center text between margins
- Format to Columns - Arrange text into columns
- Create Border - Add borders around text
All Tools
See all available tools