spell check for multiple languages?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

spell check for multiple languages?

Jiang Qian
Hi all:
I love the new spell check features. I usually write in English, which
is why I set my spellchecker to en-us. However I sometimes write in
Chinese, which AFAIK has no vim spell checker. So every time I write
something it will underline it. Of course I can manually write
:set nospell
to disable spellchecker every time I write in Chinese, but is there an
more intelligent way by which vim somehow know part of the paragraph is
written in Chinese and skip them? I recall spellchecker plugin I used
before doesn't seem to be bothered by my writing some Chinese.
Thanks a lot in advance.
Jiang
Reply | Threaded
Open this post in threaded view
|

Re: spell check for multiple languages?

A.J.Mechelynck
Jiang Qian wrote:

> Hi all:
> I love the new spell check features. I usually write in English, which
> is why I set my spellchecker to en-us. However I sometimes write in
> Chinese, which AFAIK has no vim spell checker. So every time I write
> something it will underline it. Of course I can manually write
> :set nospell
> to disable spellchecker every time I write in Chinese, but is there an
> more intelligent way by which vim somehow know part of the paragraph is
> written in Chinese and skip them? I recall spellchecker plugin I used
> before doesn't seem to be bothered by my writing some Chinese.
> Thanks a lot in advance.
> Jiang
>
>
>  
The 'spell' option is local-to-window. You can set it (for any file, but
not just part of it) by means of a modeline (q.v.), for example

<HTML><HEAD>
<!-- vim: set nospell :-->

at the top of an HTML file, or

--
Best regards,
Jiang Qian
-----
vim:nospell

at the bottom of an email. As the latter example shows, there may be a
problem if the filetype doesn't allow "comments" and you don't want the
modeline to be seen. (In an email, you could create a custom header, but
not all mail clients allow it.)


The EncodingChanged event cannot be used IIUC, since it applies to the
global 'encoding' option, not to the local 'fileencoding'. Anyway, UTF-8
can be used for both English and Chinese, so in this case I don't
recommend using the charset as a criterion.


If you have a file in _mixed_ language (part of the file in English and
another part in Chinese), then I don't know if (or how) Vim can
spell-check only the "English" paragraphs. It might be as simple as
excluding anything in the "Chinese" part of the Unicode range from
spell-checking altogether.


Best regards,
Tony.
Reply | Threaded
Open this post in threaded view
|

Re: spell check for multiple languages?

A.J.Mechelynck
In reply to this post by Jiang Qian
Oops. I inadvertently added a "real" signature delimiter. I meant:

Jiang Qian wrote:

> Hi all:
> I love the new spell check features. I usually write in English, which
> is why I set my spellchecker to en-us. However I sometimes write in
> Chinese, which AFAIK has no vim spell checker. So every time I write
> something it will underline it. Of course I can manually write
> :set nospell
> to disable spellchecker every time I write in Chinese, but is there an
> more intelligent way by which vim somehow know part of the paragraph is
> written in Chinese and skip them? I recall spellchecker plugin I used
> before doesn't seem to be bothered by my writing some Chinese.
> Thanks a lot in advance.
> Jiang
>
>
>  
The 'spell' option is local-to-window. You can set it (for any file, but
not just part of it) by means of a modeline (q.v.), for example

<HTML><HEAD>

<!-- vim: set nospell :-->

at the top of an HTML file, or

--<space>
Best regards,
Jiang Qian
-----
vim:nospell

(where <space> means a single space character) at the bottom of an email. As the latter example shows, there may be a
problem if the filetype doesn't allow "comments" and you don't want the
modeline to be seen. (In an email, you could create a custom header, but
not all mail clients allow it.)


The EncodingChanged event cannot be used IIUC, since it applies to the
global 'encoding' option, not to the local 'fileencoding'. Anyway, UTF-8
can be used for both English and Chinese, so in this case I don't
recommend using the charset as a criterion.


If you have a file in _mixed_ language (part of the file in English and
another part in Chinese), then I don't know if (or how) Vim can
spell-check only the "English" paragraphs. It might be as simple as
excluding anything in the "Chinese" part of the Unicode range from
spell-checking altogether.


Best regards,
Tony.



Reply | Threaded
Open this post in threaded view
|

Re: spell check for multiple languages?

Jiang Qian
> If you have a file in _mixed_ language (part of the file in English
> and another part in Chinese), then I don't know if (or how) Vim can
> spell-check only the "English" paragraphs. It might be as simple as
> excluding anything in the "Chinese" part of the Unicode range from
> spell-checking altogether.
This seems to have the best hope to work. How do I do this in vim? I can
probably figure out what the unicode range(4E00-9FAF I believe) for
Chinese, but how do I specify that they're excluded from spell-checking?  
Thanks a lot!
Jiang
Reply | Threaded
Open this post in threaded view
|

Re: spell check for multiple languages?

llinfeng
This post has NOT been accepted by the mailing list yet.
Simple one-line answer: set the following in your ~/.vimrc (or _vimrc)

set spell spelllang=en_us,cjk