dbt Power User (VS Code Extension)
dbt Power User is a VS Code Extension to make VS Code work seamlessly with dbt.
The Extension has many features, including a sqlfmt-powered formatter.
sqlfmt must be available on the PATH in order to be accessed by dbt Power User. Install sqlfmt with pipx
to isolate its dependencies and add it to the PATH.
After installing sqlfmt and the dbt Power User extension:
Associate your
.sql
files with thejinja-sql
language. Select Preferences > Settings, and under Files: Associations click Add Item:Alternatively, add the following to your VS Code
settings.json
:settings.json"files.associations": {
"*.sql": "jinja-sql"
},Select "dbt Power User" (extension
id:innoverio.vscode-dbt-power-user
) as the default formatter. You can do this either by using the context menu (right click on an open dbt model in the editor) and select "Format Document With...", or you can add the following to your VS Code settings:settings.json"[jinja-sql]": {
"editor.defaultFormatter": "innoverio.vscode-dbt-power-user"
}You can enable format on save by adding another line to your VS Code settings:
settings.json"[jinja-sql]": {
"editor.defaultFormatter": "innoverio.vscode-dbt-power-user",
"editor.formatOnSave": true
}