Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable spell highlight within a comment in Vim

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?

like image 394
Pythonist Avatar asked Jan 10 '18 09:01

Pythonist


1 Answers

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.

like image 138
Pythonist Avatar answered Nov 03 '22 10:11

Pythonist