Question

I am working on a sql file with some m4 macro embedded. Since m4 uses apostrophe to mark the start of string literals, it breaks the string highlighting of the file totally. Like

m4_include(`SQLCommon.m4')

I am wondering whether there is any option we can let vim to pair apostrophe with a single quotation mark. I searched on-line but didn't find any answer.

Thanks!

Was it helpful?

Solution

You're going to want to override vim's normal syntax highlighting for sqlString.

I was able to get the behavior I think you're looking for with just this:

:syntax region m4String start=/`/ end=/'/

To achieve nesting, we have to tell vim that a m4 string can contain more of the same:

:syntax region m4String start=/`/ end=/'/ contains=m4String extend

If you'd like to color those strings separately instead of just disrupting the normal highlighting you can separately link to the String highlight group.

:hi link m4String String

I wasn't entirely sure what you were looking for though; if the backtick-apostrophe delimited strings are inside of the normal SQL strings this won't work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top