I have book length prose content in Markdown files that is mostly in Turkish. I've done a lot of work to get Turkish spell checking working decently in vim, so :set spelllang=tr spell works well enough. However my prose contains lots of excerpts in other languages (English, Greek, Hebrew, German, Latin, French, etc.). These are tagged with some inline markup (and later typeset with correct language handling by Pandoc with some inline extensions similar to the ones allowing inline LaTeX but modified to work with SILE. This markup looks something like this:

... adına başka bir şey de deseydik gül (\lang:en{a rose by any other name}) ...

These have predictable tags such as en, el, he, de, la, fr, etc. that correspond to ISO-639-2 language codes, the same as vim would need to be told to spellcheck these languages.

Finally I have some words that are transliterations or deliberately gibberish that are tagged \lang:und{}.

My question is would it be possible to ask VIM to spellcheck these regions based on the syntax? Right now I am manually skipping over them. I realize I can probably setup a syntax highlighter to ignore the regions altogether, but can vim spellcheck different regions as different languages?


I answered pretty much the same question on Stack Overflow last week, and the short of it is that you can't do this.

The best you can do is to use :set spelllang=en_gb,tr, so it checks both languages.

Sorry :-(

As for ignore these regions, this can be done by adding a new syntax group with contains=@NoSpell. See :help :syn-spell. Also see Is it possible to turn on spell-checking for only parts of buffers? as well as this answer for some examples.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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