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")
    syntax clear

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>
                command -nargs=+ HiLink hi def link <args>

        HiLink fixPrice Label
        HiLink fixSendingTime Number
        HiLink fixTransactTime Include
        HiLink fixCorrelation String
        HiLink fixSide Identifier

        delcommand HiLink

let b:current_syntax = "fix"

Sample line of data:


Note that the ^A characters are the 0x1 unprintable characters, you can fix this file with:


Where <01> is entered with Ctrl+v followed by 001.

1 Answer 1


This should work, note that <01> is not literal text, it is the 0x01 character. You can enter it with Ctrl+v followed by 001.

if exists("b:current_syntax")

syn case ignore

syn match fixPrice         "<01>44=[^<01>]*"
syn match fixSendingTime   "<01>52=[^<01>]*"
syn match fixSide          "<01>54=[^<01>]*"
syn match fixTransactTime  "<01>60=[^<01>]*"
syn match fixCorrelation   "<01>9717=[^<01>]*"

hi def link fixPrice         Label
hi def link fixSendingTime   Number
hi def link fixSide          Identifier
hi def link fixTransactTime  Include
hi def link fixCorrelation   String

let b:current_syntax = "fix"

If you copy/pasted it, you can fix it up with: :%s/<01>/<01>/g, where the first <01> is literal text, and the second is the 0x01 character.

The regexp explained:

  • <01> - match 0x01 character
  • 44= - followed by your 'magic' number and a = sign
  • [^<01>]* - followed by 0 or more of any character except the 0x01 character.

You could maybe make the text stand out more by using bold text, or different background colours. But I'll leave that up to you ;-)

I removed all of the legacy cruft for very, very old Vim versions. You don't need it.


enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.