annotate runtime/indent/vb.vim @ 3964:3caf6f4a778e

Added tag v7-3-737 for changeset 1773d5aa6437
author Bram Moolenaar <bram@vim.org>
date Wed, 28 Nov 2012 17:34:49 +0100
parents 80229a724a11
children 63b0b7b79b25
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim indent file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: VisualBasic (ft=vb) / Basic (ft=basic) / SaxBasic (ft=vb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Author: Johannes Zellner <johannes@zellner.org>
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4 " Last Change: Fri, 18 Jun 2004 07:22:42 CEST
2421
c0e675a3e363 Minor runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 233
diff changeset
5 " Small update 2010 Jul 28 by Maxim Kim
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
233
fca8a9b65afa updated for version 7.0065
vimboss
parents: 9
diff changeset
12 setlocal autoindent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 setlocal indentexpr=VbGetIndent(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 setlocal indentkeys&
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
15 setlocal indentkeys+==~else,=~elseif,=~end,=~wend,=~case,=~next,=~select,=~loop,<:>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
233
fca8a9b65afa updated for version 7.0065
vimboss
parents: 9
diff changeset
17 let b:undo_indent = "set ai< indentexpr< indentkeys<"
fca8a9b65afa updated for version 7.0065
vimboss
parents: 9
diff changeset
18
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 " Only define the function once.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 if exists("*VbGetIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 fun! VbGetIndent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 " labels and preprocessor get zero indent immediately
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 let this_line = getline(a:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 let LABELS_OR_PREPROC = '^\s*\(\<\k\+\>:\s*$\|#.*\)'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 if this_line =~? LABELS_OR_PREPROC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 " Find a non-blank line above the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 " Skip over labels and preprocessor directives.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 let lnum = a:lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 while lnum > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 let lnum = prevnonblank(lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 let previous_line = getline(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 if previous_line !~? LABELS_OR_PREPROC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 break
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 " Hit the start of the file, use zero indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 " Add
2432
80229a724a11 Updated runtime files. :TOhtml improvements by Benjamin Fritz.
Bram Moolenaar <bram@vim.org>
parents: 2421
diff changeset
51 if previous_line =~? '^\s*\<\(begin\|\%(\%(private\|public\|friend\)\s\+\)\=\%(function\|sub\|property\)\|select\|case\|default\|if\|else\|elseif\|do\|for\|while\|enum\|with\)\>'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 let ind = ind + &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 " Subtract
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 if this_line =~? '^\s*\<end\>\s\+\<select\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 if previous_line !~? '^\s*\<select\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 let ind = ind - 2 * &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 " this case is for an empty 'select' -- 'end select'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 " (w/o any case statements) like:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 " select case readwrite
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 " end select
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 let ind = ind - &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 endif
2421
c0e675a3e363 Minor runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 233
diff changeset
67 elseif this_line =~? '^\s*\<\(end\|else\|elseif\|until\|loop\|next\|wend\)\>'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 let ind = ind - &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 elseif this_line =~? '^\s*\<\(case\|default\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 if previous_line !~? '^\s*\<select\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 let ind = ind - &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 endfun
2421
c0e675a3e363 Minor runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 233
diff changeset
77
c0e675a3e363 Minor runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 233
diff changeset
78 " vim:sw=4