6

I type my LaTeX documents with Vim. I use both spell check and syntax highlight with the default plugins, although I use a customised colour scheme. With this setup, this is the typical view I get in LaTeX documents:

screenshot

As you can see, comments (otherwise green) are also highlighted in red by the spell checker. I'd like the comments to be fully green regardless of the syntax to facilitate the visualisation. How can I ask Vim to force the priority of comments highlight over syntax?

Pythonist
  • 1,937
  • 1
  • 14
  • 25
  • 3
    have a look at `:h syn-spell` you can turn it of with `@NoSpell` in the syntax file. – Doktor OSwaldo Jan 10 '18 at 10:10
  • Thanks for the hint, I fixed it. It turns out that the default syntax file is flexible enough to let the user decide how to behave in this regard. It works internally by defining the syntax with or without the `@NoSpell` attribute, depending on a global variable you can set. Therefore, including `let g:tex_comment_nospell=1` in the filetype script produces the desired behaviour. Do you think I should promote this comment as a self-answer for the sake of completeness? – Pythonist Jan 10 '18 at 12:08
  • 1
    Yes, please answer the question yourself; it might help other users in the future. – Ingo Karkat Jan 10 '18 at 12:11
  • Yes, definitly! – Doktor OSwaldo Jan 10 '18 at 12:12

1 Answers1

7

After the hint by Doctor OSwaldo, I followed the rabbit hole and figured out how to achieve the desired behaviour. It turns out that this is indeed supported by the standard syntax file for LaTeX and even well documented (see :h tex-nospel).

In short, you can define and set to 1 the global variable g:tex_comment_nospell to get the desired behaviour. Therefore, I only had to add let g:tex_comment_nospell=1 to my .vimrc.

Pythonist
  • 1,937
  • 1
  • 14
  • 25