Mercurial > vim
comparison runtime/indent/rst.vim @ 7:3fc0f57ecb91 v7.0001
updated for version 7.0001
author | vimboss |
---|---|
date | Sun, 13 Jun 2004 20:20:40 +0000 |
parents | |
children | f14cbd913415 |
comparison
equal
deleted
inserted
replaced
6:c2daee826b8f | 7:3fc0f57ecb91 |
---|---|
1 " Vim indent file | |
2 " Language: reStructuredText Documentation Format | |
3 " Maintainer: Nikolai Weibull <source@pcppopper.org> | |
4 " URL: http://www.pcppopper.org/vim/indent/pcp/rst/ | |
5 " Latest Revision: 2004-04-25 | |
6 " arch-tag: 3fe10f75-24d0-4d94-a924-0ce945958104 | |
7 | |
8 " Only load this indent file when no other was loaded. | |
9 if exists("b:did_indent") | |
10 finish | |
11 endif | |
12 | |
13 let b:did_indent = 1 | |
14 | |
15 setlocal indentexpr=GetRSTIndent() | |
16 setlocal indentkeys-=:,0# indentkeys-=e | |
17 | |
18 " Only define the function once. | |
19 if exists("*GetRSTIndent") | |
20 finish | |
21 endif | |
22 | |
23 function GetRSTIndent() | |
24 let lnum = prevnonblank(v:lnum - 1) | |
25 | |
26 if lnum == 0 | |
27 return 0 | |
28 endif | |
29 | |
30 let ind = indent(lnum) | |
31 let line = getline(lnum) | |
32 | |
33 if line =~ '^\s*[-*+]\s' | |
34 let ind = ind + 2 | |
35 elseif line =~ '^\s*\d\+.\s' | |
36 let ind = ind + matchend(substitute(line, '^\s*', '', ''), '\d\+.\s\+') | |
37 endif | |
38 | |
39 let line = getline(v:lnum - 1) | |
40 | |
41 if line =~ '^\s*$' | |
42 execute lnum | |
43 call search('^\s*\%([-*+]\s\|\d\+.\s\|\.\.\|$\)', 'bW') | |
44 let line = getline('.') | |
45 if line =~ '^\s*[-*+]' | |
46 let ind = ind - 2 | |
47 elseif line =~ '^\s*\d\+\.\s' | |
48 let ind = ind - matchend(substitute(line, '^\s*', '', ''), | |
49 \ '\d\+\.\s\+') | |
50 elseif line =~ '^\s*\.\.' | |
51 let ind = ind - 3 | |
52 else | |
53 let ind = ind | |
54 endif | |
55 endif | |
56 | |
57 return ind | |
58 endfunction | |
59 | |
60 " vim: set sts=2 sw=2: |