We create folds exploiting the indent level that starts each GEDCOM
file, but only when the next line is at a deeper nesting level than
the current one.
---
runtime/syntax/gedcom.vim | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
Hello,
I've written a small patch for the GEDCOM format file in vim to allow
folding following the indent level embedded on each line. I tried
contacting the author of the syntax file at the address mentioned in the
syntax file itself, but it seems the email address is invalid, so I'm
submitting the patch to the mailing list.
The patch is in git format, let me know if some other format is
preferred.
Thanks,
Giuseppe Bilotta
diff --git a/runtime/syntax/gedcom.vim b/runtime/syntax/gedcom.vim
index 98851cc..a65e94a 100644
--- a/runtime/syntax/gedcom.vim
+++ b/runtime/syntax/gedcom.vim
@@ -40,6 +40,16 @@ syntax match gedcom_surname "/\(\i\|\s\)*/" contained
syntax match gedcom_date
"\d\{1,2}\s\+\(jan\|feb\|mar\|apr\|may\|jun\|jul\|aug\|sep\|oct\|nov\|dec\)\s\+\d\+"
syntax match gedcom_date ".*" contained
+" GEDCOM lines begin with their 'indent' level. This would suggest something as
+" set foldexpr=getline(v:lnum)[0]
+" but this naive approach causes neighboring lines at the same indent level to
be
+" nested together. Instead, what we do is check if the next line is at a higher
+" indent level, and create a fold at _that_ indent level starting on our line
+set
foldexpr=getline(v:lnum)[0]<getline(v:lnum+1)[0]?'>'.getline(v:lnum+1)[0]:getline(v:lnum)[0]
+set foldmethod=expr
+" This approach only works correctly for indent levels 0-9, but I have yet to
find a GEDCOM
+" file that goes higher than 5, so this is pretty safe.
+
" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
--
1.7.8.rc2.253.gdbf3
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php