3

How can I get COBOL comments to use proper syntax highlighting in Notepad++ when line numbers are filled in columns 1-6?

I am a developer who is using Notepad++ to code in COBOL. I use the built-in COBOL syntax highlighting, which works under most conditions, but has a particular issue.

COBOL comments are indicated by an asterisk as the 7th character in a line - ordinarily, this works correctly. However, if the 6th character in the line immediately preceding the asterisk is also filled in, the line will incorrectly fail to register as a comment.

Example:

      * THIS SHOWS AS A COMMENT
SH0819* THIS DOES NOT SHOW AS A COMMENT
     9* NEITHER DOES THIS

In COBOL, lines 1-6 are used for "line numbers", or alternatively, initials and dates as a form of primitive manual version control. It is common to have these characters filled in, and they should not interfere with the syntax in any way.

Is there a way to prevent the 6th character from impacting the syntax highlighting of the 7th character?

2 Answers 2

3

I know this is an old post but maybe this will help someone. I recently started programming in Unisys COBOL and noticed the issue you are referring to. To fix it, you will need to rebuild NPP. It is open source on Git.

LexCOBOL.cxx is the program that needs to be updated. Around line 210 is an if statement that starts if (isCOBOLwordstart(ch) || .... You need to add an additional condition that checks if the column number is 7 or greater. The new if statement starts like this:

if (column > 6 && (isCOBOLwordstart(ch) || ....)

LexCOBOL.cxx Change to fix COBOL comment issue.

2

First case: begin coding in col 1 and will be treated like col 7 (Notepad++ works good) Case #1

Second case: begin coding in col 8, and will be treated like standard editor COBOL. Case #2

When col 6 is coding, then Notepad++ assumes line as case 1. (Remarks don't work in this case).

I use SPFLite. This editor works as ISPF on Mainframe.

1
  • 1
    Unfortunately, I am working almost exclusively with old, pre-existing code as opposed to writing new code, so I don't think this is a practical solution for me. Jul 29, 2020 at 15:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .