Mercurial > vim
comparison runtime/indent/readline.vim @ 375:f14cbd913415 v7.0097
updated for version 7.0097
author | vimboss |
---|---|
date | Wed, 29 Jun 2005 22:40:58 +0000 |
parents | 3fc0f57ecb91 |
children | 1f3b1021f002 |
comparison
equal
deleted
inserted
replaced
374:575dacb554d8 | 375:f14cbd913415 |
---|---|
1 " Vim indent file | 1 " Vim indent file |
2 " Language: readline configuration file | 2 " Language: readline configuration file |
3 " Maintainer: Nikolai Weibull <source@pcppopper.org> | 3 " Maintainer: Nikolai Weibull <nikolai+work.vim@bitwi.se> |
4 " URL: http://www.pcppopper.org/vim/indent/pcp/readline/ | 4 " Latest Revision: 2005-06-29 |
5 " Latest Revision: 2004-04-25 | |
6 " arch-tag: ee681235-3abf-4a42-8587-edabd409a980 | |
7 | 5 |
8 " Only load this indent file when no other was loaded. | |
9 if exists("b:did_indent") | 6 if exists("b:did_indent") |
10 finish | 7 finish |
11 endif | 8 endif |
12 | |
13 let b:did_indent = 1 | 9 let b:did_indent = 1 |
14 | 10 |
15 setlocal indentexpr=GetReadlineIndent() | 11 setlocal indentexpr=GetReadlineIndent() |
16 setlocal indentkeys=!^F,o,O,=$else,=$endif | 12 setlocal indentkeys=!^F,o,O,=$else,=$endif |
17 | 13 |
18 " Only define the function once. | |
19 if exists("*GetReadlineIndent") | 14 if exists("*GetReadlineIndent") |
20 finish | 15 finish |
21 endif | 16 endif |
22 | 17 |
23 function GetReadlineIndent() | 18 function GetReadlineIndent() |
24 let lnum = prevnonblank(v:lnum - 1) | 19 let lnum = prevnonblank(v:lnum - 1) |
25 | |
26 if lnum == 0 | 20 if lnum == 0 |
27 return 0 | 21 return 0 |
28 endif | 22 endif |
29 | 23 |
30 let line = getline(lnum) | |
31 let ind = indent(lnum) | 24 let ind = indent(lnum) |
32 | 25 |
33 " increase indent if previous line started with $if or $else | 26 if getline(lnum) =~ '^\s*$\(if\|else\)\>' |
34 if line =~ '^\s*$\(if\|else\)\>' | |
35 let ind = ind + &sw | 27 let ind = ind + &sw |
36 endif | 28 endif |
37 | 29 |
38 let line = getline(v:lnum) | 30 if getline(v:lnum) =~ '^\s*$\(else\|endif\)\>' |
39 | |
40 " decrease indent if this line starts with $else or $endif | |
41 if line =~ '^\s*$\(else\|endif\)\>' | |
42 let ind = ind - &sw | 31 let ind = ind - &sw |
43 endif | 32 endif |
44 | 33 |
45 return ind | 34 return ind |
46 endfunction | 35 endfunction |
47 | |
48 " vim: set sts=2 sw=2: |