1 " IDL (Interactive Data Language) indent file.
2 " Language: IDL (ft=idlang)
3 " Last change: 2002 Sep 23
4 " Maintainer: Aleksandar Jelenak <ajelenak AT yahoo.com>
6 " Only load this indent file when no other was loaded.
7 if exists("b:did_indent")
12 setlocal indentkeys=o,O,0=endif,0=ENDIF,0=endelse,0=ENDELSE,0=endwhile,
13 \0=ENDWHILE,0=endfor,0=ENDFOR,0=endrep,0=ENDREP
15 setlocal indentexpr=GetIdlangIndent(v:lnum)
17 " Only define the function once.
18 if exists("*GetIdlangIndent")
22 function GetIdlangIndent(lnum)
23 " First non-empty line above the current line.
24 let pnum = prevnonblank(v:lnum-1)
25 " v:lnum is the first non-empty line -- zero indent.
29 " Second non-empty line above the current line.
30 let pnum2 = prevnonblank(pnum-1)
33 let curind = indent(pnum)
35 " Indenting of continued lines.
36 if getline(pnum) =~ '\$\s*\(;.*\)\=$'
37 if getline(pnum2) !~ '\$\s*\(;.*\)\=$'
38 let curind = curind+&sw
41 if getline(pnum2) =~ '\$\s*\(;.*\)\=$'
42 let curind = curind-&sw
46 " Indenting blocks of statements.
47 if getline(v:lnum) =~? '^\s*\(endif\|endelse\|endwhile\|endfor\|endrep\)\>'
48 if getline(pnum) =~? 'begin\>'
49 elseif indent(v:lnum) > curind-&sw
50 let curind = curind-&sw
54 elseif getline(pnum) =~? 'begin\>'
55 if indent(v:lnum) < curind+&sw
56 let curind = curind+&sw