7
|
1 " Vim filetype plugin file
|
26219
|
2 " Language: Visual Basic (ft=vb)
|
|
3 " Maintainer: Doug Kearns <dougkearns@gmail.com>
|
|
4 " Previous Maintainer: Johannes Zellner <johannes@zellner.org>
|
|
5 " Last Change: 2021 Nov 17
|
7
|
6
|
26219
|
7 if exists("b:did_ftplugin")
|
|
8 finish
|
|
9 endif
|
7
|
10 let b:did_ftplugin = 1
|
|
11
|
26219
|
12 let s:cpo_save = &cpo
|
|
13 set cpo&vim
|
|
14
|
|
15 setlocal comments=sr:'\ -,mb:'\ \ ,el:'\ \ ,:'
|
|
16 setlocal commentstring='\ %s
|
|
17 setlocal formatoptions-=t formatoptions+=croql
|
|
18
|
|
19 let b:undo_ftplugin = "setlocal com< cms< fo<"
|
7
|
20
|
|
21 " we need this wrapper, as call doesn't allow a count
|
26219
|
22 function! s:VbSearch(pattern, flags)
|
7
|
23 let cnt = v:count1
|
|
24 while cnt > 0
|
|
25 call search(a:pattern, a:flags)
|
|
26 let cnt = cnt - 1
|
|
27 endwhile
|
26219
|
28 endfunction
|
7
|
29
|
26219
|
30 if !exists("no_plugin_maps") && !exists("no_vb_maps")
|
|
31 nnoremap <buffer> <silent> [[ <Cmd>call <SID>VbSearch('^\s*\%(\%(private\<Bar>public\)\s\+\)\=\%(function\<Bar>sub\)', 'sbW')<CR>
|
|
32 vnoremap <buffer> <silent> [[ <Cmd>call <SID>VbSearch('^\s*\%(\%(private\<Bar>public\)\s\+\)\=\%(function\<Bar>sub\)', 'sbW')<CR>
|
|
33 nnoremap <buffer> <silent> ]] <Cmd>call <SID>VbSearch('^\s*\%(\%(private\<Bar>public\)\s\+\)\=\%(function\<Bar>sub\)', 'sW')<CR>
|
|
34 vnoremap <buffer> <silent> ]] <Cmd>call <SID>VbSearch('^\s*\%(\%(private\<Bar>public\)\s\+\)\=\%(function\<Bar>sub\)', 'sW')<CR>
|
|
35 nnoremap <buffer> <silent> [] <Cmd>call <SID>VbSearch('^\s*end\s\+\%(function\<Bar>sub\)', 'sbW')<CR>
|
|
36 vnoremap <buffer> <silent> [] <Cmd>call <SID>VbSearch('^\s*end\s\+\%(function\<Bar>sub\)', 'sbW')<CR>
|
|
37 nnoremap <buffer> <silent> ][ <Cmd>call <SID>VbSearch('^\s*end\s\+\%(function\<Bar>sub\)', 'sW')<CR>
|
|
38 vnoremap <buffer> <silent> ][ <Cmd>call <SID>VbSearch('^\s*end\s\+\%(function\<Bar>sub\)', 'sW')<CR>
|
|
39 let b:undo_ftplugin .= " | sil! exe 'nunmap <buffer> [[' | sil! exe 'vunmap <buffer> [['" .
|
|
40 \ " | sil! exe 'nunmap <buffer> ]]' | sil! exe 'vunmap <buffer> ]]'" .
|
|
41 \ " | sil! exe 'nunmap <buffer> []' | sil! exe 'vunmap <buffer> []'" .
|
|
42 \ " | sil! exe 'nunmap <buffer> ][' | sil! exe 'vunmap <buffer> ]['"
|
|
43 endif
|
7
|
44
|
26219
|
45 " TODO: line start anchors are almost certainly overly restrictive - allow
|
|
46 " after statement separators. Even in QuickBasic only block IF statements
|
|
47 " were required to be at the start of a line.
|
|
48 if exists("loaded_matchit") && !exists("b:match_words")
|
|
49 let b:match_ignorecase = 1
|
|
50 let b:match_words =
|
|
51 \ '\%(^\s*\)\@<=\<if\>.*\<then\>\s*\%($\|''\):\%(^\s*\)\@<=\<else\>:\%(^\s*\)\@<=\<elseif\>:\%(^\s*\)\@<=\<end\>\s\+\<if\>,' .
|
|
52 \ '\%(^\s*\)\@<=\<for\>:\%(^\s*\)\@<=\<next\>,' .
|
|
53 \ '\%(^\s*\)\@<=\<while\>:\%(^\s*\)\@<=\<wend\>,' .
|
|
54 \ '\%(^\s*\)\@<=\<do\>:\%(^\s*\)\@<=\<loop\>\s\+\<while\>,' .
|
|
55 \ '\%(^\s*\)\@<=\<select\>\s\+\<case\>:\%(^\s*\)\@<=\<case\>:\%(^\s*\)\@<=\<end\>\s\+\<select\>,' .
|
|
56 \ '\%(^\s*\)\@<=\<enum\>:\%(^\s*\)\@<=\<end\>\s\<enum\>,' .
|
|
57 \ '\%(^\s*\)\@<=\<with\>:\%(^\s*\)\@<=\<end\>\s\<with\>,' .
|
|
58 \ '\%(^\s*\)\@<=\%(\<\%(private\|public\)\>\s\+\)\=\<function\>\s\+\([^ \t(]\+\):\%(^\s*\)\@<=\<\1\>\s*=:\%(^\s*\)\@<=\<end\>\s\+\<function\>,' .
|
|
59 \ '\%(^\s*\)\@<=\%(\<\%(private\|public\)\>\s\+\)\=\<sub\>\s\+:\%(^\s*\)\@<=\<end\>\s\+\<sub\>'
|
|
60 let b:undo_ftplugin .= " | unlet! b:match_words b:match_ignorecase"
|
|
61 endif
|
|
62
|
|
63 if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
|
|
64 let b:browsefilter = "Visual Basic Source Files (*.bas)\t*.bas\n" .
|
|
65 \ "Visual Basic Form Files (*.frm)\t*.frm\n" .
|
|
66 \ "All Files (*.*)\t*.*\n"
|
|
67 let b:undo_ftplugin .= " | unlet! b:browsefilter"
|
7
|
68 endif
|
|
69
|
|
70 let &cpo = s:cpo_save
|
|
71 unlet s:cpo_save
|