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

  1. "  vim: set sw=4 sts=4:
  2. "  Maintainer    : Nikolai 'pcp' Weibull <da.box@home.se>
  3. "  Revised on    : Tue, 24 Jul 2001 18:45:00 CEST
  4. "  Language    : Eterm configuration file
  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=GetEtermIndent()
  14. setlocal indentkeys=!^F,o,O,=end
  15.  
  16. " Only define the function once.
  17. if exists("*GetEtermIndent")
  18.     finish
  19. endif
  20.  
  21. function GetEtermIndent()
  22.     " Find a non-blank line above the current line.
  23.     let lnum = prevnonblank(v:lnum - 1)
  24.  
  25.     " Hit the start of the file, use zero indent.
  26.     if lnum == 0
  27.        return 0
  28.     endif
  29.  
  30.     let line    = getline(lnum)
  31.     let ind    = indent(lnum)
  32.  
  33.     if line =~ '^\s*begin\>'
  34.     let ind    = ind + &sw
  35.     endif
  36.  
  37.     let line    = getline(v:lnum)
  38.  
  39.     " Check for closing brace on current line
  40.     if line =~ '^\s*end\>'
  41.     let ind    = ind - &sw
  42.     endif
  43.  
  44.     return ind
  45. endfunction
  46.