latex spell check disabled if set filetype=latex

239 views
Skip to first unread message

Enno

unread,
May 15, 2014, 4:07:34 AM5/15/14
to vim...@googlegroups.com
This inconsistency is also discussed in the comments of the thread opener on

http://tex.stackexchange.com/questions/135337/how-to-set-up-spell-checking-with-vim

If set filetype=plaintex, then spell checking in a tex file checks the text in the whole document for spelling errors. (This is, spelling errors are have a curly red underline.)

If set filetype=latex, then spell checking in a tex file only checks the spelling in comments or erratically in some latex environments.

This occurs in Gvim 7.4.285 and Windows 7 64 bit.

Charles Campbell

unread,
May 16, 2014, 5:01:27 PM5/16/14
to vim...@googlegroups.com
The problem: avoid spell checking things that should not be spell
checked. The preamble, for example, largely falls into this category.
Math regions falls into this category. Etc.
The solution: restrict spell checking to specific things, such as
sections (actually, document, chapter, part, section, subsection,
subsubsection, and others)
User problem: has introduced new commands that are not recognized by
syntax/tex.vim as things that should involve spell checking, and has not
thought of writing after/syntax/tex/... to recognize spell checking in
his/her new zones.

Solution: user should write syntax recognition rules to enable spell
checking in the region(s) of interest.

Regards,
Chip Campbell

Enno

unread,
Jun 13, 2014, 12:35:58 PM6/13/14
to vim...@googlegroups.com, charles.e...@nasa.gov

Ok, I understand that spell checking is only activated after a keyword, such as the \section{..} command.

But why is it that \begin{document} does not belong to these keywords? This disables spell checking for example for letter document classes without any sectioning.

How to remedy this least intrusively?

Charles Campbell

unread,
Jun 13, 2014, 12:53:06 PM6/13/14
to vim...@googlegroups.com
Enno wrote:
> Ok, I understand that spell checking is only activated after a
> keyword, such as the \section{..} command. But why is it that
> \begin{document} does not belong to these keywords? This disables
> spell checking for example for letter document classes without any
> sectioning. How to remedy this least intrusively?
Spell checking is activated for syntax regions. Most of the preamble
should not be spell checked. Spell checking *is* enabled for
\begin{document}..\end{document} (that's called a texDocZone by the
syntax highlighting), and it does work for the letter document classes
without sectioning.

Regards,
Chip Campbell

Enno

unread,
Jun 22, 2014, 12:26:58 PM6/22/14
to vim...@googlegroups.com, charles.e...@nasa.gov
Hello,

there is c:\Program Files\Vim\vim74\syntax\tex.vim that says

" Maintainer: Charles E. Campbell
" Last Change: Mar 20, 2014
" Version: 81
" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX

However, in the test file

\documentclass{article}

\begin{document}


\end{document}

the spell checking errors are only detected in the comments between \begin{document} and \end{document}, but not in the text itself.

This changes however, if a \section{...} command is added, for example.

Charles E Campbell

unread,
Jun 24, 2014, 1:16:44 PM6/24/14
to vim...@googlegroups.com
Just tried it:

\documentclass{article}
\begin{document}
This is junkk . Loks like spell checkingx is woiking to mee!
% This is junkk . Loks like spell checkingx is woiking to mee!
\end{document}

Both the text and the comment were spell checked.
I used:

vim -u vimrc.spellchk abc.tex

and both files are attached. I also used syntax/tex.vim v81, which you
may get from my website:
http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX .

Regards,
Chip Campbell


abc.tex
vimrc.spellchk

Enno

unread,
Jun 29, 2014, 9:33:48 AM6/29/14
to vim...@googlegroups.com
Hello Dr Chip,

Thanks a lot for your patience that I am sorry to have abused: It turned out that it was a Rainbow Parentheses plugin (https://github.com/luochen1990/rainbow) that disabled the spell check between \begin... and \end{document} but left it active otherwise.

Best wishes

Enno

Charles Campbell

unread,
Jun 30, 2014, 9:35:25 AM6/30/14
to vim...@googlegroups.com
Perhaps you ought to try my Rainbow highlighter:
http://www.drchip.org/astronaut/vim/index.html#RAINBOW .

Regards,
Chip Campbell

Enno

unread,
Jul 1, 2014, 10:31:52 AM7/1/14
to vim...@googlegroups.com, charles.e...@nasa.gov
I'll give it a try. It is even more complete since it works with the conceal feature.
Reply all
Reply to author
Forward
0 new messages