CFML Code Auto-Formatting Extension for VS Code. This extension is specialized in automatic tag wrapping and indent formatting, without making unnecessary code style changes.
- CFML (.cfc) automatic indent formatting (stable operation)
- Since it's implemented with JS and TS, you don't need to set up any Lucce or ColdFusion environment.
- Automatic tag wrapping
- Partial formatting by block tags
- Preserves original code style
- Supports manual execution & automatic formatting on save
- It supports block content and allows selecting the content to be formatted, making it easier to manage the scope.
- Install the extension.
- Open a CFML file (
.cfmor.cfc). - Right-click and select Format Code (satt).
- Choose from the available formatting options:
- CFTag Syntax: Formats CFML tags (e.g.,
<cfquery xxx>XXX</cfquery>). If no content is selected, formats the entire CFC file. - Script Syntax: Formats content within
<cfscript>blocks. Can also format embedded JavaScript. - SQL Syntax: Formats SQL content.
- HTML Syntax: Formats HTML tag content within
.cfmfiles. - CSS Syntax: Formats CSS content within
.cfmfiles.
- CFTag Syntax: Formats CFML tags (e.g.,
.cfcfile formatting operates stably.cfmfiles may have formatting issues → planned to improve in the future- SQL statements should avoid leading commas why?
- When formatting after focusing on the opening tag, the closing tag may be automatically added. This is an issue caused by another plugin (e.g. Auto Close Tag).
- SQL formatting is first done using sql-formatter.
However, if it includes something particularly complex such as
cfloop, my own custom logic is applied. - The formatting of
cfscriptis very similar to JavaScript. If the string contains SQL statements, XML, or HTML tags, tags may break, so it’s better not to use it. - Automatic tag wrapping is useful when a tag has many attributes, but short inline tags may also get wrapped.
- I have already tried using Lucee’s AST methods
astFromString()andastFromPath(), but I couldn’t get detailed information from them. Below is the execution result I obtained, and I’m still experimenting with this.See issue
| 2.1 CFTag Syntax | 2.2 Script Syntax |
|---|---|
![]() |
![]() |
| Setting | Default Value | Type | Description |
|---|---|---|---|
hri.cfml.formatter.indentWithTabs |
true |
boolean | Use tabs instead of spaces for indentation. |
hri.cfml.formatter.indentSize |
4 |
number | Number of spaces when indenting with spaces (1–10). |
hri.cfml.formatter.indentChar |
" " |
string | Indent character: space " " or \t. Overridden by indentWithTabs. |
hri.cfml.formatter.wrapLineLength |
0 |
number | Wrap lines after this many characters. 0 means no limit. |
hri.cfml.formatter.maxPreserveNewlines |
2 |
number | Maximum number of consecutive newlines to preserve (0–10). |
hri.cfml.formatter.preserveNewlines |
true |
boolean | Whether to preserve existing newlines. |
hri.cfml.formatter.keepArrayIndentation |
false |
boolean | Whether to preserve original array indentation. |
hri.cfml.formatter.braceStyle |
"collapse" |
string | Brace style: collapse / expand / end-expand / none. |
hri.cfml.formatter.breakChainedMethods |
false |
boolean | Whether to break chained methods into multiple lines. |
hri.cfml.formatter.spaceBeforeConditional |
true |
boolean | Whether to add a space before conditionals (if, while, for). |
hri.cfml.formatter.endWithNewline |
false |
boolean | Whether to add a newline at the end of the file. |
hri.cfml.formatter.expressionWidth |
30 |
number | Wrap lines when the SQL string length exceeds this value. |
hri.cfml.formatter.sqlLanguage |
"mysql" |
string | Select SQL dialect for formatting. |
💡 How to Change Settings
Press Ctrl + , in VSCode and enter "Format Code (satt)" in the search box to make changes.
After modifying, don’t forget to reload the window!
VS Code 用 CFML コード自動整形拡張機能。
この拡張機能は タグの自動改行、インデント整形に特化 しており、余計なコードスタイルの変更は行いません。
- CFML (.cfc) コードの自動インデント整形(安定動作)
- タグの自動改行
- ブロックタグごとで部分的にフォーマット
- 元のコードスタイルを保持
- 手動実行 & 保存時自動整形に対応
- JSとTSで実装されているため、LucceやColdFusion環境を構築する必要はありません。
- ブロック単位での内容に対応し、整形対象を選択できるため、範囲を管理しやすくなります。
- 拡張機能をインストール
- CFML ファイルを開く(
.cfmまたは.cfc) - ショートカット Shift + Alt + M または右クリックで Format Code (satt) を選択
- 利用可能なフォーマットオプションから選択:
- CFTag 構文: CFML タグをフォーマットします(例:
<cfquery xxx>XXX</cfquery>)。選択がない場合は CFC ファイル全体をフォーマットします。 - Script 構文:
<cfscript>ブロック内のコンテンツをフォーマットします。埋め込まれた JavaScript もフォーマット可能です。 - SQL 構文: Formats SQL content 。
- HTML 構文:
.cfmファイル内の HTML タグコンテンツをフォーマットします。 - CSS 構文:
.cfmファイル内の CSS コンテンツをフォーマットします。
- CFTag 構文: CFML タグをフォーマットします(例:
.cfcファイルの整形は安定動作.cfmファイルは整形が乱れる場合あり → 今後改善予定- SQL文はカンマ前置をしないように 何故?
- 開始タグにフォーカスしてからフォーマットすると、自動で閉じタグが追加されてしまう場合がある。これは他のプラグインの問題である。例: (Auto Close Tag)
- SQL のフォーマットは、まず sql-formatter を使用します。ただし、
cfloopなど特に複雑なものを含む場合は、自作のロジックでフォーマットします。 cfscriptのフォーマットは、JavaScript と非常に似ています。 SQL 文や XML、HTML タグが含まれていると、タグが壊れることがあるので、使わないほうがいいです。- タグの自動改行は属性が多い場合に便利ですが、インラインで短いタグを使いたいケースでは改行されることがあります。
Details
| 設定項目 | デフォルト値 | 型 | 説明 |
|---|---|---|---|
hri.cfml.formatter.indentWithTabs |
true |
boolean | インデントにスペースではなくタブを使用する。 |
hri.cfml.formatter.indentSize |
4 |
number | スペースでインデントする場合のスペース数(1–10)。 |
hri.cfml.formatter.indentChar |
" " |
string | インデント文字:スペース " " または \t。indentWithTabs で上書きされる。 |
hri.cfml.formatter.wrapLineLength |
0 |
number | この文字数を超えると改行。0 は制限なし。 |
hri.cfml.formatter.maxPreserveNewlines |
2 |
number | 連続して保持する改行の最大数(0–10)。 |
hri.cfml.formatter.preserveNewlines |
true |
boolean | 既存の改行を保持するかどうか。 |
hri.cfml.formatter.keepArrayIndentation |
false |
boolean | 配列の元のインデントを保持するかどうか。 |
hri.cfml.formatter.braceStyle |
"collapse" |
string | 波括弧スタイル:collapse / expand / end-expand / none。 |
hri.cfml.formatter.breakChainedMethods |
false |
boolean | メソッドチェーンを複数行に分割するかどうか。 |
hri.cfml.formatter.spaceBeforeConditional |
true |
boolean | 条件文(if, while, for)の前にスペースを入れるか。 |
hri.cfml.formatter.endWithNewline |
false |
boolean | ファイル末尾に改行を追加するかどうか。 |
hri.cfml.formatter.expressionWidth |
30 |
number | sql指定文字列長さを超えると改行 |
hri.cfml.formatter.sqlLanguage |
"mysql" |
string | フォーマットSQLを選ぶ |
💡 設定変更方法
VSCode で Ctrl + , を押し、検索欄に 「Format Code (satt)」 と入力すると変更可能。変更があったら、再起動みたいな操作でウィンドウをリロードするのを忘れないでね



