Sort selected lines by length. Align PHP-style key => value arrays.
No settings. No dependencies. Selection-only.
Features
Longest → Shortest: sort selected lines by trim().length, descending.
Shortest → Longest: sort selected lines by trim().length, ascending.
Align Array =>: pad keys so => arrows line up. Indentation preserved. Lines without => pass through untouched.
Usage
Highlight lines in editor.
Right-click → Simple Line Sorter submenu (visible only with active selection).
Pick command. Or open Command Palette (Ctrl+Shift+P) and search title.
Command ID (declared)
Title
Status
simple-line-sorter.sortLongToShort
Longest → Shortest
works
simple-line-sorter.sortShortToLong
Shortest → Longest
works
simple-line-sorter.alignArray
Align Array =>
broken, see Known Issues
Empty selection → info message, no-op. Align with zero => lines → No key => value pair found., no-op.
Examples
Sort longest → shortest (length measured after trim()):
# before
a
abcd
ab
# after
abcd
ab
a
Align =>:
// before
$name => 'A',
$longer_key => 'B',
id => 3,
// after
$name => 'A',
$longer_key => 'B',
id => 3,
Requirements
VS Code ^1.125.0. No other requirements.
Known Issues
Align Array menu entry broken.package.json declares line-sorter.alignArray, but src/extension.ts registers simple-line-sorter.alignArray. IDs must match. Submenu item does nothing until unified. Sort commands unaffected.
CRLF normalized to LF. Split on /\r?\n/, rejoin with '\n'.
Length = trim().length. Leading/trailing whitespace ignored for ordering, but kept in output.
In-place Array.sort. Stable in modern V8, but equal-length order should not be relied on.