I tried to create a custom syntax file to read FIX messages. Note: I am certain my custom files are being loaded by Vim.
The file format is sequences of NUMBER=VALUE
pairs separated by the unprintable 0x1
character. I wanted a few of the pairs (the ones with important data) to turn colors when I open the file in Vim. I don't care about which colors they turn, as long as they are all different and are easily distinguishable from each other.
Specifically, I want the tags associated with the following numbers to be highlighted: 44, 52, 54, 60, 9717.
Here's my syntax file (~/.vim/syntax.vim
)
if version >= 600
if exists("b:current_syntax")
finish
endif
else
syntax clear
endif
syn case ignore
"syn match fixPrice "\|44[=][^|]\+\|"
"syn match fixSendingTime "\|52[=][^|]\+\|"
"syn match fixTransactTime "\|60[=][^|]\+\|"
"syn match fixCorrelation "\|9717[=][^|]\+\|"
"syn match fixSide "\|54[=][^|]\+\|"
syn match fixPrice "44"
syn match fixSendingTime "|52"
syn match fixTransactTime "\|60"
syn match fixCorrelation "\|9717"
syn match fixSide "\|54"
" Define the default highlighting
if version >= 508 || !exists("did_fix_syntax_inits")
if version < 508
let did_fix_syntax_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink fixPrice Label
HiLink fixSendingTime Number
HiLink fixTransactTime Include
HiLink fixCorrelation String
HiLink fixSide Identifier
delcommand HiLink
endif
let b:current_syntax = "fix"
Sample line of data:
8=FIXT.1.1^A9=380^A35=X^A49=CME^A56=0^A34=13362975^A52=20130626135401572^A1128=9^A268=3^A279=0^A269=2^A48=42025^A22=8^A270=-224^A271=1^A273=135401000^A274=2^A451=32^A1020=23^A83=523628^A5799=1^A5797=1^A279=0^A269=2^A48=17311^A22=8^A270=12356^A271=1^A273=135401000^A277=1^A451=-395^A1020=201377^A83=5671131^A5797=1^A279=0^A269=2^A48=122816^A22=8^A270=12580^A271=1^A273=135401000^A274=2^A277=1^A451=-427^A1020=31^A83=1396693^A5797=2^A75=20130626^A10=001^A
Note that the ^A
characters are the 0x1
unprintable characters, you can fix this file with:
:%s/\^A/<01>/
Where <01>
is entered with Ctrl+v followed by 001.