annotate runtime/indent/cobol.vim @ 27317:839be955609f v8.2.4187

patch 8.2.4187: gnuplot file not recognized Commit: https://github.com/vim/vim/commit/ff5cbe8133c6eb5dd86b9e042f32f589627e9bf9 Author: nobodyatandnothing <you@example.com> Date: Sun Jan 23 11:19:37 2022 +0000 patch 8.2.4187: gnuplot file not recognized Problem: Gnuplot file not recognized. Solution: Recognize ".gnuplot". (closes https://github.com/vim/vim/issues/9588)
author Bram Moolenaar <Bram@vim.org>
date Sun, 23 Jan 2022 12:30:04 +0100
parents 9c221ad9634a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
1 " Vim indent file
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
2 " Language: cobol
16086
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
3 " Maintainer: Ankit Jain <ajatkj@yahoo.co.in>
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
4 " (formerly Tim Pope <vimNOSPAM@tpope.info>)
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1125
diff changeset
5 " $Id: cobol.vim,v 1.1 2007/05/05 18:08:19 vimboss Exp $
16086
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
6 " Last Update: By Ankit Jain on 22.03.2019
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
7 " Ankit Jain 22.03.2019 Changes & fixes:
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
8 " Allow chars in 1st 6 columns
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
9 " #C22032019
25880
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
10 " Ankit Jain 24.09.2021 add b:undo_indent (request by tpope)
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
11
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
12 if exists("b:did_indent")
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
13 finish
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
14 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
15 let b:did_indent = 1
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
16
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
17 setlocal expandtab
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
18 setlocal indentexpr=GetCobolIndent(v:lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
19 setlocal indentkeys&
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
20 setlocal indentkeys+=0<*>,0/,0$,0=01,=~division,=~section,0=~end,0=~then,0=~else,0=~when,*<Return>,.
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
21
25880
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
22 let b:undo_indent = "setlocal expandtab< indentexpr< indentkeys<"
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
23
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
24 " Only define the function once.
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
25 if exists("*GetCobolIndent")
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
26 finish
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
27 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
28
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
29 let s:skip = 'getline(".") =~ "^.\\{6\\}[*/$-]\\|\"[^\"]*\""'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
30
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
31 function! s:prevgood(lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
32 " Find a non-blank line above the current line.
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
33 " Skip over comments.
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
34 let lnum = a:lnum
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
35 while lnum > 0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
36 let lnum = prevnonblank(lnum - 1)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
37 let line = getline(lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
38 if line !~? '^\s*[*/$-]' && line !~? '^.\{6\}[*/$CD-]'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
39 break
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
40 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
41 endwhile
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
42 return lnum
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
43 endfunction
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
44
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
45 function! s:stripped(lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
46 return substitute(strpart(getline(a:lnum),0,72),'^\s*','','')
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
47 endfunction
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
48
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
49 function! s:optionalblock(lnum,ind,blocks,clauses)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
50 let ind = a:ind
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
51 let clauses = '\c\<\%(\<NOT\s\+\)\@<!\%(NOT\s\+\)\=\%('.a:clauses.'\)'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
52 let begin = '\c-\@<!\<\%('.a:blocks.'\)\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
53 let beginfull = begin.'\ze.*\%(\n\%(\s*\%([*/$-].*\)\=\n\)*\)\=\s*\%('.clauses.'\)'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
54 let end = '\c\<end-\%('.a:blocks.'\)\>\|\%(\.\%( \|$\)\)\@='
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
55 let cline = s:stripped(a:lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
56 let line = s:stripped(s:prevgood(a:lnum))
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
57 if cline =~? clauses "&& line !~? '^search\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
58 call cursor(a:lnum,1)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
59 let lastclause = searchpair(beginfull,clauses,end,'bWr',s:skip)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
60 if getline(lastclause) =~? clauses && s:stripped(lastclause) !~? '^'.begin
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
61 let ind = indent(lastclause)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
62 elseif lastclause > 0
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2034
diff changeset
63 let ind = indent(lastclause) + shiftwidth()
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2034
diff changeset
64 "let ind = ind + shiftwidth()
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
65 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
66 elseif line =~? clauses && cline !~? end
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2034
diff changeset
67 let ind = ind + shiftwidth()
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
68 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
69 return ind
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
70 endfunction
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
71
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
72 function! GetCobolIndent(lnum) abort
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
73 let minshft = 6
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
74 let ashft = minshft + 1
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
75 let bshft = ashft + 4
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
76 " (Obsolete) numbered lines
16086
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
77 " #C22032019: Columns 1-6 could have alphabets as well as numbers
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
78 "if getline(a:lnum) =~? '^\s*\d\{6\}\%($\|[ */$CD-]\)'
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
79 if getline(a:lnum) =~? '^\s*[a-zA-Z0-9]\{6\}\%($\|[ */$CD-]\)'
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
80 return 0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
81 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
82 let cline = s:stripped(a:lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
83 " Comments, etc. must start in the 7th column
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
84 if cline =~? '^[*/$-]'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
85 return minshft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
86 elseif cline =~# '^[CD]' && indent(a:lnum) == minshft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
87 return minshft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
88 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
89 " Divisions, sections, and file descriptions start in area A
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
90 if cline =~? '\<\(DIVISION\|SECTION\)\%($\|\.\)' || cline =~? '^[FS]D\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
91 return ashft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
92 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
93 " Fields
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
94 if cline =~? '^0*\(1\|77\)\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
95 return ashft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
96 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
97 if cline =~? '^\d\+\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
98 let cnum = matchstr(cline,'^\d\+\>')
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
99 let default = 0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
100 let step = -1
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
101 while step < 2
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
102 let lnum = a:lnum
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
103 while lnum > 0 && lnum < line('$') && lnum > a:lnum - 500 && lnum < a:lnum + 500
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
104 let lnum = step > 0 ? nextnonblank(lnum + step) : prevnonblank(lnum + step)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
105 let line = getline(lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
106 let lindent = indent(lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
107 if line =~? '^\s*\d\+\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
108 let num = matchstr(line,'^\s*\zs\d\+\>')
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
109 if 0+cnum == num
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
110 return lindent
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2034
diff changeset
111 elseif 0+cnum > num && default < lindent + shiftwidth()
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2034
diff changeset
112 let default = lindent + shiftwidth()
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
113 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
114 elseif lindent < bshft && lindent >= ashft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
115 break
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
116 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
117 endwhile
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
118 let step = step + 2
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
119 endwhile
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
120 return default ? default : bshft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
121 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
122 let lnum = s:prevgood(a:lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
123 " Hit the start of the file, use "zero" indent.
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
124 if lnum == 0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
125 return ashft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
126 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
127 " Initial spaces are ignored
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
128 let line = s:stripped(lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
129 let ind = indent(lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
130 " Paragraphs. There may be some false positives.
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
131 if cline =~? '^\(\a[A-Z0-9-]*[A-Z0-9]\|\d[A-Z0-9-]*\a\)\.' "\s*$'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
132 if cline !~? '^EXIT\s*\.' && line =~? '\.\s*$'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
133 return ashft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
134 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
135 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
136 " Paragraphs in the identification division.
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
137 "if cline =~? '^\(PROGRAM-ID\|AUTHOR\|INSTALLATION\|' .
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
138 "\ 'DATE-WRITTEN\|DATE-COMPILED\|SECURITY\)\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
139 "return ashft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
140 "endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
141 if line =~? '\.$'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
142 " XXX
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
143 return bshft
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
144 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
145 if line =~? '^PERFORM\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
146 let perfline = substitute(line, '\c^PERFORM\s*', "", "")
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
147 if perfline =~? '^\%(\k\+\s\+TIMES\)\=\s*$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2034
diff changeset
148 let ind = ind + shiftwidth()
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
149 elseif perfline =~? '^\%(WITH\s\+TEST\|VARYING\|UNTIL\)\>.*[^.]$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2034
diff changeset
150 let ind = ind + shiftwidth()
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
151 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
152 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
153 if line =~? '^\%(IF\|THEN\|ELSE\|READ\|EVALUATE\|SEARCH\|SELECT\)\>'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2034
diff changeset
154 let ind = ind + shiftwidth()
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
155 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
156 let ind = s:optionalblock(a:lnum,ind,'ADD\|COMPUTE\|DIVIDE\|MULTIPLY\|SUBTRACT','ON\s\+SIZE\s\+ERROR')
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
157 let ind = s:optionalblock(a:lnum,ind,'STRING\|UNSTRING\|ACCEPT\|DISPLAY\|CALL','ON\s\+OVERFLOW\|ON\s\+EXCEPTION')
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
158 if cline !~? '^AT\s\+END\>' || line !~? '^SEARCH\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
159 let ind = s:optionalblock(a:lnum,ind,'DELETE\|REWRITE\|START\|WRITE\|READ','INVALID\s\+KEY\|AT\s\+END\|NO\s\+DATA\|AT\s\+END-OF-PAGE')
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
160 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
161 if cline =~? '^WHEN\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
162 call cursor(a:lnum,1)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
163 " We also search for READ so that contained AT ENDs are skipped
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
164 let lastclause = searchpair('\c-\@<!\<\%(SEARCH\|EVALUATE\|READ\)\>','\c\<\%(WHEN\|AT\s\+END\)\>','\c\<END-\%(SEARCH\|EVALUATE\|READ\)\>','bW',s:skip)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
165 let g:foo = s:stripped(lastclause)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
166 if s:stripped(lastclause) =~? '\c\<\%(WHEN\|AT\s\+END\)\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
167 "&& s:stripped(lastclause) !~? '^\%(SEARCH\|EVALUATE\|READ\)\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
168 let ind = indent(lastclause)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
169 elseif lastclause > 0
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2034
diff changeset
170 let ind = indent(lastclause) + shiftwidth()
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
171 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
172 elseif line =~? '^WHEN\>'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2034
diff changeset
173 let ind = ind + shiftwidth()
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
174 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
175 "I'm not sure why I had this
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
176 "if line =~? '^ELSE\>-\@!' && line !~? '\.$'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
177 "let ind = indent(s:prevgood(lnum))
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
178 "endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
179 if cline =~? '^\(END\)\>-\@!'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
180 " On lines with just END, 'guess' a simple shift left
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2034
diff changeset
181 let ind = ind - shiftwidth()
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
182 elseif cline =~? '^\(END-IF\|THEN\|ELSE\)\>-\@!'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
183 call cursor(a:lnum,indent(a:lnum))
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
184 let match = searchpair('\c-\@<!\<IF\>','\c-\@<!\%(THEN\|ELSE\)\>','\c-\@<!\<END-IF\>\zs','bnW',s:skip)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
185 if match > 0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
186 let ind = indent(match)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
187 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
188 elseif cline =~? '^END-[A-Z]'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
189 let beginword = matchstr(cline,'\c\<END-\zs[A-Z0-9-]\+')
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
190 let endword = 'END-'.beginword
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
191 let first = 0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
192 let suffix = '.*\%(\n\%(\%(\s*\|.\{6\}\)[*/].*\n\)*\)\=\s*'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
193 if beginword =~? '^\%(ADD\|COMPUTE\|DIVIDE\|MULTIPLY\|SUBTRACT\)$'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
194 let beginword = beginword . suffix . '\<\%(NOT\s\+\)\=ON\s\+SIZE\s\+ERROR'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
195 let g:beginword = beginword
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
196 let first = 1
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
197 elseif beginword =~? '^\%(STRING\|UNSTRING\)$'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
198 let beginword = beginword . suffix . '\<\%(NOT\s\+\)\=ON\s\+OVERFLOW'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
199 let first = 1
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
200 elseif beginword =~? '^\%(ACCEPT\|DISPLAY\)$'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
201 let beginword = beginword . suffix . '\<\%(NOT\s\+\)\=ON\s\+EXCEPTION'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
202 let first = 1
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
203 elseif beginword ==? 'CALL'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
204 let beginword = beginword . suffix . '\<\%(NOT\s\+\)\=ON\s\+\%(EXCEPTION\|OVERFLOW\)'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
205 let first = 1
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
206 elseif beginword =~? '^\%(DELETE\|REWRITE\|START\|READ\|WRITE\)$'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
207 let first = 1
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
208 let beginword = beginword . suffix . '\<\%(NOT\s\+\)\=\(INVALID\s\+KEY'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
209 if beginword =~? '^READ'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
210 let first = 0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
211 let beginword = beginword . '\|AT\s\+END\|NO\s\+DATA'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
212 elseif beginword =~? '^WRITE'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
213 let beginword = beginword . '\|AT\s\+END-OF-PAGE'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
214 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
215 let beginword = beginword . '\)'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
216 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
217 call cursor(a:lnum,indent(a:lnum))
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
218 let match = searchpair('\c-\@<!\<'.beginword.'\>','','\c\<'.endword.'\>\zs','bnW'.(first? 'r' : ''),s:skip)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
219 if match > 0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
220 let ind = indent(match)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
221 elseif cline =~? '^\(END-\(READ\|EVALUATE\|SEARCH\|PERFORM\)\)\>'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2034
diff changeset
222 let ind = ind - shiftwidth()
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
223 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
224 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
225 return ind < bshft ? bshft : ind
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
226 endfunction