annotate runtime/ftplugin/cobol.vim @ 17907:4cf69f8d1ec6 v8.1.1950

patch 8.1.1950: using NULL pointer after an out-of-memory Commit: https://github.com/vim/vim/commit/4bbfb0f3cc67c00c8cee4e47283e8d760025219d Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 31 15:28:02 2019 +0200 patch 8.1.1950: using NULL pointer after an out-of-memory Problem: Using NULL pointer after an out-of-memory. Solution: Check for NULL pointer. (Dominique Pelle, closes https://github.com/vim/vim/issues/4881)
author Bram Moolenaar <Bram@vim.org>
date Sat, 31 Aug 2019 15:30:04 +0200
parents bd7461db24b3
children 0db0640e16e0
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>)
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 5618
diff changeset
5 " Last Update: By Ankit Jain (changed maintainer) on 22.03.2019
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
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
40 if has("gui_win32") && !exists("b:browsefilter")
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
41 let b:browsefilter = "COBOL Source Files (*.cbl, *.cob)\t*.cbl;*.cob;*.lib\n".
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
42 \ "All Files (*.*)\t*.*\n"
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
43 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
44
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
45 let b:undo_ftplugin = "setlocal com< cms< fo< et< tw<" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
46 \ " | unlet! b:browsefilter b:match_words b:match_ignorecase b:match_skip"
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
47 if !exists("g:no_plugin_maps") && !exists("g:no_cobol_maps")
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
48 let b:undo_ftplugin = b:undo_ftplugin .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
49 \ " | sil! exe 'nunmap <buffer> <'" .
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 'vunmap <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 'iunmap <buffer> <C-D>'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
56 \ " | sil! exe 'iunmap <buffer> <C-T>'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
57 \ " | sil! exe 'iunmap <buffer> <Tab>'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
58 \ " | sil! exe 'nunmap <buffer> <Plug>Traditional'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
59 \ " | sil! exe 'nunmap <buffer> <Plug>Comment'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
60 \ " | sil! exe 'nunmap <buffer> <Plug>DeComment'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
61 \ " | sil! exe 'vunmap <buffer> <Plug>VisualTraditional'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
62 \ " | sil! exe 'vunmap <buffer> <Plug>VisualComment'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
63 \ " | sil! exe 'iunmap <buffer> <Plug>VisualDeComment'" .
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
64 \ " | sil! exe 'unmap <buffer> [['" .
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 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
69
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
70 if !exists("g:no_plugin_maps") && !exists("g:no_cobol_maps")
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
71 if version >= 700
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
72 nnoremap <silent> <buffer> > :set opfunc=<SID>IncreaseFunc<CR>g@
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
73 nnoremap <silent> <buffer> < :set opfunc=<SID>DecreaseFunc<CR>g@
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
74 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
75 nnoremap <silent> <buffer> >> :call CobolIndentBlock(1)<CR>
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 vnoremap <silent> <buffer> > :call CobolIndentBlock(v:count1)<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 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
80 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
81 if !maparg("<Tab>","i")
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
82 inoremap <silent> <buffer> <Tab> <C-R>=<SID>Tab()<CR><C-R>=<SID>RestoreShiftwidth()<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
83 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
84 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
85 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
86 noremap <silent> <buffer> [] m':call <SID>toend('b')<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
87 noremap <silent> <buffer> ][ m':call <SID>toend('')<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
88 " For EnhancedCommentify
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
89 noremap <silent> <buffer> <Plug>Traditional :call <SID>Comment('t')<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
90 noremap <silent> <buffer> <Plug>Comment :call <SID>Comment('c')<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
91 noremap <silent> <buffer> <Plug>DeComment :call <SID>Comment('u')<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
92 noremap <silent> <buffer> <Plug>VisualTraditional :'<,'>call <SID>Comment('t')<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
93 noremap <silent> <buffer> <Plug>VisualComment :'<,'>call <SID>Comment('c')<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
94 noremap <silent> <buffer> <Plug>VisualDeComment :'<,'>call <SID>Comment('u')<CR>
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
95 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
96
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
97 let &cpo = s:cpo_save
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
98 unlet s:cpo_save
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
99
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
100 if exists("g:did_cobol_ftplugin_functions")
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
101 finish
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
102 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
103 let g:did_cobol_ftplugin_functions = 1
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
104
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
105 function! s:repeat(str,count)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
106 let i = 0
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
107 let ret = ""
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
108 while i < a:count
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
109 let ret = ret . a:str
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
110 let i = i + 1
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
111 endwhile
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
112 return ret
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
113 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
114
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
115 function! s:increase(...)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
116 let lnum = '.'
5618
350272cbf1fd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
117 let sw = shiftwidth()
1121
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
118 let i = a:0 ? a:1 : indent(lnum)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
119 if i >= 11
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
120 return sw - (i - 11) % sw
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
121 elseif i >= 7
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
122 return 11-i
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
123 elseif i == 6
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
124 return 1
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
125 else
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
126 return 6-i
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
127 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
128 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
129
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
130 function! s:decrease(...)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
131 let lnum = '.'
5618
350272cbf1fd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
132 let sw = shiftwidth()
1121
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
133 let i = indent(a:0 ? a:1 : lnum)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
134 if i >= 11 + sw
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
135 return 1 + (i + 12) % sw
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
136 elseif i > 11
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
137 return i-11
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
138 elseif i > 7
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
139 return i-7
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
140 elseif i == 7
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
141 return 1
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
142 else
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
143 return i
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
144 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
145 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
146
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
147 function! CobolIndentBlock(shift)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
148 let head = strpart(getline('.'),0,7)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
149 let tail = strpart(getline('.'),7)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
150 let indent = match(tail,'[^ ]')
5618
350272cbf1fd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
151 let sw = shiftwidth()
1121
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
152 let shift = a:shift
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
153 if shift > 0
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
154 if indent < 4
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
155 let tail = s:repeat(" ",4-indent).tail
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
156 let shift = shift - 1
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
157 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
158 let tail = s:repeat(" ",shift*sw).tail
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
159 let shift = 0
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
160 elseif shift < 0
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
161 if (indent-4) > -shift * sw
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
162 let tail = strpart(tail,-shift * sw)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
163 elseif (indent-4) > (-shift-1) * sw
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
164 let tail = strpart(tail,indent - 4)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
165 else
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
166 let tail = strpart(tail,indent)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
167 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
168 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
169 call setline('.',head.tail)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
170 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
171
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
172 function! s:IncreaseFunc(type)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
173 '[,']call CobolIndentBlock(1)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
174 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
175
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
176 function! s:DecreaseFunc(type)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
177 '[,']call CobolIndentBlock(-1)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
178 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
179
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
180 function! s:IncreaseIndent()
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
181 let c = "\<C-T>"
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
182 if exists("*InsertCtrlTWrapper")
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
183 let key = InsertCtrlTWrapper()
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
184 if key != c
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
185 return key
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
186 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
187 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
188 let interval = s:increase()
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
189 let b:cobol_shiftwidth = &shiftwidth
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
190 let &shiftwidth = 1
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
191 let lastchar = strpart(getline('.'),col('.')-2,1)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
192 if lastchar == '0' || lastchar == '^'
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
193 return "\<BS>".lastchar.c
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
194 else
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
195 return s:repeat(c,interval)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
196 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
197 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
198
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
199 function! s:DecreaseIndent()
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
200 let c = "\<C-D>"
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
201 if exists("*InsertCtrlDWrapper")
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
202 " I hack Ctrl-D to delete when not at the end of the line.
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
203 let key = InsertCtrlDWrapper()
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
204 if key != c
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
205 return key
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
206 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
207 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
208 let interval = s:decrease()
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
209 let b:cobol_shiftwidth = &shiftwidth
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
210 let &shiftwidth = 1
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
211 return s:repeat(c,interval)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
212 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
213
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
214 function! s:RestoreShiftwidth()
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
215 if exists("b:cobol_shiftwidth")
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
216 let &shiftwidth=b:cobol_shiftwidth
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
217 unlet b:cobol_shiftwidth
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
218 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
219 return ""
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
220 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
221
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
222 function! s:Tab()
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
223 if (strpart(getline('.'),0,col('.')-1) =~ '^\s*$' && &sta)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
224 return s:IncreaseIndent()
5618
350272cbf1fd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
225 " &softtabstop < 0: &softtabstop follows &shiftwidth
350272cbf1fd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
226 elseif (&sts < 0 || &sts == shiftwidth()) && &sts != 8 && &et
1121
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
227 return s:repeat(" ",s:increase(col('.')-1))
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
228 else
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
229 return "\<Tab>"
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
230 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
231 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
232
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
233 function! s:Comment(arg)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
234 " For EnhancedCommentify
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
235 let line = getline('.')
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
236 if (line =~ '^.\{6\}[*/C]' || a:arg == 'c') && a:arg != 'u'
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
237 let line = substitute(line,'^.\{6\}\zs.',' ','')
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
238 else
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
239 let line = substitute(line,'^.\{6\}\zs.','*','')
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
240 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
241 call setline('.',line)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
242 endfunction
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
243
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
244 function! s:toend(direction)
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
245 let ignore = '^\(\s*\|.\{6\}\)\%([*/]\|\s*$\)'
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
246 let keep = line('.')
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
247 keepjumps +
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
248 while line('.') < line('$') && getline('.') =~ ignore
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
249 keepjumps +
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
250 endwhile
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
251 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
252 if a:direction != 'b' && !res
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
253 let res = line('$')
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
254 keepjumps $
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
255 elseif res
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
256 keepjumps -
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
257 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
258 if res
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
259 while line('.') > 1 && getline('.') =~ ignore
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
260 keepjumps -
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
261 endwhile
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
262 if line('.') == 1 && getline('.') =~ ignore
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
263 exe "keepjumps ".keep
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
264 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
265 else
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
266 exe "keepjumps ".keep
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
267 endif
e63691e7c504 updated for version 7.1a
vimboss
parents:
diff changeset
268 endfunction