If you edit your journals (and other hledger data files) with a text editor, you want that frequent task to be as pleasant and non-tedious as possible. So it’s worth using a powerful editor - one with comfortable copy/paste, search & replace, and perhaps more advanced features like macros.
Also, for most editors there are helper modes which can make editing hledger journal files much more convenient. These provide things like syntactic highlighting, auto indentation, and tab completion of account names. You can find the latest modes at:
hledger-mode, hledger-vim, hledger-vscode etc. are designed specifically for hledger. Modes with “ledger” in their name, such as ledger-mode, vim-ledger etc., can also work well for hledger journals.
https://github.com/ledger/ledger-mode (manual), for Emacs, is the most used and maintained helper mode for h/ledger files. Use M-x customize to browse ledger-mode’s settings and change them as seems wise.
ledger-binary-path to hledger
(unless your hledger journal is ledger-compatible and you also have ledger installed).
A typical cause of incompatibility is when ledger-mode tries to call the “ledger” binary with a command or arguments that hledger doesn’t support. In this case you can
open an ledger-mode issue, asking, suggesting how, and/or providing a pull request to make it more hledger-compatible (best)
do something locally to keep ledger-mode happy, eg define a small add-on command mimicking the required ledger command.
ledger-display-balance-at-point (C-c C-p) runs
ledger cleared ACCT.
hledger doesn’t have a “cleared” command, so you could make it by
hledger-cleared.sh in $PATH:
#!/bin/sh hledger balance -N "$@" # or add -C, or whatever you like
#367 ledger-mode setup for hledger needs documenting has more discussion and tips, which should be collected here.
To toggle a transaction’s cleared status: move point to it, C-c C-e. To toggle just a posting’s status: move point to it, C-c C-c.
Ledger entries can be embedded in a org file and manipulated using Babel. See eg Using Ledger for Accounting in Org-mode with Babel
A helper to browse TODO tags in the journal:
(defun journal-todos nil (interactive) (lgrep "TODO:" "current.journal" "~/finance" nil))
General editing tips¶
From the mail list, somebody’s trick for alignment: “Space-indent the account, tab-indent the amount, set a large tab stop.”