This extension integrates the keepsorted CLI with Visual Studio Code.
It formats and checks structured lists so your files stay consistently ordered while comments remain attached to their items.
Requirements
Install the keepsorted command line tool.
If you have Rust installed this can be done with:
cargo install keepsorted
Prebuilt binaries are also available from the project releases.
Why use it?
Keep diffs small and easy to review
Maintain consistent ordering without losing comments
Fix only the lines you select or the whole workspace
Commands
Keepsorted: Check Selection — checks selected lines for unsorted items
Keepsorted: Check Document — checks the current file
Keepsorted: Check Workspace — checks the entire workspace
Keepsorted: Format Selection — sorts selected lines
Keepsorted: Format Document — sorts the current file
Keepsorted: Format Workspace — formats files in a workspace
Keepsorted: Clear All Issues — clears diagnostics
Keepsorted: Fix All Issues — fixes all files with reported problems
Keepsorted: Show Info — shows extension and CLI information
Settings
Setting
Default
Description
keepsorted.enable
true
Enable or disable the extension
keepsorted.fileListSource
git
Source of files for scans: all, git, git-modified
keepsorted.onOpen
file
What to scan when a file is opened: off, file, directory
keepsorted.fixOnSave
false
Run keepsorted --fix on a file when it is saved
keepsorted.openProblems
false
Open the Problems panel automatically after a scan
keepsorted.path
keepsorted
Path or command to the CLI executable
keepsorted.features
[]
Experimental features passed as --features to the CLI
keepsorted.extraArgs
[]
Extra CLI arguments applied to every invocation
keepsorted.diffCommand
""
Optional custom diff command that must output unified diff
Build and Install
npm ci # installs dependencies and compiles the extension
npm test
npm run build
The build step creates a .vsix package in the repository root.
In VS Code run Extensions: Install from VSIX... and select that file to install the extension locally.