I am trying to create a vim syntax file (actually for gvim, but they should be very similar), but one of my matching groups does not match what it should.
I need to match the literal "nop" or "NOP" and grey it out. how I do this is:
syn match nopkw 'nop|NOP'
according to my own knowledge, and (more importantly) regex101.com, this should match literal "nop" or "NOP". Later in my file I use
highlight nopkw guifg=#d3d3d3
If I am correct, this should make all "nop"'s light grey. But it does not. I have other matches in my file that work correctly, such as for numbers:
syn match num '\d+'
highlight num guifg=#ff0000
This works fine, as expected. Why does the "nop" regex not work, and can you find me one that does?
thank you.
Thankfully, the answer is really simple. You need to escape the bar for it work as an 'or'. Try this:
syn match nopkw 'nop\|NOP'
Or, another option would be to use the magic option. This would look like this:
syn match nopkw '\vnop|NOP'