# How to configure spell to ignore some environments in LaTeX

Is there a way to tell vim not to spell-check part of a latex document? For instance, code block using the minted environment or URLs in \url{}?

(I'm not sure it's relevant for spell checking but I'm using the vimtex plugin to edit latex files.)

You can disable spell checking for syntax items by adding them to a cluster together with @NoSpell. You can read :help spell-syntax for some information and look at your tex syntax file which most likely contains several examples already. If you type :tabe $VIMRUNTIME/syntax/tex.vim you should get the tex syntax file in a new tab. If you then search /\c@NoSpell you may see a line like  syn cluster texMathZoneGroup add=@NoSpell  The texMathZoneGroup cluster has been defined earlier in the script to contain a number of syntax items and here @NoSpell is added to the cluster to disable spell checking for these items. I'm afraid I can't say exactly where to best make the change for your particular syntax items as I don't know that syntax file very well. There may be an obvious cluster already where you can simply add @NoSpell, or you may have to create a cluster that contains= the items in question. It is also a good idea to make a copy of the syntax file in your user runtime directory and apply your changes there rather than change the distributed syntax file, or to apply your changes in a after/syntax/tex.vim or other script that runs after the syntax file is loaded. Since you use a plugin, it may have options related to which items are spell checked. I don't use vimtex but Karl Lervåg is pretty active here and if you get his attention could answer that for you. • There are no such options in vimtex today, no. But it seems to make sense to ignore spelling in minted environments, so I might update the plugin correspondingly. Thanks for the nice explanation! – Karl Yngve Lervåg Aug 26 '15 at 21:07 • I looked around in the code and I didn't find an existing region for minted environment so I tried to create my own like this: syn region mintedZone start="\\begin{minted}" end="\\end{minted}" contains=@NoSpell but it doesn't seem to help. Any suggestion? – Grégoire Aug 27 '15 at 9:31 • @Grégoire Please, let us continue this discussion in the vimtex issue. – Karl Yngve Lervåg Aug 28 '15 at 18:22 You can add your own syntax rules to e.g. ~/.vim/after/syntax/tex.vim. In order to prevent spell checking inside a command such as \url, you can use the following code: syntax match texStatement '\\command' nextgroup=texMyCommand syntax region texMyCommand matchgroup=Delimiter start='{' end='}' contained contains=@NoSpell  Here texStatement and Delimiter are groups that are defined by the internal syntax plugin, see :e$VIMRUNTIME/syntax/tex.vim.