Loading ...
Sorry, an error occurred while loading the content.
 

new vim.vim indent file

Expand Messages
  • Bram Moolenaar
    The indent file for Vim scripts in the 6.0h version doesn t handle empty lines. This one should work better: Vim indent file Language: Vim script
    Message 1 of 1 , Sep 2, 2000
      The indent file for Vim scripts in the 6.0h version doesn't handle empty
      lines. This one should work better:

      " Vim indent file
      " Language: Vim script
      " Maintainer: Bram Moolenaar <Bram@...>
      " Last Change: 2000 Sep 02

      setlocal indentexpr=GetVimIndent()
      setlocal cinkeys+==end

      " Only define the function once.
      if exists("*GetVimIndent")
      finish
      endif

      function GetVimIndent()
      " Find a non-empty line above the current line.
      let lnum = v:lnum - 1
      while lnum > 0
      if getline(lnum) !~ '^\s*$'
      break
      endif
      let lnum = lnum - 1
      endwhile

      " Hit the start of the file, use zero indent.
      if lnum == 0
      return 0
      endif

      " Add a 'shiftwidth' after :if, :while, :function and :else
      let ind = indent(lnum)
      if getline(lnum) =~ '^\s*\(if\>\|wh\|fu\|el\)'
      let ind = ind + &sw
      endif

      " Subtract a 'shiftwidth' on a :endif, :endwhile, :endfun and :else
      if getline(v:lnum) =~ '^\s*\(ene\@!\|el\)'
      let ind = ind - &sw
      endif

      return ind
      endfunction

      " vim:sw=2

      --
      The only way the average employee can speak to an executive is by taking a
      second job as a golf caddie.
      (Scott Adams - The Dilbert principle)

      /// Bram Moolenaar Bram@... http://www.moolenaar.net \\\
      \\\ Vim: http://www.vim.org ICCF Holland: http://iccf-holland.org ///
    Your message has been successfully submitted and would be delivered to recipients shortly.