codekingpro/portable-devtools
114k
1" Vim indent file2" Language: C-shell (tcsh)3" Maintainer: Doug Kearns <dougkearns@gmail.com>4" Previous Maintainer: Gautam Iyer <gi1242+vim@NoSpam.com> where NoSpam=gmail (Original Author)5" Last Change: 2021 Oct 156 7" Only load this indent file when no other was loaded.8if exists("b:did_indent")9 finish10endif11 12let b:did_indent = 113 14setlocal indentexpr=TcshGetIndent()15setlocal indentkeys+=e,0=end16setlocal indentkeys-=0{,0},0),:,0#17 18let b:undo_indent = "setl inde< indk<"19 20" Only define the function once.21if exists("*TcshGetIndent")22 finish23endif24 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 == 031 return 032 endif33 34 " Add indent if previous line begins with while or foreach35 " 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 endif41 42 if line =~ '\v^\s*breaksw>'43 let ind = ind - shiftwidth()44 endif45 46 " Subtract indent if current line has on end, endif, endsw, case commands47 let line = getline(v:lnum)48 if line =~ '\v^\s*%(else|end|endif|endsw)\s*$'49 let ind = ind - shiftwidth()50 endif51 52 return ind53endfunction54 