TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I set up vim in such a manner, that it spellchecks only the text portion of my file?

I write a lot of reports that include code listings, which I would like to exclude from the spellchecking.

Also I am writing in different languages: german and english. How do I setup vim to do the spell checking properly. Which spell-checking packages are the best (aspell/ispell/...)?

share|improve this question
up vote 8 down vote accepted

Vim has built in spell checking. You do not need external spell checkers. Simply use :set spell to enable spell checking.

To disable spell checking in code listings, you need to modify the vim syntax file for tex. Copy $VIMRUNTIME/syntax/tex.vim to $HOME/.vim/syntax/tex.vim. Around line 402, this file has:

syn region texZone      start="\\begin{verbatim}"           end="\\end{verbatim}\|%stopzone\>"  contains=@Spell
syn region texZone      start="\\begin{code}"               end="\\end{code}\|%stopzone\>"  contains=@Spell
" listings package:
syn region texZone      start="\\begin{lstlisting}"         end="\\end{lstlisting}\|%stopzone\>"    contains=@Spell
" moreverb package:
syn region texZone      start="\\begin{verbatimtab}"        end="\\end{verbatimtab}\|%stopzone\>"   contains=@Spell
syn region texZone      start="\\begin{verbatimwrite}"      end="\\end{verbatimwrite}\|%stopzone\>" contains=@Spell
syn region texZone      start="\\begin{boxedverbatim}"      end="\\end{boxedverbatim}\|%stopzone\>" contains=@Spell

Change each of these @Spell to @NoSpell and vim will not spell check in the respective environments.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.