Some simple vim settings for OpenCOBOL

COBOL development with the Vim text editor and simple source code templates. …

Well met,

Below is the short .vimrc I use for what feels like a nice OpenCOBOL COBOL source code edit.


" btiffin vim startup
set nocompatible
set virtualedit=all
set laststatus=2
set hidden
set noerrorbells
set backspace=indent,eol,start

" Auto load COBOL template
autocmd BufNewFile *.cob 0r ~/lang/cobol/header.cob

where the last line is vim's goto zero, 0, then starts a read of
a localized filename that you would need to change if you copy this. My empty header file is in $HOME/lang/cobol/header.cob. It looks like,


OCOBOL >>SOURCE FORMAT IS FIXED
*> ***************************************************************
*> Author: Brian Tiffin
*> Date:
*> Purpose:
*> Tectonics: cobc
*> ***************************************************************
identification division.
program-id. .

data division.
working-storage section.

*> ***************************************************************
procedure division.

goback.
end program .

So, it saves quite a bit of typing for new COBOL source files.

virtualedit=all gives you a free text cursor, unhindered by actual newline endings to source. Great for fixed form COBOL.

Oh, and if you don't use program.cob, but say program.cbl, you'll need to change the autocmd.

Cheers,
Brian

Leave a Reply

Your email address will not be published. Required fields are marked *