Pimping Your Editor

With a well setup auto-ingest system, the need for manually entering transactions reduces. In my personal case, since I do virtually no transactions by cash, I have no transactions that I enter manually. This means I need my editor primarily to correct or augment my auto-ingest system. For me, that boils down to these use cases:

  • change accounts in postings, or add new postings, typically in expense accounts
  • make minor corrections while browsing, typically in expense accounts
  • select lots to sell in investment accounts

This article is focused on vim, but really discusses the features you need, which you should be able to find or program in any advanced editor.

Vim and beancount

Although my expertise is in vim and is presented below, even if you are not a vim user, this section may help you figure out useful features that you can find solutions for in your editing environment.

I use the awesome vim-beancount plugin. I use these shortcuts:

let g:beancount_separator_col=70
au FileType beancount nnoremap <buffer> <leader>c vip:AlignCommodity<CR>
au FileType beancount nnoremap <buffer> <leader>g vip:GetContext<CR>

Autocompletion

Autocompletion of account names is the feature I most frequently use. Given that, I use this single, simple line in my .virmc to map it to Tab, which allows me to type e:g for example, hit Tab, and have it autocomplete to Expenses:Groceries.

autocmd FileType beancount inoremap <buffer> <Tab> <C-x><C-o>

I use a separate file for account open directives. In addition, I have multiple ledgers, with $BEAN_ROOT pointing to the active one. I set this up like so:

au BufNewFile,BufRead *.bc let b:beancount_root="$BEAN_ROOT/accounts-open-list.bc"

Lot Selection

When selling commodities, you may have have the need to identify the lots you are selling (aka lot reduction), depending on your tax accounting. Unfortunately, OFX files do not contain this information. It must thus be done manually using information from your brokerage. This is where the line above comes in handy:

au FileType beancount nnoremap <buffer> <leader>g vip:GetContext<CR>

This will show you the tax lots that existed before the transaction, from which you can complete your sale transaction.

Error Checking

I use this shell alias to run bean-check, and view its results in a quickfix window in vim, which allows for quick navigation (jumping to forward/backward to the next/previous error) and fixing of problems in the ledger:

bk='bean-check ${BEAN_ROOT}/main-accounts.bc 2> ${BEAN_ROOT}/err ;  test -s ${BEAN_ROOT}/err && my_editor -q ${BEAN_ROOT}/err +:copen'

Fava and Editing

Fava has a bunch of great editing features including autocomplete for account names. It is particularly useful for quick fixes as you browse your account tree or journal (eg: recategorizing an Expense).

Fava can also open up your editor (eg: gvim) at the line being displayed in your web browser. Use beancount_urlscheme to enable tihs.

Notes mentioning this note