blob: b2640f1f2f97f13f2e91778c13fa5a356a354535 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim indent file
2" Language: readline configuration file
3" Maintainer: Nikolai Weibull <source@pcppopper.org>
4" URL: http://www.pcppopper.org/vim/indent/pcp/readline/
5" Latest Revision: 2004-04-25
6" arch-tag: ee681235-3abf-4a42-8587-edabd409a980
7
8" Only load this indent file when no other was loaded.
9if exists("b:did_indent")
10 finish
11endif
12
13let b:did_indent = 1
14
15setlocal indentexpr=GetReadlineIndent()
16setlocal indentkeys=!^F,o,O,=$else,=$endif
17
18" Only define the function once.
19if exists("*GetReadlineIndent")
20 finish
21endif
22
23function GetReadlineIndent()
24 let lnum = prevnonblank(v:lnum - 1)
25
26 if lnum == 0
27 return 0
28 endif
29
30 let line = getline(lnum)
31 let ind = indent(lnum)
32
33 " increase indent if previous line started with $if or $else
34 if line =~ '^\s*$\(if\|else\)\>'
35 let ind = ind + &sw
36 endif
37
38 let line = getline(v:lnum)
39
40 " decrease indent if this line starts with $else or $endif
41 if line =~ '^\s*$\(else\|endif\)\>'
42 let ind = ind - &sw
43 endif
44
45 return ind
46endfunction
47
48" vim: set sts=2 sw=2: