You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With vim-ledger, if I press Tab on the first column on an empty row, autocompletion enters the current date. I miss this feature, and this would be a great addition to vim-beancount if it's easy to add in. https://github.com/ledger/vim-ledger
(Please feel free to delete this issue if this is not of interest).
Thanks!
The text was updated successfully, but these errors were encountered:
The idea is: assume your transactions are ordered in chronicle order and you want to keep in that way, using the following vim function will find the right place (the last transaction whose date is <= today), place the cursor there, enter current date and leave vim in insert mode.
If you don't have transactions in a future date then it can be simplified a lot.
@nathangrigg let me know if you want to include this, I can send a PR.
function GotoInsertPosition()
let today=strftime("%Y-%m-%d")
let f=bufname("%")
let cmd="grep ^20 ".f."|sort|awk '{ if($1 > \"".today."\") { printf \"%s\",lastday; found=1; exit; } lastday=$1 } END {if(!found) printf \"%s\",lastday}'"
let lastday=system(cmd)
let cmd="awk '/^".lastday."/,/^$/{lineno=NR} END {printf \"%d\",lineno}' ".f
let lineno=system(cmd)
execute ":".lineno
execute "normal! yyppk"
execute "normal! i".today." *"
execute ":startinsert!"
endfunction
nnoremap <C-x> :call GotoInsertPosition()<CR>
With vim-ledger, if I press Tab on the first column on an empty row, autocompletion enters the current date. I miss this feature, and this would be a great addition to vim-beancount if it's easy to add in.
https://github.com/ledger/vim-ledger
(Please feel free to delete this issue if this is not of interest).
Thanks!
The text was updated successfully, but these errors were encountered: