2 " Language: C-shell (tcsh)
3 " Maintainer: GI <a@b.c>, where a='gi1242+vim', b='gmail', c='com'
4 " Last Modified: Sat 10 Dec 2011 09:23:00 AM EST
6 " Only load this indent file when no other was loaded.
7 if exists("b:did_indent")
13 setlocal indentexpr=TcshGetIndent()
14 setlocal indentkeys+=e,0=end,0=endsw indentkeys-=0{,0},0),:,0#
16 " Only define the function once.
17 if exists("*TcshGetIndent")
21 function TcshGetIndent()
22 " Find a non-blank line above the current line.
23 let lnum = prevnonblank(v:lnum - 1)
25 " Hit the start of the file, use zero indent.
30 " Add indent if previous line begins with while or foreach
31 " OR line ends with case <str>:, default:, else, then or \
32 let ind = indent(lnum)
33 let line = getline(lnum)
34 if line =~ '\v^\s*%(while|foreach)>|^\s*%(case\s.*:|default:|else)\s*$|%(<then|\\)$'
38 if line =~ '\v^\s*breaksw>'
42 " Subtract indent if current line has on end, endif, case commands
43 let line = getline(v:lnum)
44 if line =~ '\v^\s*%(else|end|endif)\s*$'