Monday, November 26, 2012

Re: special keymap depending on language

On 26/11/12 22:40, Steve wrote:
> Hi,
>
> I write in French and in English. In French, before a question mark, one needs
> a non-breakable space but not in English. Somebody on this list nicely
> suggested to create a file in ~/.vim/keymap/touchesfrmail.vim containing:
>
> loadkeymap
> << «<Char-0xa0>
>>> <Char-0xa0>»<Space>
> ? <Char-0xa0>?<Space>
> ! <Char-0xa0>!<Space>
> : <Char-0xa0>:<Space>
> ; <Char-0xa0>;<Space>
>
> (Sometimes, I don't want the trailing <Space>, but that's all right, I just
> delete it with the backspace key, most of the time I want it.)
>
> This file gets loaded by the following in my .vimrc:
>
> autocmd FileType mail setlocal kmp=touchesfrmail
>
>
> This works great when writing in French, I don't have to manually put a nb
> space. But when writing in English, the same happens which I obviously don't
> want. So my question is rather simple: can I load this file only when editing
> in French?
>
> Thank you,
> best regards,
> steve
>

Well, it would be possible if there is some computer-readable criterion
to tell French-language and English-language email apart from each other.

One possibility would be to set different keymaps and load them manually
when opening the message for editing. Another (for Unix-like OSes) would
be to start Vim with the $LC_CTYPE environment variable set to some
French locale (e.g. fr_FR.UTF-8) in one case and some English locale
(e.g. en_US.UTF-8) in the other (Note: if $LC_ALL is set, it overrides
every $LC_something variable, and if $LANG is set it is used as fallback
for those which are not set.) You could then choose the keymap to be
used for mail based on an :if clause testing the value of v:ctype (or
its first two letters), which defaults to the value of $LC_CTYPE and can
be modified by a :language ctype command:
see
:help v:ctype
:help :lang

Best regards,
Tony.
--
When the government bureau's remedies don't match your problem, you
modify the problem, not the remedy.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment