An opinionated formatter that gets your .sql and .txt (Yardi) files to look clean: UPPERCASE keywords, clean indentation, optional AS alignment, and block‑style comments.
Powered by Poor Man's T-SQL Formatter with custom house-style post-processing for the perfect balance of readability and consistency.
- Install from Marketplace 👉 A Better SQL Stylist on Visual Studio Marketplace
Or, if you prefer, clone and build locally:
git clone https://github.com/MessiDaGod/SqlFormatterExtension.git
cd SqlFormatterExtension
npm i
npm run compile- Run in VS Code
- Open this folder in VS Code.
- Press
F5(Run → Start Debugging) to launch an Extension Development Host. - Open any
.sqlor.txtfile and run Format Document (or select text and run Format Selection).
- Make it your default SQL formatter
- In the Extension Host window: Command Palette →
Preferences: Open Settings (JSON)and add:
{
"[sql]": {
"editor.defaultFormatter": "shakely-consulting.better-sql-stylist",
"editor.formatOnSave": true
},
"sqlStylist.convertLineCommentsToBlock": true,
"sqlStylist.alignAs": false
}- Package to VSIX (optional)
npm run package
# then install the .vsix in VS Code (Extensions → … → Install from VSIX)- Poor Man's T-SQL Formatter engine — Battle-tested T-SQL formatting with extensive dialect support
- UPPERCASE SQL keywords — Makes SQL more readable
- Optional AS alignment — Align
ASkeywords in SELECT lists - Block‑style comment conversion — Convert
--to/* ... */ - JOIN alignment and indentation — Clean, consistent JOIN formatting
- WHERE / HAVING first predicate inline — Compact, readable predicates
- Selection formatting — Format only selected text or entire document
- Yardi .txt file support — Special handling for Yardi SQL files
- Dual engine support — Choose between Poor Man's T-SQL (default) or built-in house formatter
When working with Yardi .txt files, the formatter intelligently preserves special Yardi syntax:
- Ignores lines starting with
//— Lines like//Select,//Detail,//End Selectare preserved exactly as-is - Ignores
//FILTERblocks — Everything between//FILTERand//END FILTERis preserved (case-insensitive) - Ignores
//FORMATblocks — Everything between//FORMATand//END FORMATis preserved (case-insensitive) - Formats the SQL between special markers — Only the actual SQL code gets formatted
Example Yardi file:
//Select
SELECT * FROM Users
//FORMAT
badly formatted SQL that stays this way
//END FORMAT
SELECT
FirstName,
LastName
FROM Employees
//FILTER
preserve this exactly
//END FILTER
WHERE Active = 1
//End SelectAfter formatting, the //FORMAT and //FILTER blocks remain untouched, while the rest gets formatted cleanly.
sqlStylist.engine—pmtsql | house— choose formatter engine (default:pmtsql)pmtsql(default) — Uses Poor Man's T-SQL Formatter for robust T-SQL formattinghouse— Uses sql-formatter library with custom rules
sqlStylist.postProcessHouse— Apply house-style cleanup after pmtsql formatting (default:true)sqlStylist.keywordCase—upper | lower | preserve(default:upper)sqlStylist.tabWidth— spaces per indent (default:4)sqlStylist.linesBetweenQueries— blank lines between queries (default:2)sqlStylist.convertLineCommentsToBlock— turn--comment-only lines into/* ... */(default:true)sqlStylist.alignAs— pad spaces to alignASin SELECT lists (default:false)sqlStylist.commaBeforeColumn— use leading commas in SELECT lists (default:false)sqlStylist.oneLineFunctionArgs— collapse common function args to single line (default:true)
- Open a
.sqlor.txtfile - Right-click → Format Document
- Or use the keyboard shortcut (usually
Shift+Alt+Fon Windows/Linux,Shift+Option+Fon Mac)
- Select the SQL code you want to format
- Right-click → Format Selection
- Or use Format Document while text is selected
- Uses Poor Man's T-SQL Formatter by default for battle-tested T-SQL formatting.
- Alternative
houseengine usessql-formatterwith thetransactsqldialect. alignAsis a simple text pass that works best when the formatter has put one select item per line.- Comment conversion only targets comment-only lines. Inline
--after code are left as-is. - Yardi special blocks (
//FILTER,//FORMAT) are case-insensitive.
To publish a new version to the marketplace:
# Update version in package.json, then:
npm run publish
# or
node install.js publishAGPL-3.0-only © Shakely Consulting
- See logs in View → Output → Better SQL Stylist.
- Use
npm run watchduring development for auto-compilation - Run
npm run ext:reinstallto test changes locally