Skip to content

Commit

Permalink
feat: vim folding
Browse files Browse the repository at this point in the history
  • Loading branch information
howeyc committed Nov 23, 2023
1 parent 95dad56 commit 61de937
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions vim-ledger/ftplugin/ledger.vim
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,23 @@ if has('autocmd')
augroup END
endif

" show payee line and amount as fold header
if has('folding')
function! LedgerFoldText()
let line = getline(v:foldstart)
let cmt = matchstr(line, ' ;.*')
let sidx = stridx(line, " ")
if sidx > 0
let line = strpart(line, 0, sidx)
endif
let amt = matchstr(getline(v:foldstart+1), '-\?\d\+\.\d\+')
let blanks = repeat(' ', 80-(len(line)+len(amt)))
return line .. blanks .. amt .. cmt
endfunction

setlocal foldtext=LedgerFoldText()
endif

" Commands for ledger file type:
" insert date
nnoremap <buffer> <localleader>id "=strftime("%Y/%m/%d")<CR>P
Expand Down

0 comments on commit 61de937

Please sign in to comment.