Tapatalk

How to ignore spaces when folding EDI X12 files?

How to ignore spaces when folding EDI X12 files?

1
NewbieNewbie
1

PostDec 03, 2025#1

Hi,

New to UltraEdit, using 2025.1.0.20 64-bit. I have read the intro posts and didn't see this topic there or searching through this section.

Instead of the wordfile for EDI X12 that is included with my version of UE, I'm using "X12 (HIPAA EDI)" wordfile from User-submitted wordfiles for UltraEdit/UEStudio – the only diff from default seems to be adding folding (pasting first four lines below); also note the delimiters – no space or tab after equal sign (so these are not defined as delimiters, right?):

Code: Select all

/L13"X12 (HIPAA EDI)" Noquote File Extensions = x12
/Delimiters =~*:<>|^
/Open Fold Strings = "ISA" "GS" "ST" "LS"
/Close Fold Strings = "IEA" "GE" "SE" "LE"
Text between delimiters can contain the strings that happen to match fold strings – "ST" is particularly problematic with addresses, because both "ST<space>" and "<space>ST" occur naturally. So here's what I'm seeing in UE:
UE.png (9.63KiB)
EDI block with wrong offered code folding
It's folding "SE" up to "ST<space>" from "ST CHARLES" and "GE" up to "<space>ST" from "MAIN ST." That's not at all helpful, and is in fact very confusing (one might go so far as to way "wrong for this use case").

I understand that I can't directly specify a specific open fold string to pair with a specific close fold string: that's not a problem here, as the file would be invalid if it didn't have the pairs of identifiers around the segment (they have to be opened/closed as pairs to meet the spec).

Under the assumption that CR/LF is a delimiter (along with delimiters specified in the wordfile), what I want to see is "<delimiter><close fold string><delimiter>" folding up to "<delimiter><open fold string><delimiter>" (in this example: L7 "SE" up to L3 "ST" and L8 "GS" up to L2 "GE" and L9 "IEA" up to L1 "ISA"); instead of matching to "<space><fold string>" or "<fold string><space>".

Is this possible through wordfile, program options, or other workaround? And if not, how do I make a change request?

PS: While I'm here: Is there a way to show a fold/match even when there are no lines in-between? So in the new screen shot below, can I show link between lines 3 and 4?
UE2.webp (3.85KiB)
Small EDI block with no additional line between the lines with ST and SE

6,826625
Grand MasterGrand Master
6,826625

PostDec 03, 2025#2

A normal space is always interpreted as word delimiter for syntax highlighting even on not being explicitly specified in the delimiters list. All other delimiters including a horizontal tab must be specified on the line beginning with /Delimiters = to be interpreted as delimiters for syntax highlighting.

I do not know anything about the EDI syntax but the folding you want can be achieved by replacing in the wordfile "ST" by "ST*".

Code: Select all

/Open Fold Strings = "ISA" "GS" "ST*" "LS"
/Close Fold Strings = "IEA" "GE" "SE" "LE"
I do not know if there is always an asterisk after ST which should be interpreted as open fold string. If there are other characters than an asterisk also possible after ST to interpret as open fold string, add those variants of ST plus additional character also to the list of open fold strings.

Another possibility is adding an ignore fold string to ignore all lines containing a space for searching for an open/close fold string, i.e. use:

Code: Select all

Open Fold Strings = "ISA" "GS" "ST" "LS"
/Close Fold Strings = "IEA" "GE" "SE" "LE"
/Ignore Fold Strings = " "
Both solutions work in my test for the EDI block:

Code: Select all

ISA*~
GS*HC~
ST*837~
N3*1234 MAIN ST~
N4*ST CHARLES*IL*60174~
DTP*123~
SE*45~
GE*6~
IEA*789~
Offering a code folding for just two lines with no additional line between the open and the close fold string requires disabling at Advanced - Settings or Configuration - Editor display - Code folding the setting Show last line of fold in syntax highlighted files. UltraEdit does not offer otherwise a folding if no line can be hidden on applying the code folding.

Offering a code folding on third line to hide the fourth line works with unchecked Show last line of fold in syntax highlighted files for the following EDI block:

Code: Select all

ISA*~
GS*HC~
ST*837~
SE*45~
GE*6~
IEA*789~