[mapserver-commits] r8031 - trunk/docs/howto
svn at osgeo.org
svn at osgeo.org
Fri Nov 21 11:34:30 EST 2008
Author: hobu
Date: 2008-11-21 11:34:30 -0500 (Fri, 21 Nov 2008)
New Revision: 8031
Added:
trunk/docs/howto/map_fold.vim
Log:
add Schuyler's VIM folding stuff to svn
Added: trunk/docs/howto/map_fold.vim
===================================================================
--- trunk/docs/howto/map_fold.vim (rev 0)
+++ trunk/docs/howto/map_fold.vim 2008-11-21 16:34:30 UTC (rev 8031)
@@ -0,0 +1,54 @@
+" Vim folding mode for UMN MapServer .map files
+" Author: Schuyler Erle <schuyler at nocat.net>
+" Last Change: 2006 May 04
+" Version: 1.0
+" Based on an indent folding mode by Jorrit Wiersma and Max Ischenko
+"
+" To use, copy to your ~/.vim directory and then add the following
+" to your .vimrc:
+"
+" autocmd BufRead *.map source ~/.vim/map_fold.vim
+
+setlocal foldmethod=expr
+setlocal foldexpr=GetMapFileFold(v:lnum)
+setlocal foldtext=MapFileFoldText()
+highlight Folded term=bold ctermfg=white ctermbg=black
+
+function! GetMapFileFold(lnum)
+ " If it's a group statement, fold one level
+ let line = getline(a:lnum)
+
+ if line =~ '\c^\s*\(CLASS\|JOIN\|LABEL\|LAYER\|LEGEND\|METADATA\|OUTPUTFORMAT\|PROJECTION\|QUERYMAP\|REFERENCE\|SCALEBAR\|STYLE\|SYMBOL\|WEB\)\s*\(#.*\)*$'
+ return "a1"
+ endif
+
+ " if it's an END, unfold one level
+ if line =~ '\c^\s*END\s*\(#.*\)*$'
+ return "s1"
+ endif
+
+ " otherwise...
+ return "="
+endfunction
+
+function! MapFileFoldText()
+ let line = getline(v:foldstart)
+ let line3 = substitute(line, '\t', ' ', 'g')
+ let line2 = substitute(line3, '^\( *\)', '&+ ', '')
+
+ let i = v:foldstart
+ let name = ""
+ while i < v:foldend
+ let iline = getline(i)
+ if iline =~ '\c^\s*\(NAME\|EXPRESSION\)\s\s*'
+ let name = substitute(iline, '\c\s*\(NAME\|EXPRESSION\)\s*', '', '')
+ break
+ endif
+ let i = i + 1
+ endwhile
+ if name != ""
+ let line2 = line2 . " " . name
+ endif
+ return line2 . " "
+endfunction
+
More information about the mapserver-commits
mailing list