berkes
berkes

Reputation: 27553

How to mark a block to be spellchecked in a different language or not at all in vim?

I am editing a document in Vim. Some parts are in English, some in Dutch. Lets say, I have the following

A common form of lorem ipsum reads:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

"Lorem ipsum" text is derived from sections 1.10.33 of Cicero's De finibus bonorum et malorum.

Now, when spellchecking I'd like to mark the second paragraph (or any block, really) to be spellchecked in a different language. Or, alternatively, to not be spellchecked at all. Is that possible?

The document in question is markdown.

Upvotes: 3

Views: 497

Answers (2)

CyanideData
CyanideData

Reputation: 19

I had the same issue and although I also discovered I couldn't separate spelling by paragraphs, I created a small tool to alternate between languages in one click instead of having them both at the same time. Maybe this could help. https://github.com/CyanideData2/Vim-Archive

Upvotes: 1

Martin Tournoij
Martin Tournoij

Reputation: 27822

I'd like to mark the second paragraph (or any block, really) to be spellchecked in a different language.

There is a simple yet unsatisfactory answer to this: you can't do this. Sorry :-(

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

enter image description here


alternatively, to not be spellchecked at all

This can be done by adding a new syntax group with contains=@NoSpell. See :help :syn-spell. It does require you to make some syntax rule though.

Also see Is it possible to turn on spell-checking for only parts of buffers? as well as this answer for some examples.

Upvotes: 7

Related Questions