4 " Last Change: 2005 Mar 28
5 " Maintainer: BERTRAND Joël <rpl2@free.fr>
7 " Only load this indent file when no other was loaded.
8 if exists("b:did_indent")
14 setlocal indentkeys+==~end,=~case,=~if,=~then,=~else,=~do,=~until,=~while,=~repeat,=~select,=~default,=~for,=~start,=~next,=~step,<<>,<>>
16 " Define the appropriate indent function but only once
17 setlocal indentexpr=RplGetFreeIndent()
18 if exists("*RplGetFreeIndent")
22 let b:undo_indent = "set ai< indentkeys< indentexpr<"
24 function RplGetIndent(lnum)
25 let ind = indent(a:lnum)
26 let prevline=getline(a:lnum)
28 let prevstat=substitute(prevline, '!.*$', '', '')
30 " Add a shiftwidth to statements following if, iferr, then, else, elseif,
31 " case, select, default, do, until, while, repeat, for, start
32 if prevstat =~? '\<\(if\|iferr\|do\|while\)\>' && prevstat =~? '\<end\>'
33 elseif prevstat =~? '\(^\|\s\+\)<<\($\|\s\+\)' && prevstat =~? '\s\+>>\($\|\s\+\)'
34 elseif prevstat =~? '\<\(if\|iferr\|then\|else\|elseif\|select\|case\|do\|until\|while\|repeat\|for\|start\|default\)\>' || prevstat =~? '\(^\|\s\+\)<<\($\|\s\+\)'
38 " Subtract a shiftwidth from then, else, elseif, end, until, repeat, next,
40 let line = getline(v:lnum)
41 if line =~? '^\s*\(then\|else\|elseif\|until\|repeat\|next\|step\|default\|end\)\>'
43 elseif line =~? '^\s*>>\($\|\s\+\)'
50 function RplGetFreeIndent()
51 " Find the previous non-blank line
52 let lnum = prevnonblank(v:lnum - 1)
54 " Use zero indent at the top of the file
59 let ind=RplGetIndent(lnum)