Editing in Vim
A vim plugin is provided to apply syntax highlighting and account autocomplete when editing. Install the vim-ledger plugin.
Below is the result of :set filetype=ledger in vim.

The plugin can also do folding, try :set foldmethod=syntax

Format on Save
In order to format on save, set your vim config to the following:
let g:ledger_autofmt_bufwritepre = 1