Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Jbuilder Visual AlignNew to Visual Studio Code? Get it now.
Jbuilder Visual Align

Jbuilder Visual Align

Shootingfly

|
1 install
| (0) | Free
Visual-only alignment for Ruby on Rails and Crystal Jbuilder templates. Align json.field values without changing files.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Jbuilder Visual Align

Visually align json.field values in Ruby on Rails and Crystal .jbuilder templates, without changing source text, copied text, saved files or version-control diffs. Keep your existing language mode and language extensions.

English instructions are followed by 简体中文 below.

Source:

json.id user.id
json.nickname user.nickname
json.avatar_url user.avatar_url

Editor display:

json.id         user.id
json.nickname   user.nickname
json.avatar_url user.avatar_url

Usage

Install Jbuilder Visual Align and open a .jbuilder file. Alignment is automatic. Run Jbuilder: Toggle Visual Alignment from the command palette, or click the status-bar toggle. The toggle is remembered per workspace.

Consecutive fields with the same indentation form a group. Blank lines, comments, control flow and structure calls split groups. Nested fields and tab indentation are supported. json.array!, json.partial!, block headers and common multiline literals are excluded. No formatter is registered and no source edits are performed.

Settings

Setting Default Purpose
jbuilderVisualAlign.fileExtensions [".jbuilder"] File suffixes to enable
jbuilderVisualAlign.maxPadding 80 Skip groups exceeding this padding; 0 means unlimited
jbuilderVisualAlign.debounceMs 0 Delay decoration updates after edits; opening and switching remain immediate
jbuilderVisualAlign.showStatusBar true Show the toggle

Use a monospaced font. Text selection follows the original source; dragging across virtual padding can feel different, so toggle alignment off when needed.

Performance and limitations

Models are prepared when documents open and cached for editor navigation. Ordinary value edits scan changed lines without rereading or regrouping the entire document, and do not resend identical decorations. Replacing an anchor range, including whole-document replacement and undo, restores decorations.

Editor decorations arrive asynchronously: a cold start or first open may briefly show the original spacing. The extension cannot guarantee alignment before the editor's first frame.

This is a lightweight lexical guard, not a full Ruby or Crystal parser. Parenthesized calls and dynamic field names are not expanded, multiple statements are not split, and unusual literal syntax or macros may require disabling alignment for that file type. Tested in Qoder CN; designed for Visual Studio Code 1.90 or later and compatible desktop editors.

Privacy

No network requests, telemetry, external commands or runtime dependencies. The extension reads open documents to calculate display decorations; it does not edit or save them. It works in untrusted and virtual workspaces.

Development

Run npm ci, npm test and npm run check. Build an installable package with npm run package. Native editor integration tests are in test/host.js and use a disposable fixture; a real template can optionally be opened read-only via JBUILDER_ALIGN_REAL_TEMPLATE.

Licensed under the MIT license; see the included LICENSE file.


Jbuilder Visual Align

在 Visual Studio Code(微软代码编辑器)及兼容编辑器中,将 .jbuilder 模板的 json.字段 参数 按列对齐显示。文件中的空白、复制得到的文本和版本差异保持原样;无需更换语言模式。

实际文件:

json.id user.id
json.nickname user.nickname
json.avatar_url user.avatar_url

显示效果:

json.id         user.id
json.nickname   user.nickname
json.avatar_url user.avatar_url

打开模板后自动生效,编辑时自动更新。点击状态栏的“Jbuilder 对齐开/关”,或从命令面板运行“Jbuilder: 切换视觉对齐”。开关按工作区保存。

0.2.0 提前启动并在文档打开时预计算,切换文件复用缓存。普通值编辑只重新扫描受影响的行,不重新读取整个文件、不重复提交相同装饰;视觉间距固定在字段后的空白上,减少输入时的位置跳动。字段名、行数或多行字面量发生变化时才重新计算受影响的布局。

原生编辑器通过异步消息接收扩展装饰,没有供普通扩展在首次绘制前阻塞画面的入口,因此冷启动或首次打开文件仍不能保证绝对无闪动。这里不会通过隐藏文本或临时改写文档掩盖这个限制。

连续、同缩进的普通字段调用构成一组。空行、注释、控制语句、结构调用会切断分组。支持制表符缩进和嵌套字段;跳过 json.array!、json.partial!、json.xxx do、多行字符串、常用百分号字面量和文档字符串中的伪代码。不展开括号调用或动态字段名;同一行多个语句不会拆分对齐。

设置:

设置 默认值 用途
jbuilderVisualAlign.fileExtensions [".jbuilder"] 启用的文件后缀
jbuilderVisualAlign.maxPadding 80 最大补齐宽度,超过则跳过整组;0 不限
jbuilderVisualAlign.debounceMs 0 编辑后的装饰提交等待时间,默认立即更新;打开和切换文件始终不延迟
jbuilderVisualAlign.showStatusBar true 显示开关

以等宽字体使用。视觉空白由编辑器装饰绘制,鼠标拖选经过补齐位置时可能不如原始文本直观,可暂时关闭对齐;键盘选择与文件内容不受影响。这里的词法保护并非完整语言解析器,复杂宏和罕见多行字面量不保证识别。

扩展不注册格式化器,不执行外部命令、不联网、不收集遥测,也不调用文档编辑或保存方法。

开发验证:npm test、npm run check。打包:npm install 后执行 npm run package,从扩展面板的“从 VSIX(Visual Studio Code Extension,编辑器扩展安装包)安装”选择 dist/ 中的安装包。

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft