annotate runtime/ftplugin/cobol.vim @ 6880:bcc0909b379e v7.4.760

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