ledger-mode more Evil
evil-ledger package provides a minor mode for Emacs that adds Evil motions
and operators to
ledger-mode buffers. It allows you to treat transactions as
text objects while in
evil-mode -- selecting, deleting, and changing around
and inside them as a unit.
For example, given the transaction and cursor (indicated by
2000/01/01 * Landlord Expenses:Rent | $500.00 Assets::Chequing
vax selects the transaction around point and all whitespace up to the next
transaction. This makes for easy copying, moving, and deletion of transactions
as a whole, instead of by selecting a series of lines.
evil-ledger is available from MELPA.
evil-ledger-mode is a self-contained minor mode, so you can simply enable it
ledger-mode buffer to try it out, and disable it when you don't need it.
Using Transactions as Text Objects
ax to the visual and operator states for
selecting inside and around transactions, respectively. This means you can, for
- Select the transaction at point with
vix, and include surrounding whitespace with
- Delete the current transaction with
dax, or replace it with
evil-ledger-mode supports repeated invocations, so for example
the transaction at point, plus the next one as well, and so on.
Commands also support numerical prefixes, so
d3ax deletes the current and next
evil-ledger-mode also provides navigation aids
gk for jumping to
the next and previous transactions, respectively. Of course,
3gj will work as
Alignment and Sorting
evil-ledger-mode adds an
evil-ledger-align operator to visual state with the
=, so that, for example,
v3ax= will select the next three
transactions and align all postings in them.
There is also an
evil-ledger-sort operator that will sort transactions by date
ledger-sort-region), although it does not have a keybinding by
default. You can add one with
(evil-define-key* 'visual evil-ledger-mode-map "S" #'evil-ledger-sort)
or by setting
To make the minor mode start automatically in Ledger buffers, you can add it as a hook in your configuration, e.g.
(add-hook 'ledger-mode-hook #'evil-ledger-mode))
use-package users, the following is a sample configuration:
(use-package evil-ledger :ensure t :after ledger-mode :config (setq evil-ledger-sort-key "S") (add-hook 'ledger-mode-hook #'evil-ledger-mode))
All code is made available under the GPLv3, the same license as Emacs itself.