" Vim indent file " Language: Perl " Author: Rafael Garcia-Suarez " URL: http://rgarciasuarez.free.fr/vim/indent/perl.vim " Last Change: 2001 Sep 03 " Only load this indent file when no other was loaded. if exists("b:did_indent") finish endif let b:did_indent = 1 setlocal indentexpr=GetPerlIndent() setlocal indentkeys+=0=,0),=EO,=or,=and " Only define the function once. if exists("*GetPerlIndent") finish endif function GetPerlIndent() " Get the line to be indented let cline = getline(v:lnum) " Don't indent POD markers ; don't indent end-of-heredocs markers " (assuming they begin with 'EO') if cline =~ '^\s*\(=\|EO\)' return 0 endif " Find a non-blank line above the current line. let lnum = prevnonblank(v:lnum - 1) " Hit the start of the file, use zero indent. if lnum == 0 return 0 endif let line = getline(lnum) let ind = indent(lnum) " Indent to column 0 if previous line contains <' if line !~ '^\s*\(or\|and\)\>' let ind = ind + &sw endif elseif line =~ '^\s*\(or\|and\)\>' let ind = ind - &sw endif " Don't indent comments if line =~ '^\s*#' return ind endif return ind endfunction