I found interesting edge code in Vim syntax highlighting. Consider the following snippet from a companyโs Makefile:
LDSCRIPT := $(subst ",,$(CONFIG_SYS_LDSCRIPT))
The above line just removes double quotes from the given LDSCRIPT . Nothing is syntactically wrong; make works as expected and no problem.
Problem
Since the above line contains only one double quote, the highlighting rules mistakenly assume that the rest of the Makefile is quoted and colors it as such. For simple Make files, this is a nuisance; for 1KLOC + Makefiles this becomes a real problem (especially since this preprocessing is near the top of the file).
Question
Is there a way to turn off syntax highlighting based on strings that match a particular regular expression (like subst[ \t]*['"],.* ) Or something like that? If it isn't, is there a way to resume Vim highlighting on any arbitrary line, while maintaining the main points?
If at all possible, I would like to avoid making changes to the Makefile, as this script is divided into several sections.
I am ready to write / modify vimscript to achieve this goal, however I have not done this before (to any reasonable extent). Any tips, pointers or other helpful tips would be greatly appreciated.
What i tried
:syntax sync minlines=1 :syntax sync fromstart :syntax sync clear
None of the above seems to affect selection at startup in the editor. Looking through Vim's help documents, it seems that :syn-sync-fourth can do what I am doing, however, I'm not sure how it will work the other way around (for example, to turn off selection and not apply it).
vim syntax-highlighting makefile
phobos51594
source share