codekingpro/portable-devtools
114k
1" Description: InstallShield indenter2" Author: Johannes Zellner <johannes@zellner.org>3" Last Change: Tue, 27 Apr 2004 14:54:59 CEST4 5" Only load this indent file when no other was loaded.6if exists("b:did_indent")7 finish8endif9let b:did_indent = 110 11setlocal autoindent12setlocal indentexpr=GetIshdIndent(v:lnum)13setlocal indentkeys&14setlocal indentkeys+==else,=elseif,=endif,=end,=begin,<:>15" setlocal indentkeys-=0#16 17let b:undo_indent = "setl ai< indentexpr< indentkeys<"18 19" Only define the function once.20if exists("*GetIshdIndent")21 finish22endif23 24fun! GetIshdIndent(lnum)25 " labels and preprocessor get zero indent immediately26 let this_line = getline(a:lnum)27 let LABELS_OR_PREPROC = '^\s*\(\<\k\+\>:\s*$\|#.*\)'28 let LABELS_OR_PREPROC_EXCEPT = '^\s*\<default\+\>:'29 if this_line =~ LABELS_OR_PREPROC && this_line !~ LABELS_OR_PREPROC_EXCEPT30 return 031 endif32 33 " Find a non-blank line above the current line.34 " Skip over labels and preprocessor directives.35 let lnum = a:lnum36 while lnum > 037 let lnum = prevnonblank(lnum - 1)38 let previous_line = getline(lnum)39 if previous_line !~ LABELS_OR_PREPROC || previous_line =~ LABELS_OR_PREPROC_EXCEPT40 break41 endif42 endwhile43 44 " Hit the start of the file, use zero indent.45 if lnum == 046 return 047 endif48 49 let ind = indent(lnum)50 51 " Add52 if previous_line =~ '^\s*\<\(function\|begin\|switch\|case\|default\|if.\{-}then\|else\|elseif\|while\|repeat\)\>'53 let ind = ind + shiftwidth()54 endif55 56 " Subtract57 if this_line =~ '^\s*\<endswitch\>'58 let ind = ind - 2 * shiftwidth()59 elseif this_line =~ '^\s*\<\(begin\|end\|endif\|endwhile\|else\|elseif\|until\)\>'60 let ind = ind - shiftwidth()61 elseif this_line =~ '^\s*\<\(case\|default\)\>'62 if previous_line !~ '^\s*\<switch\>'63 let ind = ind - shiftwidth()64 endif65 endif66 67 return ind68endfun69 