
A VS Code extension to make editing hledger journal files a bit more fun.
HLedger is an awesome plain text cli accounting tool. This extension adds syntax highlighting, formatting, sorting, and other quality-of-life improvements to make editing these files easier.

Features
- Automatically aligns account names and amounts in hledger journal files
- Autocomplete suggestions based on your account types
- Balancing amount suggestions, press tab to automatically add the balanced amount (
$100 -> -$100)
- Rich syntax highlighting with hierarchical account coloring
- Sort journal entries by date (
Shift+Cmd+S)
- Handles all supported comment styles (
;, #, *, and comment blocks) for formatting and toggling
- Format on save / Sort on save options (disabled by default)
- Toggle comment lines (
Cmd+/)
- Create new monthly journal files (
Cmd+N)
- Matches HLedger defaults, but highly configurable to your preference (See VSCode settings under "HLedger")
Demo
Syntax Highlighting (details)
Rich syntax highlighting with hierarchical account coloring and project tags:

Aligns amounts to a configurable column position for clean, readable journal files:

Sort by Date
Automatically sorts transactions chronologically:

Autocomplete / Balancing Suggestions
Intelligent suggestions for both the standard categories and your own, and a suggestion for balancing amounts. For more info see AUTOCOMPLETE.md.

Supported File Types
.journal
.hledger
.ledger
Usage
- Open a hledger journal file
- Use one of these methods to format:
- Press
Shift+Alt+F to format the entire document
- Save the file (if format on save is enabled)
- Right-click and select "Format hledger Journal" from the context menu
- Additional commands:
- Press
Shift+Cmd+S to sort entries by date
- Press
Cmd+/ to toggle comments on selected lines
- Press
Cmd+N to create a new monthly journal file
Extension Settings
This extension contributes the following settings:
hledger-formatter.formatOnSave: Enable/disable formatting on save (default: false)
hledger-formatter.sortOnSave: Enable/disable sorting entries by date on save (default: false)
hledger-formatter.amountColumnPosition: Column position for aligning amounts when using fixed column mode (default: 42, range: 20-100)
hledger-formatter.amountAlignment: Choose between a fixed column or per-transaction widest alignment (default: widest)
hledger-formatter.indentationWidth: Posting indentation width in spaces (default: 4)
hledger-formatter.negativeCommodityStyle: Render negatives as -$ or $- (default: $-)
hledger-formatter.dateFormat: Preferred transaction date layout (YYYY-MM-DD, YYYY/MM/DD, YYYY.MM.DD)
hledger-formatter.commentCharacter: Default character used when toggling comments (;, #, or *; default: ;)
Autocomplete / Suggestions
hledger-formatter.suggestBalancingAmounts: Enable/disable inline ghost text suggestions for balancing amounts (default: true)
hledger-formatter.defaultAccountCategories: Include standard account categories in autocomplete (options: none, lowercase, uppercase, capitalize; default: lowercase)
Example
Before formatting:
2023-01-05 Grocery Store
expenses:food $85.50
assets:bank:checking $-85.50
2023-01-10 Coffee Shop
expenses:dining:coffee $4.75
assets:cash $-4.75
After formatting:
2023-01-05 Grocery Store
expenses:food $85.50
assets:bank:checking -$85.50
2023-01-10 Coffee Shop
expenses:dining:coffee $4.75
assets:cash -$4.75
Release Notes
See CHANGELOG.md for a full list of changes in each release.
Requirements
Contributing
This is an open source project and contributions are welcome! See CONTRIBUTING.md for detailed information on:
- Setting up your development environment
- Running tests and building the extension
- Submitting pull requests
Feel free to:
- Report bugs or request features via GitHub Issues
- Submit pull requests with improvements
- Share feedback and suggestions
Other Distributions
In addition to the VSCode Marketplace, this package is also available on the OpenVSX Registry: iiatlas/hledger-formatter.
Support
For help and support, see SUPPORT.md
License
MIT - see the LICENSE file for details