home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / vim60.zip / vim60rt2.zip / vim / vim60 / indent / tcl.vim < prev    next >
Text File  |  2001-09-26  |  1KB  |  52 lines

  1. "  vim: set sw=4 sts=4:
  2. "  Maintainer    : Nikolai 'pcp' Weibull <da.box@home.se>
  3. "  Revised on    : Wed, 25 Jul 2001 20:46:22 CEST
  4. "  Language    : Tcl
  5.  
  6. " Only load this indent file when no other was loaded.
  7. if exists("b:did_indent")
  8.     finish
  9. endif
  10.  
  11. let b:did_indent = 1
  12.  
  13. setlocal indentexpr=GetTclIndent()
  14. setlocal indentkeys-=:,0#
  15.  
  16. " Only define the function once.
  17. if exists("*GetTclIndent")
  18.     finish
  19. endif
  20.  
  21. function GetTclIndent()
  22.     let lnum = v:lnum
  23.     let line = getline(lnum)
  24.     let pline = getline(lnum - 1)
  25.  
  26.     while lnum > 0 && (line =~ '^\s*#' || line =~ '^\s*$' || pline =~ '\\\s*$')
  27.     let lnum = lnum - 1
  28.     let line = getline(lnum)
  29.     let pline = getline(lnum - 1)
  30.     endwhile
  31.  
  32.     if lnum == 0
  33.     return 0
  34.     endif
  35.  
  36.     let ind = indent(lnum)
  37.  
  38.     " Check for opening brace on previous line
  39.     if line =~ '{\(.*}\)\@!'
  40.     let ind = ind + &sw
  41.     endif
  42.  
  43.     let line = getline(v:lnum)
  44.  
  45.     " Check for closing brace on current line
  46.     if line =~ '^\s*}'
  47.     let ind    = ind - &sw
  48.     endif
  49.  
  50.     return ind
  51. endfunction
  52.