diff options
author | John Wiegley <johnw@newartisans.com> | 2007-04-30 06:26:38 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:38:33 -0400 |
commit | c8899addfd2deed3d84be2de234681db64987722 (patch) | |
tree | 07f9a5eb603ff4ec83fe18c83083575d2b7a439a /contrib/ledger.vim | |
parent | aa9cc125796711afcaa459898e95527fdae8e912 (diff) | |
download | fork-ledger-c8899addfd2deed3d84be2de234681db64987722.tar.gz fork-ledger-c8899addfd2deed3d84be2de234681db64987722.tar.bz2 fork-ledger-c8899addfd2deed3d84be2de234681db64987722.zip |
Rearranged the sources a bit.
Diffstat (limited to 'contrib/ledger.vim')
-rw-r--r-- | contrib/ledger.vim | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/contrib/ledger.vim b/contrib/ledger.vim new file mode 100644 index 00000000..df63feb8 --- /dev/null +++ b/contrib/ledger.vim @@ -0,0 +1,46 @@ +" Vim syntax file +" filetype: ledger +" Version: 0.0.2 +" by Wolfgang Oertl; Use according to the terms of the GPL>=2. +" Revision history +" 2005-02-05 first version (partly copied from ledger.vim 0.0.1) + +if version < 600 + syntax clear +elseif exists("b:current_sytax") + finish +endif + +" for debugging +syntax clear + +" region: a normal transaction +syn region transNorm start=/^\d/ skip=/^\s/ end=/^/ fold keepend transparent contains=transDate +syn match transDate /^\d\S\+/ contained +syn match Comment /^;.*$/ +" highlight default link transNorm Question +highlight default link Comment SpecialKey +highlight default link transDate Question + +" folding: how to represent a transaction in one line. +function! MyFoldText() + let line = strpart(getline(v:foldstart), 0, 65) + " get the amount at the end of the second line + let line2 = getline(v:foldstart+1) + let pos = match(line2, "[0-9.]*$") + let line2 = strpart(line2, pos) + let pad_len = 80 - strlen(line) - strlen(line2) + if (pad_len < 0) then + pad_len = 0 + endif + let pad = strpart(" ", 0, pad_len) + return line . pad . line2 +endfunction +set foldtext=MyFoldText() +set foldmethod=syntax + +" syncinc is easy: search for the first transaction. +syn sync clear +syn sync match ledgerSync grouphere transNorm "^\d" + +let b:current_syntax = "ledger" |