02.7Columns

Column aligner

Line up assignments, key–value pairs and lists on any delimiter, or tidy a Markdown table so its pipes line up. Widths are measured the way editors and terminals draw text, so Chinese, Japanese and Korean characters and emoji count as two columns.

Options

Split at
Delimiter goes

Aligned

name                     = TabMender
tagline                  = Tabs, spaces & whitespace fixer
都市                     = 東京
emoji_ok                 = 🎉
max_line_length          = 100
# comments without the delimiter stay put
trim_trailing_whitespace = true

Aligned 6 lines into 2 columns. Lines without the delimiter are left as they are.

Using the aligner

  • Delimiter: what separates the columns. Equals and colon split at the first one by default, for key = value lines; pipes, commas and tabs split at every one.
  • In its own column pads the text before the delimiter (name   = x). Right after the text keeps it attached and pads after it (name:   x), the usual style for YAML-like lists and CSV.
  • Runs of 2+ spaces re-aligns text that was lined up by hand, keeping single spaces inside a cell. Any whitespace splits like column -t.
  • Indentation is kept, and the columns line up across lines with different indentation.

Each character is measured by its display width: CJK ideographs, kana, Hangul and full-width forms take two columns, emoji (including sequences joined with ZWJ) two, and combining accents none. That is what keeps a table with 東京 in it straight in a terminal, a code editor and GitHub’s source view.

Questions

Why does my aligned text look crooked in some apps?

Alignment needs a monospaced font. In proportional fonts, or fonts that draw CJK characters at some other width, no amount of padding lines up.

Can I align on something longer than one character?

Yes. Choose Custom and type any text, such as => or --, and the lines are split on it.

Is my text uploaded?

No. Alignment happens in your browser.