1" Vim indent file 2" Language: C-shell (tcsh) 3" Maintainer: Doug Kearns <[email protected]> 4" Previous Maintainer: Gautam Iyer <[email protected]> where NoSpam=gmail (Original Author) 5" Last Change: 2021 Oct 15 6 7" Only load this indent file when no other was loaded. 8if exists("b:did_indent") 9 finish 10endif 11 12let b:did_indent = 1 13 14setlocal indentexpr=TcshGetIndent() 15setlocal indentkeys+=e,0=end 16setlocal indentkeys-=0{,0},0),:,0# 17 18let b:undo_indent = "setl inde< indk<" 19 20" Only define the function once. 21if exists("*TcshGetIndent") 22 finish 23endif 24 25function TcshGetIndent() 26 " Find a non-blank line above the current line. 27 let lnum = prevnonblank(v:lnum - 1) 28 29 " Hit the start of the file, use zero indent. 30 if lnum == 0 31 return 0 32 endif 33 34 " Add indent if previous line begins with while or foreach 35 " OR line ends with case <str>:, default:, else, then or \ 36 let ind = indent(lnum) 37 let line = getline(lnum) 38 if line =~ '\v^\s*%(while|foreach)>|^\s*%(case\s.*:|default:|else)\s*$|%(<then|\\)$' 39 let ind = ind + shiftwidth() 40 endif 41 42 if line =~ '\v^\s*breaksw>' 43 let ind = ind - shiftwidth() 44 endif 45 46 " Subtract indent if current line has on end, endif, endsw, case commands 47 let line = getline(v:lnum) 48 if line =~ '\v^\s*%(else|end|endif|endsw)\s*$' 49 let ind = ind - shiftwidth() 50 endif 51 52 return ind 53endfunction 54