summaryrefslogtreecommitdiffstats
path: root/runtime/indent/vb.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2004-06-13 20:20:40 +0000
committerBram Moolenaar <Bram@vim.org>2004-06-13 20:20:40 +0000
commit071d4279d6ab81b7187b48f3a0fc61e587b6db6c (patch)
tree221cbe3c40e043163c06f61c52a7ba2eb41e12ce /runtime/indent/vb.vim
parentb4210b3bc14e2918f153a7307530fbe6eba659e1 (diff)
updated for version 7.0001v7.0001
Diffstat (limited to 'runtime/indent/vb.vim')
-rw-r--r--runtime/indent/vb.vim72
1 files changed, 72 insertions, 0 deletions
diff --git a/runtime/indent/vb.vim b/runtime/indent/vb.vim
new file mode 100644
index 0000000000..515e4dc6b6
--- /dev/null
+++ b/runtime/indent/vb.vim
@@ -0,0 +1,72 @@
+" Vim indent file
+" Language: VisualBasic (ft=vb) / Basic (ft=basic) / SaxBasic (ft=vb)
+" Author: Johannes Zellner <johannes@zellner.org>
+" Last Change: Tue, 27 Apr 2004 14:54:59 CEST
+
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=VbGetIndent(v:lnum)
+setlocal indentkeys&
+setlocal indentkeys+==~else,=~elseif,=~end,=~wend,=~case,=~next,=~select,~=loop,<:>
+
+" Only define the function once.
+if exists("*VbGetIndent")
+ finish
+endif
+
+fun! VbGetIndent(lnum)
+ " labels and preprocessor get zero indent immediately
+ let this_line = getline(a:lnum)
+ let LABELS_OR_PREPROC = '^\s*\(\<\k\+\>:\s*$\|#.*\)'
+ if this_line =~? LABELS_OR_PREPROC
+ return 0
+ endif
+
+ " Find a non-blank line above the current line.
+ " Skip over labels and preprocessor directives.
+ let lnum = a:lnum
+ while lnum > 0
+ let lnum = prevnonblank(lnum - 1)
+ let previous_line = getline(lnum)
+ if previous_line !~? LABELS_OR_PREPROC
+ break
+ endif
+ endwhile
+
+ " Hit the start of the file, use zero indent.
+ if lnum == 0
+ return 0
+ endif
+
+ let ind = indent(lnum)
+
+ " Add
+ if previous_line =~? '^\s*\<\(begin\|\%(\%(private\|public\|friend\)\s\+\)\=\%(function\|sub\|property\)\|select\|case\|default\|if\>.\{-}\<then\>\s*$\|else\|elseif\|do\|for\|while\|enum\|with\)\>'
+ let ind = ind + &sw
+ endif
+
+ " Subtract
+ if this_line =~? '^\s*\<end\>\s\+\<select\>'
+ if previous_line !~? '^\s*\<select\>'
+ let ind = ind - 2 * &sw
+ else
+ " this case is for an empty 'select' -- 'end select'
+ " (w/o any case statements) like:
+ "
+ " select case readwrite
+ " end select
+ let ind = ind - &sw
+ endif
+ elseif this_line =~? '^\s*\<\(end\|else\|until\|loop\|next\|wend\)\>'
+ let ind = ind - &sw
+ elseif this_line =~? '^\s*\<\(case\|default\)\>'
+ if previous_line !~? '^\s*\<select\>'
+ let ind = ind - &sw
+ endif
+ endif
+
+ return ind
+endfun