Monday, January 7, 2013

help on syntax file for fixed-width record files

I'm trying to create a syntax file for a file containing fixed-width records [1], so that whenever I edit a file, the records are highlighted so that each field is easily distinguishable by color.

My file looks like this:

A000000001IMFOO23456
C000000002IMFOO23456
Z000000003IMFOO23456


The file has several record types.  A record type is declared by the first character of the line i.e. A, C, Z, etc.  The lines are 1464 characters long (!) so I included just the start of them for brevity.  Each record contains different elements, i.e. an A record has an element from position 2 through 10, 11 through 20, etc., but a C Record has elements from 2 through 10 and 11 through 24.  So, the syntax file has to account for the first character of each line.
I'm starting on the A records, and here's what I have so far:


:syntax region ARecord_OriginatorID start="^A" end=".{20}"
:syntax region ARecord_RecordCount start="^A" end=".{10}"
:syntax match ARecord_RecordType "^A" oneline



:hi ARecord_RecordOriginatorID ctermfg=yellow
:hi ARecord_RecordCount ctermfg=red
:hi ARecord_RecordType ctermfg=blue


However, this results in only the first character (i.e. "A") being blue.  My goal is that the A is blue, the next nine characters at positions 2 through 10 are red, and the next 10 characters are yellow.  

Any help on this would be appreciated.  I feel like I'm missing something fundamental to syntax patterns, but I'm not sure what.  This is my first attempt at a syntax file of any kind.

Thanks,
Dan


[1] Specifically, a Canadian Payments Association Standard 005 AFT File.  https://www.rbcroyalbank.com/ach/file-451771.pdf

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: