I would appreciate some help writing a simple syntax file. I have files with the following header:
Job Number: 20030003 Date: October 28, 2020 Time: 01:36:00
Vessel: Enterprise
Client: Shell Area: Atlantic Shores Offshore Windfarm
Lat: 40 22.6625 Lon: 7-34 02 06.2200 Y: 2358609.81 X: 483116.09
0.15 1511.41 19.38
0.45 1513.60 18.95
0.75 1513.15 18.44
1.05 1512.62 18.18
1.35 1512.58 18.17
1.65 1512.62 18.18
My keywords are:
Job Number
Date
Time
Vessel
Client
Area
Lat
Lon
Y
X
I have those defined, but I'm having trouble defining the values. The problems are:
- The values may have spaces in them
- The values may occur at the end of a line
- Other than values at the end of a line, the value terminator may either be two spaces, a tab and a space, or a single tab.
- My syntax file is highlighting the columns of numbers below my header.
Here is my current syntax file:
" Quit when a syntax file was already loaded.
if exists('b:current_syntax') | finish| endif
syntax match velVar "Client" nextgroup=velAssignment
syntax match velVar "Vessel" nextgroup=velAssignment
syntax match velVar "Area" nextgroup=velAssignment
syntax match velVar "Date" nextgroup=velAssignment
syntax match velVar "Time" nextgroup=velAssignment
syntax match velVar "Job Number" nextgroup=velAssignment
syntax match velVar "Lat" nextgroup=velAssignment
syntax match velVar "Lon" nextgroup=velAssignment
syntax match velVar "Y" nextgroup=velAssignment
syntax match velVar "X" nextgroup=velAssignment
syntax match velAssignment ":" contained nextgroup=velValue
syntax match velValue " [ -.,:[:alnum:]]*$" nextgroup=velNum
syntax match velValue " [ -.,:[:alnum:]]* " nextgroup=velNum
syntax match velValue " [ -.,:[:alnum:]]*^I" nextgroup=velNum
syntax match velValue " [ -.,:[:alnum:]]*^I " nextgroup=velNum
syntax match velNum^I"^ *[:digit:]*$"
hi def link velVar Identifier
hi def link velAssignment Statement
hi def link velValue String
let b:current_syntax = 'vel'
:help pattern
and searching for line number. The format is\%<linenumber>l
where<linenumber>
is a specific line number,\%<<linenumber>l
matches above a specific line number and\%><linenumber>l
matches below a certain line number. I would try those options first and just use5
. The manual does state a warning about inserting and deleting lines can quickly mess up highlighting.