Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vim-cobol
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kevin Lyda
vim-cobol
Commits
d519c981
Commit
d519c981
authored
7 years ago
by
Kevin Lyda
Browse files
Options
Downloads
Patches
Plain Diff
Work in python2 environments.
parent
6d2d6a0b
Loading
Loading
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
plugin/cobol.py
+10
-4
10 additions, 4 deletions
plugin/cobol.py
plugin/cobol.vim
+10
-5
10 additions, 5 deletions
plugin/cobol.vim
with
20 additions
and
9 deletions
plugin/cobol.py
+
10
−
4
View file @
d519c981
...
...
@@ -5,6 +5,7 @@
# Copyright © 2017 Kevin Lyda <kevin@phrye.com>
#
# Distributed under terms of the GPL license.
from
__future__
import
print_function
"""
COBOL utilities.
...
...
@@ -13,12 +14,17 @@ COBOL utilities.
import
vim
import
math
try
:
xrange
except
NameError
:
xrange
=
range
def
cobol_Renumber
():
if
vim
.
current
.
buffer
.
options
[
'
filetype
'
]
==
b
'
cobol
'
:
gap
=
{}
last_line_no
=
0
lines
=
vim
.
current
.
buffer
for
i
in
range
(
len
(
lines
)):
for
i
in
x
range
(
len
(
lines
)):
if
len
(
lines
[
i
])
==
0
or
lines
[
i
][:
6
]
==
'
'
:
if
not
gap
:
gap
[
'
i
'
]
=
i
...
...
@@ -34,14 +40,14 @@ def cobol_Renumber():
(
i
-
gap
[
'
i
'
]
+
1
))
if
delta
>
1
:
new_line_no
=
gap
[
'
last_line_no
'
]
+
delta
for
j
in
range
(
gap
[
'
i
'
],
i
):
for
j
in
x
range
(
gap
[
'
i
'
],
i
):
lines
[
j
]
=
(
'
%06d
'
%
new_line_no
)
+
lines
[
j
][
6
:]
new_line_no
+=
delta
gap
=
{}
if
gap
:
delta
=
100
new_line_no
=
gap
[
'
last_line_no
'
]
+
delta
for
j
in
range
(
gap
[
'
i
'
],
len
(
lines
)):
for
j
in
x
range
(
gap
[
'
i
'
],
len
(
lines
)):
lines
[
j
]
=
(
'
%06d
'
%
new_line_no
)
+
lines
[
j
][
6
:]
new_line_no
+=
delta
else
:
...
...
@@ -51,7 +57,7 @@ def cobol_Renumber():
def
cobol_Unnumber
():
if
vim
.
current
.
buffer
.
options
[
'
filetype
'
]
==
b
'
cobol
'
:
lines
=
vim
.
current
.
buffer
for
i
in
range
(
len
(
lines
)):
for
i
in
x
range
(
len
(
lines
)):
if
lines
[
i
][:
6
].
isdigit
():
lines
[
i
]
=
'
'
+
lines
[
i
][
6
:]
else
:
...
...
This diff is collapsed.
Click to expand it.
plugin/cobol.vim
+
10
−
5
View file @
d519c981
...
...
@@ -9,8 +9,13 @@ if exists('g:loaded_cobol') || &cp
endif
let
g:loaded_cobol
=
1
if
!
has
(
'python3'
)
echo
"Missing python."
if
has
(
'python3'
)
let
s:pyfile_cmd
=
'py3file'
let
s:py_cmd
=
'py3'
elseif
has
(
'python'
)
let
s:pyfile_cmd
=
'pyfile'
let
s:py_cmd
=
'py'
else
finish
endif
...
...
@@ -18,17 +23,17 @@ let s:path = fnamemodify(resolve(expand('<sfile>:p')), ':h')
function
!
LoadCobolPython
()
if
!
exists
(
'g:cobol_py_loaded'
)
exec
'
py
3
file
'
.
s:path
.
'/cobol.py'
exec
s:
pyfile
_cmd
s:path
.
'/cobol.py'
let
g:cobol_py_loaded
=
1
endif
endfunction
function
!
Renumber
()
py3
cobol_Renumber
()
exec
s:py_cmd
'
cobol_Renumber()
'
endfunction
function
!
Unnumber
()
py3
cobol_Unnumber
()
exec
s:py_cmd
'
cobol_Unnumber()
'
endfunction
call
LoadCobolPython
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment