
Block Move: structural YAML and JSONC reordering
For developers who reorder YAML sequence items or JSON/JSONC array elements while preserving their attached text. Block Move moves the parsed structural block in the normal editor instead of changing individual lines manually.
日本語版
Demo media: no workflow GIF is published for Block Move yet.
Quick start
- Install with
ext install ShunsukeF.block-move and reload VS Code if prompted.
- Open a YAML, JSON, or JSONC file in a trusted workspace and place the cursor inside a supported block.
- Press
Alt+Up or Alt+Down, or run Block Move: Move Structural Block Up/Down.
Requirements, privacy, and support
- Requires VS Code 1.105.0 or later, is UI-hosted, and does not support untrusted workspaces.
- Commands and default shortcuts: move up/down with
Alt+Up and Alt+Down. It contributes no settings.
- Parsing and edits run locally. If the cursor is outside a supported structural block, VS Code's standard line-move command remains the fallback.
- Invalid input is not changed; unsupported structures and formatting remain normal source text for manual editing.
- Support and bug reports. License: MIT.
Move YAML sequence items and JSON/JSONC array blocks directly in the normal VS Code text editor. Comments and formatting stay attached to the text they describe, and the result remains a normal file with standard Undo and Git diff behavior.
Use it
- Place the cursor inside a YAML sequence item or JSON/JSONC array element.
- Press
Alt+Up or Alt+Down.
- Keep pressing to move the same structural block through its siblings.
The same operations are available from the Command Palette and editor context menu as Block Move: Move Structural Block Up and Block Move: Move Structural Block Down.
When the cursor is not inside a supported structural block, Block Move falls back to VS Code's standard line move behavior.
What stays safe
- YAML leading comments and inline comments move with their attached item when no blank line separates them.
- Blank-line-separated section comments remain at the original slot.
- Blank lines, indentation, quotes, line endings, and unrelated document text remain unchanged.
- JSON and JSONC commas are reassigned to the destination slots.
- Invalid input is never changed. The extension parses the result again before applying an edit.
- The smallest changed text range is applied as one Workspace Edit, so one Undo restores the previous order.
Supported scope
Block Move 0.1 targets array-like structures in text documents:
- YAML sequence items
- JSON array elements
- JSONC array elements
The editor remains the primary interface. Block Move does not open a Webview or convert the file into a different document model.
Privacy
All parsing and editing happen locally inside VS Code. No document content is sent to a remote service.
Build from source
bun install --frozen-lockfile
bun run build
bun test tests/block-move.test.ts
License
MIT