On 1/7/13, Dan Wierenga <[email protected]> wrote:
> 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.
syntax match ARecord_RecordType /^A/ contains=ALL
syntax match ARecord_RecordCount /^A.\{9}/ contains=ALL
syntax match ARecord_RecordOriginatorID /^A.\{19}/ contains=ALL
hi ARecord_RecordType ctermfg=blue
hi ARecord_RecordCount ctermfg=red
hi ARecord_RecordOriginatorID ctermfg=yellow
HTH,
Vlad
--
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