Opinionated Vue SFC formatter for <template> blocks.
Vuenify focuses on deterministic attribute formatting inside Vue Single File Components:
- Sort static
classattributes - Normalize Vue directives (
v-bind,v-on,v-slot) - Order directives by priority
- Order attributes (value first, then boolean)
- Group Vue directives before static attributes when both ordering features are enabled
- Stable, idempotent formatting
- Safe SFC offset handling (script/style untouched)
It formats only the structure of attributes and directives inside <template>.
It does not:
- Format JavaScript
- Format CSS
- Re-indent markup
- Replace your general-purpose formatter
Vuenify can be used in three ways:
- 🔧 As a Source Action (runs on save after formatting)
- 🧩 As the default Vue formatter
▶️ Manually via command palette commands
Sort static class attributes alphabetically and optionally remove duplicates.
Before
<div class="b a b c"></div>After
<div class="a b c"></div>Controlled by:
vuenify.classes.sortvuenify.classes.removeDuplicatesvuenify.classes.layout
Convert between long and shorthand forms:
v-bind:foo↔:foov-on:click↔@clickv-slot:header↔#header
Before
<div v-bind:foo="bar" v-on:click="handle"></div>After (short mode)
<div :foo="bar" @click="handle"></div>Supports:
- Modifiers (
.stop,.prevent,.camel) - Dynamic arguments (
v-bind:[foo]) - Same-name bindings (
:src="src")
Controlled by:
vuenify.directives.normalizevuenify.directives.stylevuenify.directives.sameName
Directives are ordered by configurable priority.
Default priority
["if", "else", "else-if", "for", "on", "model", "bind"]Before
<div v-bind="a" v-if="visible" v-model="value"></div>After
<div v-if="visible" v-model="value" v-bind="a"></div>Unknown directives are sorted alphabetically after prioritized ones.
When both directive ordering and attribute ordering are enabled, Vue directives are grouped before static attributes.
Before
<button v-if="visible" disabled v-bind:title="label"></button>After
<button v-if="visible" v-bind:title="label" disabled></button>Controlled by:
vuenify.order.directivesvuenify.order.directivePriority
Non-directive attributes can be sorted:
- Attributes with values first
- Boolean attributes after
- Alphabetical within groups
Before
<input disabled type="text" id="field" />After
<input id="field" type="text" disabled />When both vuenify.order.directives and vuenify.order.attributes are enabled, Vuenify applies a deterministic group order:
- Vue directives, ordered by directive priority
- Static attributes with values, sorted alphabetically
- Boolean attributes, sorted alphabetically
Before
<button v-if="visible" v-on:click="submit" disabled v-bind:title="label"></button>After
<button v-if="visible" v-on:click="submit" v-bind:title="label" disabled></button>Controlled by:
vuenify.order.attributesvuenify.order.layout
Opening tags are fully rebuilt to guarantee:
- Deterministic output
- Idempotent formatting
- No partial rewrites
- Stable directive and attribute grouping
- Stable ordering
Script and style blocks are never modified.
You can configure Vuenify either:
- via the Settings UI (search for “Vuenify”), or
- in
settings.json(recommended when you want to copy/paste configs)
Run Vuenify as a structural pass on save.
"[vue]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.vuenify": "always"
}
}This works independently of whichever formatter you use.
If another formatter is configured, it runs first. Vuenify runs afterwards as a structural normalization step.
Let Vuenify handle Vue formatting directly:
"[vue]": {
"editor.defaultFormatter": "zwe1ch.vuenify",
"editor.formatOnSave": true
}Available in the Command Palette:
- Vuenify: Sort Classes
- Vuenify: Normalize Directives
- Vuenify: Order Attributes & Directives
All settings are defined under the Vuenify namespace.
Type: boolean
Default: true
Sort static class attributes alphabetically.
Type: boolean
Default: true
Remove duplicate class names.
Type: "inline" | "preserve"
Default: "inline"
Controls how class attribute whitespace is handled.
inline→ Always rebuild as single-line class attributepreserve→ Keep original internal whitespace
Type: boolean
Default: true
Normalize supported Vue directives.
Type: "short" | "long"
Default: "short"
Directive style to use when normalizing.
short→:foo,@clicklong→v-bind:foo,v-on:click
Type: "ignore" | "removeValue" | "addValue"
Default: "ignore"
Controls handling of same-name bindings:
<img :src="src" />Options:
ignoreremoveValue→:srcaddValue→v-bind:src="src"
Type: boolean
Default: true
Enable directive ordering.
When this and vuenify.order.attributes are both enabled, directives are grouped before static attributes.
Type: string[]
Default:
["if", "else", "else-if", "for", "on", "model", "bind"]Custom priority order for Vue directives.
Unknown directives are placed after prioritized directives and sorted alphabetically.
Type: boolean
Default: true
Sort non-directive attributes.
Attributes are ordered as:
- Attributes with values
- Boolean attributes
Attributes are sorted alphabetically within each group.
When this and vuenify.order.directives are both enabled, static attributes are placed after Vue directives.
Type: "inline" | "preserve"
Default: "inline"
Controls whitespace handling when attributes are reordered.
inline→ All attributes rebuilt into a single linepreserve→ Preserve existing line breaks
- Deterministic output
- Idempotent formatting
- No partial attribute rewrites
- Safe SFC parsing via
@vue/compiler-sfc - Stable directive and attribute grouping
- Stable sorting behavior
- Script & style blocks untouched
MIT