annotate runtime/ftplugin/cobol.vim @ 28711:9ef5ee193725

Added tag v8.2.4879 for changeset 54e33757d1ecd86015cdf1dbfac4bfb9063c08ea
author Bram Moolenaar <Bram@vim.org>
date Fri, 06 May 2022 12:30:04 +0200
parents 0db0640e16e0
children 8ae680be2a51
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1121
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
1 " Vim filetype plugin file
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
2 " Language: cobol
16086
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 5618
diff changeset
3 " Maintainer: Ankit Jain <ajatkj@yahoo.co.in>
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 5618
diff changeset
4 " (formerly Tim Pope <vimNOSPAM@tpope.info>)
21825
0db0640e16e0 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
5 " Last Update: By Ankit Jain (add gtk support) on 15.08.2020
1121
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
6
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
7 " Insert mode mappings: <C-T> <C-D> <Tab>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
8 " Normal mode mappings: < > << >> [[ ]] [] ][
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
9 " Visual mode mappings: < >
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
10
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
11 if exists("b:did_ftplugin")
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
12 finish
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
13 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
14 let b:did_ftplugin = 1
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
15
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
16 let s:cpo_save = &cpo
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
17 set cpo&vim
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
18
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
19 setlocal commentstring=\ \ \ \ \ \ *%s
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
20 setlocal comments=:*
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
21 setlocal fo+=croqlt
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
22 setlocal expandtab
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
23 setlocal textwidth=72
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
24
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
25 " matchit support
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
26 if exists("loaded_matchit")
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
27 let s:ordot = '\|\ze\.\%( \@=\|$\)'
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
28 let b:match_ignorecase=1
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
29 "let b:match_skip = 'getline(".") =~ "^.\\{6\\}[*/C]"'
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
30 let b:match_words=
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
31 \ '\$if\>:$else\>:\$endif\>,' .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
32 \ '[$-]\@<!\<if\>:\<\%(then\|else\)\>:\<end-if\>'.s:ordot.',' .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
33 \ '-\@<!\<perform\s\+\%(\d\+\s\+times\|until\|varying\|with\s\+test\)\>:\<end-perform\>'.s:ordot . ',' .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
34 \ '-\@<!\<\%(search\|evaluate\)\>:\<\%(when\)\>:\<end-\%(search\|evaluate\)\>' .s:ordot . ',' .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
35 \ '-\@<!\<\%(add\|compute\|divide\|multiply\|subtract\)\>\%(.*\(\%$\|\%(\n\%(\%(\s*\|.\{6\}\)[*/].*\n\)*\)\=\s*\%(not\s\+\)\=on\s\+size\s\+error\>\)\)\@=:\%(\<not\s\+\)\@<!\<\%(not\s\+\)\=on\s\+size\s\+error\>:\<end-\%(add\|compute\|divide\|multiply\|subtract\)\>' .s:ordot . ',' .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
36 \ '-\@<!\<\%(string\|unstring\|accept\|display\|call\)\>\%(.*\(\%$\|\%(\n\%(\%(\s*\|.\{6\}\)[*/].*\n\)*\)\=\s*\%(not\s\+\)\=on\s\+\%(overflow\|exception\)\>\)\)\@=:\%(\<not\s\+\)\@<!\<\%(not\s\+\)\=on\s\+\%(overflow\|exception\)\>:\<end-\%(string\|unstring\|accept\|display\|call\)\>' .s:ordot . ',' .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
37 \ '-\@<!\<\%(delete\|rewrite\|start\|write\|read\)\>\%(.*\(\%$\|\%(\n\%(\%(\s*\|.\{6\}\)[*/].*\n\)*\)\=\s*\%(invalid\s\+key\|at\s\+end\|no\s\+data\|at\s\+end-of-page\)\>\)\)\@=:\%(\<not\s\+\)\@<!\<\%(not\s\+\)\=\%(invalid\s\+key\|at\s\+end\|no\s\+data\|at\s\+end-of-page\)\>:\<end-\%(delete\|rewrite\|start\|write\|read\)\>' .s:ordot
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
38 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
39
21825
0db0640e16e0 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
40 " add gtk support
0db0640e16e0 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
41 if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
1121
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
42 let b:browsefilter = "COBOL Source Files (*.cbl, *.cob)\t*.cbl;*.cob;*.lib\n".
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
43 \ "All Files (*.*)\t*.*\n"
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
44 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
45
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
46 let b:undo_ftplugin = "setlocal com< cms< fo< et< tw<" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
47 \ " | unlet! b:browsefilter b:match_words b:match_ignorecase b:match_skip"
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
48 if !exists("g:no_plugin_maps") && !exists("g:no_cobol_maps")
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
49 let b:undo_ftplugin = b:undo_ftplugin .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
50 \ " | sil! exe 'nunmap <buffer> <'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
51 \ " | sil! exe 'nunmap <buffer> >'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
52 \ " | sil! exe 'nunmap <buffer> <<'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
53 \ " | sil! exe 'nunmap <buffer> >>'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
54 \ " | sil! exe 'vunmap <buffer> <'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
55 \ " | sil! exe 'vunmap <buffer> >'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
56 \ " | sil! exe 'iunmap <buffer> <C-D>'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
57 \ " | sil! exe 'iunmap <buffer> <C-T>'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
58 \ " | sil! exe 'iunmap <buffer> <Tab>'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
59 \ " | sil! exe 'nunmap <buffer> <Plug>Traditional'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
60 \ " | sil! exe 'nunmap <buffer> <Plug>Comment'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
61 \ " | sil! exe 'nunmap <buffer> <Plug>DeComment'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
62 \ " | sil! exe 'vunmap <buffer> <Plug>VisualTraditional'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
63 \ " | sil! exe 'vunmap <buffer> <Plug>VisualComment'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
64 \ " | sil! exe 'iunmap <buffer> <Plug>VisualDeComment'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
65 \ " | sil! exe 'unmap <buffer> [['" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
66 \ " | sil! exe 'unmap <buffer> ]]'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
67 \ " | sil! exe 'unmap <buffer> []'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
68 \ " | sil! exe 'unmap <buffer> ]['"
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
69 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
70
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
71 if !exists("g:no_plugin_maps") && !exists("g:no_cobol_maps")
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
72 if version >= 700
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
73 nnoremap <silent> <buffer> > :set opfunc=<SID>IncreaseFunc<CR>g@
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
74 nnoremap <silent> <buffer> < :set opfunc=<SID>DecreaseFunc<CR>g@
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
75 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
76 nnoremap <silent> <buffer> >> :call CobolIndentBlock(1)<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
77 nnoremap <silent> <buffer> << :call CobolIndentBlock(-1)<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
78 vnoremap <silent> <buffer> > :call CobolIndentBlock(v:count1)<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
79 vnoremap <silent> <buffer> < :call CobolIndentBlock(-v:count1)<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
80 inoremap <silent> <buffer> <C-T> <C-R>=<SID>IncreaseIndent()<CR><C-R>=<SID>RestoreShiftwidth()<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
81 inoremap <silent> <buffer> <C-D> <C-R>=<SID>DecreaseIndent()<CR><C-R>=<SID>RestoreShiftwidth()<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
82 if !maparg("<Tab>","i")
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
83 inoremap <silent> <buffer> <Tab> <C-R>=<SID>Tab()<CR><C-R>=<SID>RestoreShiftwidth()<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
84 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
85 noremap <silent> <buffer> [[ m':call search('\c^\%(\s*\<Bar>.\{6\}\s\+\)\zs[A-Za-z0-9-]\+\s\+\%(division\<Bar>section\)\s*\.','bW')<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
86 noremap <silent> <buffer> ]] m':call search('\c^\%(\s*\<Bar>.\{6\}\s\+\)\zs[A-Za-z0-9-]\+\s\+\%(division\<Bar>section\)\.','W')<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
87 noremap <silent> <buffer> [] m':call <SID>toend('b')<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
88 noremap <silent> <buffer> ][ m':call <SID>toend('')<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
89 " For EnhancedCommentify
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
90 noremap <silent> <buffer> <Plug>Traditional :call <SID>Comment('t')<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
91 noremap <silent> <buffer> <Plug>Comment :call <SID>Comment('c')<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
92 noremap <silent> <buffer> <Plug>DeComment :call <SID>Comment('u')<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
93 noremap <silent> <buffer> <Plug>VisualTraditional :'<,'>call <SID>Comment('t')<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
94 noremap <silent> <buffer> <Plug>VisualComment :'<,'>call <SID>Comment('c')<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
95 noremap <silent> <buffer> <Plug>VisualDeComment :'<,'>call <SID>Comment('u')<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
96 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
97
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
98 let &cpo = s:cpo_save
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
99 unlet s:cpo_save
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
100
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
101 if exists("g:did_cobol_ftplugin_functions")
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
102 finish
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
103 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
104 let g:did_cobol_ftplugin_functions = 1
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
105
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
106 function! s:repeat(str,count)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
107 let i = 0
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
108 let ret = ""
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
109 while i < a:count
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
110 let ret = ret . a:str
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
111 let i = i + 1
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
112 endwhile
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
113 return ret
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
114 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
115
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
116 function! s:increase(...)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
117 let lnum = '.'
5618
350272cbf1fd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
118 let sw = shiftwidth()
1121
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
119 let i = a:0 ? a:1 : indent(lnum)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
120 if i >= 11
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
121 return sw - (i - 11) % sw
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
122 elseif i >= 7
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
123 return 11-i
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
124 elseif i == 6
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
125 return 1
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
126 else
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
127 return 6-i
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
128 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
129 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
130
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
131 function! s:decrease(...)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
132 let lnum = '.'
5618
350272cbf1fd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
133 let sw = shiftwidth()
1121
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
134 let i = indent(a:0 ? a:1 : lnum)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
135 if i >= 11 + sw
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
136 return 1 + (i + 12) % sw
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
137 elseif i > 11
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
138 return i-11
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
139 elseif i > 7
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
140 return i-7
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
141 elseif i == 7
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
142 return 1
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
143 else
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
144 return i
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
145 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
146 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
147
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
148 function! CobolIndentBlock(shift)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
149 let head = strpart(getline('.'),0,7)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
150 let tail = strpart(getline('.'),7)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
151 let indent = match(tail,'[^ ]')
5618
350272cbf1fd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
152 let sw = shiftwidth()
1121
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
153 let shift = a:shift
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
154 if shift > 0
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
155 if indent < 4
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
156 let tail = s:repeat(" ",4-indent).tail
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
157 let shift = shift - 1
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
158 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
159 let tail = s:repeat(" ",shift*sw).tail
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
160 let shift = 0
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
161 elseif shift < 0
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
162 if (indent-4) > -shift * sw
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
163 let tail = strpart(tail,-shift * sw)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
164 elseif (indent-4) > (-shift-1) * sw
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
165 let tail = strpart(tail,indent - 4)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
166 else
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
167 let tail = strpart(tail,indent)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
168 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
169 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
170 call setline('.',head.tail)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
171 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
172
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
173 function! s:IncreaseFunc(type)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
174 '[,']call CobolIndentBlock(1)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
175 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
176
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
177 function! s:DecreaseFunc(type)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
178 '[,']call CobolIndentBlock(-1)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
179 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
180
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
181 function! s:IncreaseIndent()
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
182 let c = "\<C-T>"
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
183 if exists("*InsertCtrlTWrapper")
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
184 let key = InsertCtrlTWrapper()
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
185 if key != c
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
186 return key
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
187 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
188 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
189 let interval = s:increase()
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
190 let b:cobol_shiftwidth = &shiftwidth
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
191 let &shiftwidth = 1
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
192 let lastchar = strpart(getline('.'),col('.')-2,1)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
193 if lastchar == '0' || lastchar == '^'
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
194 return "\<BS>".lastchar.c
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
195 else
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
196 return s:repeat(c,interval)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
197 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
198 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
199
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
200 function! s:DecreaseIndent()
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
201 let c = "\<C-D>"
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
202 if exists("*InsertCtrlDWrapper")
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
203 " I hack Ctrl-D to delete when not at the end of the line.
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
204 let key = InsertCtrlDWrapper()
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
205 if key != c
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
206 return key
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
207 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
208 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
209 let interval = s:decrease()
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
210 let b:cobol_shiftwidth = &shiftwidth
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
211 let &shiftwidth = 1
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
212 return s:repeat(c,interval)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
213 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
214
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
215 function! s:RestoreShiftwidth()
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
216 if exists("b:cobol_shiftwidth")
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
217 let &shiftwidth=b:cobol_shiftwidth
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
218 unlet b:cobol_shiftwidth
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
219 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
220 return ""
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
221 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
222
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
223 function! s:Tab()
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
224 if (strpart(getline('.'),0,col('.')-1) =~ '^\s*$' && &sta)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
225 return s:IncreaseIndent()
5618
350272cbf1fd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
226 " &softtabstop < 0: &softtabstop follows &shiftwidth
350272cbf1fd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
227 elseif (&sts < 0 || &sts == shiftwidth()) && &sts != 8 && &et
1121
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
228 return s:repeat(" ",s:increase(col('.')-1))
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
229 else
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
230 return "\<Tab>"
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
231 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
232 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
233
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
234 function! s:Comment(arg)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
235 " For EnhancedCommentify
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
236 let line = getline('.')
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
237 if (line =~ '^.\{6\}[*/C]' || a:arg == 'c') && a:arg != 'u'
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
238 let line = substitute(line,'^.\{6\}\zs.',' ','')
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
239 else
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
240 let line = substitute(line,'^.\{6\}\zs.','*','')
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
241 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
242 call setline('.',line)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
243 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
244
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
245 function! s:toend(direction)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
246 let ignore = '^\(\s*\|.\{6\}\)\%([*/]\|\s*$\)'
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
247 let keep = line('.')
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
248 keepjumps +
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
249 while line('.') < line('$') && getline('.') =~ ignore
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
250 keepjumps +
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
251 endwhile
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
252 let res = search('\c^\%(\s*\|.\{6\}\s\+\)\zs[A-Za-z0-9-]\+\s\+\%(division\|section\)\s*\.',a:direction.'W')
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
253 if a:direction != 'b' && !res
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
254 let res = line('$')
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
255 keepjumps $
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
256 elseif res
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
257 keepjumps -
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
258 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
259 if res
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
260 while line('.') > 1 && getline('.') =~ ignore
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
261 keepjumps -
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
262 endwhile
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
263 if line('.') == 1 && getline('.') =~ ignore
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
264 exe "keepjumps ".keep
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
265 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
266 else
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
267 exe "keepjumps ".keep
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
268 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
269 endfunction