0

I recently tryed following the answer to this question: vim-spell: exclude custom LaTeX commands.

To remove spelling from the inside of certain commands, I ended up adding the following to after/syntax/tex

syn match texSomevariable "\\Acs\*{[^}]\{-}}"hs=s+6,he=e-1 containedin=texStatement contains=texDelimiter,@NoSpell
syn match texSomevariable "\\cref{[^}]\{-}}"hs=s+6,he=e-1 containedin=texStatement,texRefZone contains=texDelimiter,@NoSpell,texDelimiter
syn match texSomevariable "\\Cref{[^}]\{-}}"hs=s+6,he=e-1 containedin=texStatement,texRefZone contains=texDelimiter,@NoSpell,texDelimiter
syn match texSomevariable "\\crefrange{[^}]\{-}}"hs=s+11,he=e-1 containedin=texStatement,texRefZone contains=texDelimiter,@NoSpell,texDelimiter
syn match texSomevariable "\\Crefrange{[^}]\{-}}"hs=s+11,he=e-1 containedin=texStatement,texRefZone contains=texDelimiter,@NoSpell,texDelimiter
syn match texSomevariable "\\subcaptionref{[^}]\{-}}"hs=s+15,he=e-1 containedin=texStatement,texRefZone contains=texDelimiter,@NoSpell,texDelimiter
syn match texSomevariable "\\acs{[^}]\{-}}"hs=s+5,he=e-1 containedin=texStatement contains=texDelimiter,@NoSpell,texDelimiter
syn match texSomevariable "\\Acs{[^}]\{-}}"hs=s+5,he=e-1 containedin=texStatement contains=texDelimiter,@NoSpell,texDelimiter
syn match texSomevariable "\\ac{[^}]\{-}}"hs=s+4,he=e-1 containedin=texStatement contains=texDelimiter,@NoSpell,texDelimiter
syn match texSomevariable "\\Ac{[^}]\{-}}"hs=s+4,he=e-1 containedin=texStatement contains=texDelimiter,@NoSpell,texDelimiter

In the answer by Kristian he mentioned that the { and } should be excluded by the texDelimiter flag, but they still don't get highlighted for me.

The larger problem is that when I open a long .tex file, with multiple figures that have been collapsed. The nospell is set for the rest of the document. So I have to find the problematic figure and unfoldit manually (zM zr does not work).

Other commands will keep being highlighted, but the commands in the list will stop being highlighted, so I can probe around figures by writing \ac and see if it goes from syntax highlighted to not highligted when the c is put down.

It's a really wierd problem, so I can't make an MWE ;-( but hopefully some vim-wizards know their magic, if so, thanks in advantage ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.