Extension Details

- COBOL
- by Swipht Group
- 0 Recent Installs | 0 Total Installs
- COBOL editing for Nova in fixed and free format, with syntax, embedded SQL, symbols, copybook-aware completions, navigation, references, and renaming, record layouts, clips, format, alignment, and sequence-area tools, and GnuCOBOL build, run, debugging, and diagnostics.
- Repository
- Bug Reports
-
Read Files
-
Launch Subprocesses
-
This extension is allowed to:
Readme
COBOL
Proprietary COBOL support for Nova, published by Swipht Group.
The extension highlights COBOL in fixed and free reference format, including embedded EXEC SQL blocks. It lists programs, divisions, sections, paragraphs, files, and data items in the symbol list, and offers keyword, intrinsic function, and in-file completions that follow COPY statements into copybooks. It jumps to declarations and copybooks, finds references, renames names, shows record layouts, aligns data entries, converts between fixed and free format, renumbers sequence areas, and compiles, runs, and debugs with GnuCOBOL.
Requirements
- Nova 11 or later
- Optional: GnuCOBOL 3.x (
cobc) on yourPATH, or a compiler path set in preferences. On a Mac with Homebrew:brew install gnucobol - Optional: a COBOL language server executable, if you want diagnostics and completion beyond this extension’s built-in features
- Optional, for debugging: Xcode or the Command Line Tools, which provide
lldb-dap(xcode-select --install)
Usage
Open a .cbl, .cob, .cobol, .pco, .cpy, .copy, or .cbx file. Nova selects the COBOL syntax automatically. A file with another extension is recognized when one of its first lines is an IDENTIFICATION DIVISION header.
Fixed and free format
The source format is chosen per file from its first lines that decide it:
- A
>>SOURCE FORMAT IS FREE/FIXEDdirective, or$SET SOURCEFORMAT"FREE"/"FIXED", always wins. - Code that starts in column 8 or later, a sequence area in columns 1–6, or a column-7 indicator (
*,/,-,D,$) means fixed. Six digits in columns 1–6 followed by a blank or an indicator always mean fixed, even when a*>comment starts in column 7. - Code, a
*>comment, or a>>directive in columns 1–6 means free. - A
*>comment that starts in column 7 reads the same in both formats, so the next line decides. - A file where no line decides is fixed.
In fixed format, columns 1–6 and everything after column 72 are ignored, and column 7 marks comment, debugging, and continuation lines. In free format, there is no sequence area and no right margin, and comments start with *>. A >>SOURCE or $SET directive can switch the format partway through a file. Highlighting follows the switch.
Convert to Free Format and Convert to Fixed Format in the Editor menu rewrite the open file:
- Fixed to free drops the sequence and identification areas. Column 8 moves to column 1, column-7 comments become
*>comments,Dlines become>>Dlines, and continuation lines are joined. - Free to fixed moves code to column 8 and turns
*>comment lines into column-7 comments. A line that runs past column 72 is split: a literal continues on a-indicator line, and other code wraps at a space into Area B. If a line cannot be split, the extension tells you how many such lines are left. - Both directions remove
>>SOURCEand$SET SOURCEFORMATdirectives, since they would override the new layout.
Renumber Sequence Area writes 000100, 000200, … into columns 1–6 of every line that is not blank. It counts by 10 or 1 instead when a file has too many lines for steps of 100. Clear Sequence Area blanks columns 1–6, removes everything after column 72, and trims trailing spaces. Both work only on fixed-format files.
Align Data Clauses lines up data description entries in the selection or, with nothing selected, in the whole file. Level 01, 77, and 78 entries start in Area A: column 8 in fixed format, or the indentation of the file’s first 01 entry in free format. Each level below its parent is indented four more columns, and level-88 entries sit one step below their item. The level number is written with two digits and followed by two spaces. The first clause after the name (PIC, VALUE, USAGE, OCCURS, REDEFINES, and so on) starts in one shared column for each run of entries. The command keeps the column most of those entries already use when every name fits before it. Otherwise it uses the first multiple of four that leaves two spaces after the longest name. Only an entry’s first line moves. Continuation lines, FD and SD entries, comments, and lines with tabs are left as they are. In fixed format, a line that would pass column 72 gets a single space before its clause, or is left alone if it still does not fit.
Toggle Comment Lines comments out the lines the selection touches, or uncomments them when every non-blank one is already a comment. In fixed format, it writes * in column 7, or puts back a blank (a *> in column 7 is removed). In free format, it inserts *> at the smallest indentation of the lines, or removes it. Nova’s own Toggle Comment (⌘/) always uses *>. To give this command a shortcut, use Nova → Settings → Key Bindings.
Uppercase Reserved Words and Lowercase Reserved Words change the case of COBOL reserved words, special registers, and intrinsic function names after FUNCTION. They change only those words, in the selection or, with nothing selected, in the whole file. Names you declared, literals, comments, the text after AUTHOR. and similar paragraphs, directives, and the sequence and identification areas are left as they are.
Embedded SQL and CICS
EXEC SQL … END-EXEC, EXEC CICS … END-EXEC, and other EXEC blocks are recognized anywhere in a program, including in the data division. The text of an EXEC SQL block is highlighted with Nova’s SQL syntax. Other blocks keep their text unhighlighted. Clips cover an EXEC SQL block, INCLUDE SQLCA, a declare section, a cursor loop, and an EXEC CICS block.
GnuCOBOL does not translate EXEC SQL itself. Run an SQL precompiler such as ocesql or esqlOC first, and build the file it writes. Until then, diagnostics on save report errors on the EXEC lines.
Navigation
Go to Definition in the Editor menu jumps to the declaration of the data item, condition name, file, section, or paragraph under the cursor. It searches the open file first, then the copybooks it copies, and opens the copybook when the declaration is there. On a COPY line, it opens that copybook.
Find References lists every use of the name under the cursor, in the open file and in the copybooks it copies, with the declaration first. Choose one to jump to it. When there is only one use, it jumps there directly. Comments, literals, and fixed-format sequence and identification areas are not searched. Matches ignore letter case and whole COBOL words only, so WS-A does not match WS-AB.
Rename Symbol renames a data item, condition name, file, section, or paragraph that is declared in the open file. It changes every use in that file at once, and one Undo reverts it. When a name is followed by several spaces, the padding shrinks or grows so the next clause stays in its column. The new name must be a valid COBOL word, must not be a reserved word, and must not already be declared. A name declared in a copybook must be renamed in the copybook. The extension then tells you which copybooks still use the old name, and, in fixed format, how many renamed lines now pass column 72.
Show Record Layout opens a table of the 01 or 77 record that holds the cursor, or that declares the data item under the cursor. For each field it lists the level, name, offset (counted from 1), length, picture and usage, and the number of occurrences. Copybooks copied into the record are included, with REPLACING applied. Sizes follow GnuCOBOL:
DISPLAYitems count one byte for each character position.S,V, andPtake no space unless the sign isSEPARATE,CRandDBtake two bytes, andNtakes two bytes.COMP-3andPACKED-DECIMALtake half the digits plus one, rounded down.COMP-6takes half the digits, rounded up.COMP,COMP-4,COMP-5, andBINARYtake 1, 2, 4, or 8 bytes by digit count. Theibm,mvs,bs2000,gcos,realia, andrmdialects never use 1 byte, and themfdialect uses the fewest bytes that hold the digits.COMP-1andFLOAT-SHORTtake 4 bytes,COMP-2andFLOAT-LONG8,INDEX4, pointers 8, andBINARY-CHAR,-SHORT,-LONG, and-DOUBLEtake 1, 2, 4, and 8.- A group is the sum of its fields.
OCCURSmultiplies an item’s length, using the maximum forOCCURS … TO. AREDEFINESitem starts where the item it redefines starts and does not add to the group. Offsets inside a table are for its first occurrence.SYNCpadding is not included.
Show Expanded Source opens the program as cobc sees it after COPY and REPLACING, from cobc -E, in a new free-format document. Each #line marker becomes a *> file:line comment. For a copybook, the program that copies it is expanded. Save the file first.
Open Copybook opens the copybook named on the cursor’s COPY line. Elsewhere, it opens the file’s only copybook, or lets you choose from the copybooks it copies. Copybooks are looked up in the file’s folder and the copybook paths, with the same extensions cobc tries.
Building and running
While a COBOL file is open, a GnuCOBOL task is available for Build, Run, and Clean. You do not need to add it in Project Settings. Run builds first. A program that reads keyboard input should use that task’s Run action, which uses Nova’s task report.
A program is a .cbl, .cob, .cobol, or .pco file that declares PROGRAM-ID or FUNCTION-ID. When the focused file is a copybook, Build, Run, and Clean use the program that copies it. The extension looks in the copybook’s folder, then in parent folders inside the workspace, for a program with a COPY statement that names the copybook (COPY NAME, COPY "name.cpy", or COPY NAME OF LIBRARY, in any letter case). When no project is open, it checks the same folder and up to eight parent folders. If several programs copy it, the first path in alphabetical order is used. The copybook’s folder is added to the copybook search path. A copybook that no program copies cannot be built.
The executable is built with cobc -x and placed beside the program, or in the output directory. Clean removes it, along with any .c, .h, .i, and .o files that cobc left behind.
The Editor menu also has Compile, Run, Check Syntax, and Insert Program. Compile, Run, and Check Syntax use the same compiler script and the same program choice as the task. They ask you to save the file first when it has unsaved changes. A failed compile shows the first error. These commands do not open the task report. Insert Program inserts a fixed- or free-format skeleton that matches the open file.
The Extensions menu has New Program, which opens an untitled COBOL document with a program skeleton. The skeleton is free format when the Source Format setting is Free, and fixed otherwise.
Debugging
While a COBOL file is open, a GnuCOBOL (Debug) task is also available. Its Build action compiles the program with cobc -g and collects the debug information into a .dSYM bundle beside the executable. Its Run action builds first, then starts the program under lldb-dap with the same run arguments as the Run action. Set breakpoints in the gutter of the COBOL source, then step, continue, and look at the call stack in Nova’s debugger.
- Breakpoints and the current line follow the COBOL source, because cobc writes
#linedirectives for each statement. A few steps land in the C that cobc generated, which the debug build keeps beside the program. Clean removes it with the executable and the.dSYMbundle. - Variables appear as GnuCOBOL’s C fields (
b_8,f_22, …), not as COBOL data names. - By default, the adapter is
lldb-dapfrom Xcode or the Command Line Tools, started throughxcrun. Nova may show asetExceptionBreakpointsmessage in the debug console when a session starts. It does not affect debugging.
Diagnostics
Saving a COBOL file runs cobc -fsyntax-only and marks errors, warnings, and notes in the editor. Saving a copybook checks the program that copies it and marks problems in the copybook itself. Problems in other files appear on line 1 with the file name and line number. A copybook that no program copies is not checked. The check is skipped when Diagnostics on Save is off, or when a language server is running.
Saving a program also marks unused names as hints:
- A paragraph or section that no
PERFORM,GO TO, or other statement names. The first paragraph of the program and of each section, the first section, and everything inDECLARATIVESare not marked, since control reaches them in order. - A
WORKING-STORAGEorLOCAL-STORAGEitem whose name appears nowhere else in the file or its copybooks, including inREDEFINESandEXEC SQLhost variables. An item counts as used when a group around it, a field inside it, or one of its condition names is used. A group whose fields come from aCOPYstatement counts as used. Only the outermost unused item is marked.
These hints come from the extension, not cobc, so they work without GnuCOBOL. Turn them off with Unused-Name Hints. They are skipped when a language server is running.
Completions and clips
Completions include COBOL reserved words, special registers, and intrinsic function names after FUNCTION. They also include names declared in the open file and in the copybooks it copies: data items, group items, level-88 condition names, constants, files, sections, and paragraphs. After COPY, completions list the copybooks in the file’s folder and the copybook paths. No completions are offered inside a comment, a literal, a fixed-format sequence area, or past column 72.
Clips cover fixed- and free-format programs, subprograms, divisions and sections, data items, tables, condition names, SELECT and FD entries, a read loop, IF, EVALUATE, inline PERFORM loops, CALL, COPY, COMPUTE, STRING, and DISPLAY. Further clips cover SEARCH and SEARCH ALL with a keyed, indexed table, UNSTRING, INSPECT, SORT and MERGE with SD entries, RELEASE and RETURN, file status condition names, keyed READ, REWRITE, START, EVALUATE TRUE, PERFORM … THRU, INITIALIZE, ACCEPT … FROM DATE, and CALL … ON EXCEPTION.
Comment and uncomment use *>.
A GnuCOBOL task can still be added in Project → Project Settings… when a project wants its own compiler settings.
Configuration
Open Extensions → Extension Library…, select COBOL, and open Preferences.
- GnuCOBOL Compiler is the
cobcexecutable. Leave it blank to usecobconPATH. Homebrew’s/opt/homebrew/binand/usr/local/binare always searched. - Dialect is passed as
-std=. It sets reserved words and which features cobc accepts or warns about. The default is GnuCOBOL’s own dialect. - Source Format is passed as
-fformat=. Automatic uses the detection described above. - Extra Arguments are passed to
cobc. Quote paths that contain spaces. - Copybook Paths are directories passed with
-Iand searched for completions. Separate paths with colons or newlines. A relative path is resolved from the project folder. The folder of the file being compiled is always searched. - Output Directory receives the executable. A relative path is resolved from the project folder. Leave it blank to write it beside the program.
- Run Arguments are passed to the program when you run it. Quote values that contain spaces. They are not passed to the compiler.
- Diagnostics on Save runs the compiler check when a file is saved.
- Unused-Name Hints marks unused paragraphs, sections, and data items when a program is saved. It is on by default.
- Debug Adapter is an optional path to an
lldb-dapexecutable for the GnuCOBOL (Debug) task. Leave it blank to usexcrun lldb-dap. - Language Server is an optional executable path. The server must speak the Language Server Protocol over standard input and output. The extension does not download or bundle a server. When the path is empty, the built-in features still work. When the server is running, the save-time compiler check is skipped.
The same keys, except GnuCOBOL Compiler, Debug Adapter, and Language Server, can be set per project in Project → Project Settings…. A blank project value inherits the global setting. Diagnostics on Save and Unused-Name Hints can inherit, or be turned on or off for the project.
Executable paths are read only from your global preferences, and the save-time check ignores per-project Extra Arguments. Project settings are stored inside the project folder, so this keeps a downloaded project from choosing a program that the extension runs when you open or save a file.
Support
If this extension is useful to you, consider supporting its development:
License
The extension itself is proprietary. See LICENSE. The vendored Tree-sitter grammar is MIT-licensed. See THIRD-PARTY-NOTICES.md.
Release Notes
Unreleased
- Fixed programs over the pipe buffer size being mistaken for copybooks by the build script
- Fixed a multi-line
VALUElist starting a line with a number being read as a new data entry - Fixed Convert to Free/Fixed Format keeping a
>>SOURCEor$SET SOURCEFORMATdirective, which left the file in its old format; those lines are now removed - Fixed Convert to Free Format gluing a continued word to the previous line (
MOVE A/- TO B.becameMOVE ATO B.); the lines are now joined with a space unless the first ran to column 72
Version 1.2
- Find References lists every use of the name under the cursor, in the file and the copybooks it copies, and jumps to the one you choose
- Rename Symbol renames a data item, condition name, file, section, or paragraph throughout the open file, keeping padded clauses in their columns
- Show Record Layout shows each field's offset, length, picture, and usage for the record under the cursor, including copied fields,
OCCURS,REDEFINES, and binary and packed sizes for the dialect - Show Expanded Source opens the program after
COPYandREPLACING, fromcobc -E - Align Data Clauses indents data entries by level and lines up their first clause in one column
- Toggle Comment Lines comments lines with
*in column 7 in fixed format, or*>in free format - Hints for paragraphs and sections that nothing performs, and for data items that nothing uses, with an Unused-Name Hints setting
- Clips for
SEARCH,SEARCH ALL,UNSTRING,INSPECT,SORT,MERGE,RELEASE,RETURN, file status codes, keyedREAD,REWRITE,START,EVALUATE TRUE,PERFORM THRU,INITIALIZE,ACCEPT FROM DATE, andCALL ON EXCEPTION - More reserved words, including JSON and XML statements,
VALIDATE,LOCALE, floating-point and binary usages, and pointer types
Version 1.1
- Go to Definition jumps to the data item, condition name, file, section, or paragraph under the cursor, in the open file or a copybook it copies; on a
COPYline it opens the copybook - Open Copybook opens the copybook on the current
COPYline, or one chosen from the copybooks the file copies EXEC SQL,EXEC CICS, and otherEXEC … END-EXECblocks parse anywhere in a program, with SQL highlighting insideEXEC SQL, plus clips for embedded SQL and CICS- GnuCOBOL (Debug) task: builds with debug information and runs the program under
lldb-dap, with breakpoints and stepping in COBOL source - Uppercase Reserved Words and Lowercase Reserved Words, for the selection or the whole file
- Renumber Sequence Area and Clear Sequence Area for fixed-format files
- A file whose lines start with six-digit sequence numbers is fixed format, even when a
*>comment starts in column 7 - Clean also removes a
.dSYMbundle and the C that a debug build leaves beside the program
Version 1.0.2
- New extension icon: a larger punch card without the wordmark, matching the other Swipht Group extensions and easier to read at small sizes
Version 1.0.1
- Added donation links (Liberapay, Ko-fi, IssueHunt) to the README and a Liberapay funding link in the Extension Library
Version 1.0
Initial release
- Tree-sitter highlighting, folding, and symbols for COBOL in fixed and free format, including
>>SOURCEand$SET SOURCEFORMATswitching, copybooks, andLINE SEQUENTIALfiles - Keyword, special register, and intrinsic function completions, plus data items, condition names, files, sections, and paragraphs from the open file and the copybooks it copies
- Copybook name completion after
COPY - Clips for programs, divisions, data items, files, and common statements
- Convert to Free Format and Convert to Fixed Format, with literal continuation and line splitting at column 72
- GnuCOBOL task with Build, Run, and Clean; a focused copybook builds the program that copies it
- Compile, Run, Check Syntax, Insert Program, and New Program commands
cobcdiagnostics on save, including problems reported inside copybooks- Dialect, source format, copybook path, output directory, and run argument settings, globally and per project
- Optional language server support
- The compiler and language server paths are global-only, and the save-time check ignores per-project extra arguments, so an opened project cannot choose what runs
License
Copyright (c) 2026 Swipht Group. All rights reserved.
This extension is proprietary and confidential. No license is granted to use,
copy, modify, merge, publish, distribute, sublicense, or sell the Swipht Group
COBOL extension except to the copyright holder.
The Tree-sitter COBOL grammar distributed in binary and source form with this
extension remains under the MIT License. See THIRD-PARTY-NOTICES.md.