annotate runtime/ftplugin/cobol.vim @ 34277:0386bb1f6e2f

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