0

I write my LaTeX documents using Vim with the vimtex plugin, and for the most part Vim's spell-checker satisfies my needs. However, I am being quite frustrated by the fact that it does not seem to recognise words with diacritical marks, for example the name

Jarn\'{i}k

is treated as Jarn and k. In summary, is there a way to force Vim's spell-checker to treat a word with diacritical marks as a whole word?

3
  • 1
    If you use Jarník (i.e., using utf-8 encoding in your files), it works for me out-of-the box with vimtex (and I suppose any vim plugin).
    – Rmano
    Sep 5 '20 at 16:22
  • @Rmano I had thought of this myself, but I kept this as a last resort because entering certain diacritics (e.g. \v) from the keyboard is much more convoluted. I guess I should have mentioned it in the question, but that is why I formulated it in terms of LaTeX-style diacritics, so to speak.
    – A.P.
    Sep 6 '20 at 14:17
  • 1
    @A.P. Late find (and by chance), Luke Smith demonstrates how special characters (think the level of IPA) may be keyed quickly with vim by special key mapping (video demo, and corresponding GitHub repository).
    – Buttonwood
    Sep 19 '20 at 20:01
4

My suggestion is to enter the text already encoded as UTF-8 and then to instruct vim to accept other than, or additional languages to English for the spell check.

With the following example containing two intentional errors:

Kiti didieji miestai: Kaunas, Klaipėda, Šiauliai, Panevėžys.

This is correct, but here is an errror

L'école se situe en face de l'hôtel Bienvennu

the default correction by set spell is the following

enter image description here

This may be changed, e.g. to check only for French by :set spell spelllang=fr:

enter image description here

or to check simultaneously for multiple languages. Altogether with Lithuanian, the command here is :set spell spelllang=lt,fr,en. Note the list is without a blank after the comma:

enter image description here

This is how to add new dictionaries to the checker: As an example, for Spanish, call set spell spelllang=es. This opens a dialogue to fetch the corresponding .spl with wget to be stored in the path of .vim/spell. There are languages with multiple definitions, e.g. British English / US English.

3
  • I had thought of this myself, but I kept this as a last resort because entering certain diacritics (e.g. \v) from the keyboard is much more convoluted.
    – A.P.
    Sep 6 '20 at 14:16
  • 2
    @A.P. On Linux, even with a US keyboard, you can enable the Compose key and enter, e.g., Č as Compose-<-C, or put a caron over an arbitrary character with compose-<-space.
    – Davislor
    Sep 6 '20 at 17:20
  • @A.P. I agree with you entering printable special characters require more work, and there may be situations where the more explicit form is the safer one. Yet if the text stays within the Latin script and if coworkers (e.g. IT admin) and OS offer me the liberty, I choose the US international keyboard layout. With muscle memory, this example works in Debian (US intl. with dead keys for a 105 key ANSI keyboard) and Windows, too. E.g., in Czech labs, this may be already available next to one of the two Czech layouts, too.
    – Buttonwood
    Sep 6 '20 at 17:29

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.