org-mode + beancount, how to quickly reorganize?

1,168 views
Skip to first unread message

Oon-Ee Ng

unread,
Feb 4, 2017, 3:41:17 PM2/4/17
to Beancount
I'm a vim user, but figured going with beancount is as good a reason as any to try emacs out (evil-mode though).

Have figured some basics out, but it seems slightly inefficient (especially looking forward to a ton of entries and a growing beancount file).

So my file structure (I think fairly common based on other examples I've seen online) is repeated copies of

* Type (I use one of Bank Account, Credit Card, Cash)
** InstitutionA
** InstitutionB

And then right at the end I have a

* Unsorted

That's where all the quick-add-via-fava transactions go, which I eventually want to sort back to the structure above. Copying an entire transaction I do d-a-p (delete paragraph), which I can then paste where I want it to go.

The problem here is, how do I quickly get to where I want it to go? Under a Type->Institution heading I have a chronologically sorted list of transactions, and I'd want the newer ones to be somewhere near the end (especially for large files with lots of transactions). Currently I have to close the Unsorted heading, open the target heading, and then go to the bottom (and scroll up a few lines past some headings) before pasting.

Is this pretty much what others are doing? Or is there a faster way (e.g. something like 'go directly to end of this heading')?

Daniel Clemente

unread,
Feb 5, 2017, 11:38:01 AM2/5/17
to bean...@googlegroups.com


> The problem here is, how do I quickly get to where I want it to go? Under a Type->Institution heading I have a chronologically sorted list
> of transactions, and I'd want the newer ones to be somewhere near the end (especially for large files with lots of transactions). Currently
> I have to close the Unsorted heading, open the target heading, and then go to the bottom (and scroll up a few lines past some headings)
> before pasting.
>
> Is this pretty much what others are doing? Or is there a faster way (e.g. something like 'go directly to end of this heading')?

There might be better ways, but I always use C-c C-n to do it. This moves to the next heading. Then you go up one line and you're at the end of the previous heading.

To move to a header there's an interactive interface with C-c C-j (org-goto) but I'm always using just C-s (a normal search) to look for any particular text that is near where I want to go (e.g. a similar transaction). You could even write a string ;ADD_HERE and then just look for it each time (C-s ADD_ C-s C-m).

Martin Blais

unread,
Feb 5, 2017, 5:45:57 PM2/5/17
to Beancount
On Saturday, February 4, 2017 at 3:41:17 PM UTC-5, Oon-Ee Ng wrote:
I'm a vim user, but figured going with beancount is as good a reason as any to try emacs out (evil-mode though).

Congratulations!
I'm not sure what others do, but I can describe my own.
My organization looks like this:

* Options
* CA
** National Bank
*** Checking
*** Savings
* US
** BofA
*** Checking
*** Savings
** Amex
*** BlueCash
** Fidelity
...


Each section contains a mostly sorted list of transactions for a number of related accounts.
Then I have a section for income:

* Income
** AcmeInc
*** Salary
*** Vesting
...


Then I have sections for government things, like taxes, with a subsection for each country:

* Government
** Taxes
*** 2001
*** 2002
...
*** 2016
**** US
**** CA

I have a generic section for cash expenses like yours, I call mine "Daybook", and each subsection is for a particular period, e.g. a trip, some interval of time when I don't travel:

* Daybook
** 2016
...
*** Fall in NYC
*** Trip to Maui
*** Holidays in NYC

These are arbitrary, but in chronological order, and I tend to create a new section anytime I travel, so it comes with an update in the "location" event that can report on days vs. location.

Finally, I have a long section where I put all price updates, typically update every couple of weeks (but I'm not so good about regular entries yet, I'd like to automate that at some point):

* Prices
...


To go somewhere, I currently open my document with all sections folded, then I use i-search to find the right heading, e.g., "C-s * Ame" to get to the American Express section. Then I press C-i to open up that section and then C-n to go to the bottom.

I use registers intensely in order to go back and forth between different parts of my file.

This is simplified a fair bit.
I hope this helps,

Oon-Ee Ng

unread,
Feb 5, 2017, 9:17:23 PM2/5/17
to bean...@googlegroups.com
On Mon, Feb 6, 2017 at 6:45 AM, Martin Blais <bl...@furius.ca> wrote:
On Saturday, February 4, 2017 at 3:41:17 PM UTC-5, Oon-Ee Ng wrote:
I'm a vim user, but figured going with beancount is as good a reason as any to try emacs out (evil-mode though).

Congratulations!

Many thanks to you (and the fava folk!), I would not have made the leap with just pure ledger (very much a pythonista).

*snip of a lot of structural stuff, thanks for the explanation, but I've basically gleaned that from looking at your previous mails =)*
These are arbitrary, but in chronological order, and I tend to create a new section anytime I travel, so it comes with an update in the "location" event that can report on days vs. location.

Finally, I have a long section where I put all price updates, typically update every couple of weeks (but I'm not so good about regular entries yet, I'd like to automate that at some point):

* Prices
...

This I haven't looked into (as I hardly travel given the weakness of my currency, and being fairly young I'm not yet into equities of any nature (the local exchange is very much rigged).

To go somewhere, I currently open my document with all sections folded, then I use i-search to find the right heading, e.g., "C-s * Ame" to get to the American Express section. Then I press C-i to open up that section and then C-n to go to the bottom.
 
Thanks this sounds similar to what Daniel Clemente mentioned in his other reply. For my in evil-mode it'd just be a 'g-j' once I'm on the right heading, instead of C-n. Already trying to practice doing this but it does seem fairly convoluted in thought (instead of going directly I'm going to the NEXT section and then rewinding by 2-3 lines)

I use registers intensely in order to go back and forth between different parts of my file.

Registers? Thanks, will read up on those. Coming from vim I know about marks, but these seem (like most emacs things I've seen so far) both more powerful and more arcane...

Alex Johnstone

unread,
Feb 13, 2017, 3:09:48 PM2/13/17
to Beancount
I used beancount in emacs (well spacemacs) for a while, then stopped using beancount, then came back to it but this time I use vim.

I wasn't a vim or emacs user before using beancount, and I've found vim to be easier and quicker to get around and use for beancount. The key feature was folding and the vim-beancount plugin. I did edit the way the plugin does folding, I switched to markers and found it so easy to navigate.

I have the following layout:

; Config {{{1
; Options {{{2
; Commodities {{{2

etc. so {{{1 for top level, like * in org-mode, and {{{2 for ** and so on.

I have all my transactions wrapped by accounts:

; UK {{{2

: Bank A {{{3

; Bank B {{{3

etc.

Then I just use the folding z keys to open and close and navigate around. The best one being ]z to jump to the end of the current fold ready to add the next transaction. Whilst I was learning I put this at the top of my file to refer to:

;; Navigation
;; za will toggle folds between markers, {{{ and a number
;; [z move to start of current fold
;; ]z move to end of current fold
;; zj move down to start of next fold
;; zk move up to end of previous fold
;; ----------------- ;;
;; Beancount shortcuts
;; C-x C-o Omni completion
;; SPC = Align commodity        [I set this as based upon the vim-beancount doc's guide]
;; Select chunks in visual mode and use align commodity on it

Let me know if you need more explanation.

Jason Chu

unread,
Feb 13, 2017, 3:18:45 PM2/13/17
to Beancount
vim-beancount now supports markdown style folds, so #, ##, and ### (* is also supported) headers are folded automatically and you don't need to use {{{ anymore.

--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To post to this group, send email to bean...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/e980b84d-c7a4-4a5d-aab6-81d83e3fcd2a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

shaun

unread,
Feb 13, 2017, 3:29:43 PM2/13/17
to bean...@googlegroups.com
That sounds great.  

Could you give a quick example of what it looks like to use the markdown style folds?  I'm trying something but it doesn't seem to be working. 

Jason Chu

unread,
Feb 13, 2017, 3:40:50 PM2/13/17
to bean...@googlegroups.com
Something like this:

# Options

# Assets

## Assets:US:BankA

## Assets:US:BankB

# Liabilities

## Liabilities:Mortgage

## Liabilities:US:Credit

Each Assets:US:BankA and BankB are folded within Assets, similarly with Liabilities:Mortgage and Liabilities:US:Credit inside Liabilities.

Reply all
Reply to author
Forward
0 new messages