Reputation: 3758
This question is a sequel question of this one. I have the following script that removes capitalized words from vim spell check.
syn match myExCapitalWords +\<\w*[A-Z]\K*\>+ contains=@NoSpell
But it works only if I do syn clear
first. But then all other highlighting (e.g. markdown) gets lost. I went through syn list
to see what might be causing the conflict, but now I am out of clue.
Upvotes: 1
Views: 416
Reputation: 172540
It looks like you're extending arbitrary syntaxes with your myExCapitalWords
group. Whether / in which syntax items that works depends on the underlying syntax. Unfortunately, it is not possible to extend arbitrary syntaxes in a blanket way. That's why you're seeing problems that can only be solved via :syn clear
(which gets rid of the underlying syntax).
A syntax contains multiple groups, some of which are usually contained=
in others. If you introduce a new syntax, it will only apply to where no other syntax group already matches. You can force your group into others via containedin=TOP
or even containedin=ALL
, but that overlay may prevent other original groups from matching, and causes strange effects because their own contains=
or nextgroup=
now don't apply.
So, unfortunately, there's no general solution for this. If you're only interested in a few syntaxes, you can tweak your one-liner to make it cooperate with the underlying syntax (e.g. try containedin={syntaxName}Comment{s}
), but there's no generally applicable solution.
Upvotes: 1