aboutsummaryrefslogtreecommitdiffstats
path: root/ftplugin/beancount.vim
diff options
context:
space:
mode:
authorNathan Grigg2014-10-07 10:59:11 -0700
committerNathan Grigg2014-10-07 10:59:11 -0700
commitbdc0374f49d32dd7a996113fc49d6abee2a50b24 (patch)
treeba44baa67ea2aaa8159e13fc7f2ff317b067397c /ftplugin/beancount.vim
parentf8177b09626a0ac973912c633d95b604b9024371 (diff)
downloadvim-beancount-bdc0374f49d32dd7a996113fc49d6abee2a50b24.tar.gz
AlignCommodity and Incoming
Diffstat (limited to 'ftplugin/beancount.vim')
-rw-r--r--ftplugin/beancount.vim28
1 files changed, 28 insertions, 0 deletions
diff --git a/ftplugin/beancount.vim b/ftplugin/beancount.vim
new file mode 100644
index 0000000..f073545
--- /dev/null
+++ b/ftplugin/beancount.vim
@@ -0,0 +1,28 @@
+" These two variables customize the behavior of the AlignCommodity command.
+
+if !exists("g:beancount_separator_col")
+ let g:beancount_separator_col = 50
+endif
+if !exists("g:beancount_decimal_separator")
+ let g:beancount_decimal_separator = "."
+endif
+
+command! -range AlignCommodity :call beancount#align_commodity(<line1>, <line2>)
+
+" Align commodity to proper column
+inoremap <buffer> . .<C-O>:AlignCommodity<CR>
+nnoremap <buffer> <leader>= :AlignCommodity<CR>
+vnoremap <buffer> <leader>= :AlignCommodity<CR>
+
+" Insert incoming transactions at the bottom
+function! s:InsertIncoming()
+ let incoming = expand('%:h') . '/incoming.bean'
+ try
+ execute '$read' incoming
+ call system('mv ' . incoming . ' ' . incoming . '~')
+ catch /:E484/
+ echom "Not found: incoming.bean"
+ endtry
+endfunction
+
+command! -buffer Incoming call <SID>InsertIncoming()