" Vim indent file " Language: slrn score file (slrnsc) " Maintainer: Christian J. Robinson <infynity@onewest.net> " URL: http://www.infynity.spodzone.com/vim/indent/slrnsc.vim " Last Change: 2002 Sep 26 " Only load this indent file when no other was loaded: if exists("b:did_indent") finish endif let b:did_indent = 1 setlocal indentexpr=GetSlrnscIndent() setlocal indentkeys-=0{,0} indentkeys-=0# indentkeys-=: setlocal indentkeys+==Score:,0[,0} " Only define the function once: if exists("*GetSlrnscIndent") finish endif function GetSlrnscIndent() " Find a non-blank line above the current line: let lnum = prevnonblank(v:lnum - 1) " No indent for the start of the file: if lnum == 0 return 0 endif let ind = indent(lnum) let line = getline(lnum) " Skip over comments to find the proper indent: " (Unless you open a line just below a comment.) while line =~ '^\s*%' && getline(v:lnum - 1) !~ '^\s*%' let lnum = prevnonblank(lnum - 1) if lnum == 0 return 0 endif let ind = indent(lnum) let line = getline(lnum) endwhile " Lines after Score: or {: should be indented: if line =~ '^\(\[\|\s*Score:\|\s*{:\)' let ind = ind + &sw endif let line = getline(v:lnum) if line =~ '^\s*\[' " If the current line starts with [, " it should not be indented at all. let ind = 0 elseif line =~ '^\s*\(Score:\|}\)' " De-indent by one level if the current " line is Score: or }. let ind = ind - &sw endif return ind endfunction