A VS Code extension that formats SQL using a right-aligned "river" keyword style, with recursive alignment for subqueries.
SELECT A.COL1,
A.COL2
FROM TABLE_A A
INNER JOIN TABLE_B B ON (A.ID = B.ID)
WHERE A.STATUS = 'ACTIVE'
ORDER BY A.COL1 ASC;
Features
- SELECT — joins, correlated/derived subqueries,
CASE, window functions (OVER/PARTITION BY/ORDER BY),UNION/UNION ALL/MINUS/INTERSECT/EXCEPT,GROUP BY/HAVING/QUALIFY/ORDER BY. - INSERT — single-row and multi-row
VALUES,INSERT ... SELECT, with a hanging-paren wrap for long column/value lists. - UPDATE, DELETE.
- MERGE —
USING/ON/WHEN ... THENwithUPDATE SET(aligned=signs),DELETE, andINSERT/VALUESactions. - WITH / CTEs — single or multiple CTEs (including
WITH RECURSIVE), followed by any supported statement. - Case-normalizes reserved keywords to uppercase; identifiers and string literals are left exactly as written.
Usage
- Format Document: click the format icon in the editor toolbar, or run the command "Format SQL (River Style)" from the Command Palette.
- Format Selection: select some SQL, right-click, and choose "Format SQL Selection".
- Minify Selection: select some SQL, right-click, and choose "Minify SQL Selection (Single Line)" to collapse it down to one line per statement — the inverse of formatting, handy for pasting a query into a one-liner script or log. Works on both formatted and unformatted input; comments are dropped.
- Minify Document: run "Minify SQL Document (Single Line)" from the Command Palette to do the same for the whole file.
- Applies to files recognized as the
sqllanguage, including.sql,.dml, and.ddlfiles.
Configuration
| Setting | Default | Description |
|---|---|---|
sqlFormatter.maxLineLength |
100 |
Maximum line length before length-triggered lists (GROUP BY/ORDER BY columns, INSERT column/VALUES lists, PARTITION BY/ORDER BY in window functions) wrap one item per line. |