Mercurial > vim
comparison runtime/indent/rpl.vim @ 7:3fc0f57ecb91 v7.0001
updated for version 7.0001
author | vimboss |
---|---|
date | Sun, 13 Jun 2004 20:20:40 +0000 |
parents | |
children | fca8a9b65afa |
comparison
equal
deleted
inserted
replaced
6:c2daee826b8f | 7:3fc0f57ecb91 |
---|---|
1 " Vim indent file | |
2 " Language: RPL/2 | |
3 " Version: 0.2 | |
4 " Last Change: 2002 August 16 | |
5 " Maintainer: BERTRAND Joël <rpl2@free.fr> | |
6 | |
7 " Only load this indent file when no other was loaded. | |
8 if exists("b:did_indent") | |
9 finish | |
10 endif | |
11 let b:did_indent = 1 | |
12 | |
13 setlocal indentkeys+==~end,=~case,=~if,=~then,=~else,=~do,=~until,=~while,=~repeat,=~select,=~default,=~for,=~start,=~next,=~step,<<>,<>> | |
14 | |
15 " Define the appropriate indent function but only once | |
16 setlocal indentexpr=RplGetFreeIndent() | |
17 if exists("*RplGetFreeIndent") | |
18 finish | |
19 endif | |
20 | |
21 function RplGetIndent(lnum) | |
22 let ind = indent(a:lnum) | |
23 let prevline=getline(a:lnum) | |
24 " Strip tail comment | |
25 let prevstat=substitute(prevline, '!.*$', '', '') | |
26 | |
27 " Add a shiftwidth to statements following if, iferr, then, else, elseif, | |
28 " case, select, default, do, until, while, repeat, for, start | |
29 if prevstat =~? '\<\(if\|iferr\|do\|while\)\>' && prevstat =~? '\<end\>' | |
30 elseif prevstat =~? '\(^\|\s\+\)<<\($\|\s\+\)' && prevstat =~? '\s\+>>\($\|\s\+\)' | |
31 elseif prevstat =~? '\<\(if\|iferr\|then\|else\|elseif\|select\|case\|do\|until\|while\|repeat\|for\|start\|default\)\>' || prevstat =~? '\(^\|\s\+\)<<\($\|\s\+\)' | |
32 let ind = ind + &sw | |
33 endif | |
34 | |
35 " Subtract a shiftwidth from then, else, elseif, end, until, repeat, next, | |
36 " step | |
37 let line = getline(v:lnum) | |
38 if line =~? '^\s*\(then\|else\|elseif\|until\|repeat\|next\|step\|default\|end\)\>' | |
39 let ind = ind - &sw | |
40 elseif line =~? '^\s*>>\($\|\s\+\)' | |
41 let ind = ind - &sw | |
42 endif | |
43 | |
44 return ind | |
45 endfunction | |
46 | |
47 function RplGetFreeIndent() | |
48 " Find the previous non-blank line | |
49 let lnum = prevnonblank(v:lnum - 1) | |
50 | |
51 " Use zero indent at the top of the file | |
52 if lnum == 0 | |
53 return 0 | |
54 endif | |
55 | |
56 let ind=RplGetIndent(lnum) | |
57 return ind | |
58 endfunction | |
59 | |
60 " vim:sw=2 tw=130 |