Monday, May 30, 2011

Re: Searching for accented characters.

On 30/05/11 09:58, Jürgen Krämer wrote:
>
> Hi,
>
> Beren Sanders wrote:
>> On Sun, May 29, 2011 at 8:25 PM, Tim Chase<vim@tim.thechases.com> wrote:
>>> On 05/29/2011 06:43 PM, Beren Sanders wrote:
>>>>
>>>> Is there an easy standard way to make accented characters match searches
>>>> for
>>>> their normal counterparts?
>>>>
>>>> For example, I obtain "é" by typing "<CTRL>-k ' e" and I would like to set
>>>> it up so that searching for "Ajoute" will match both "Ajoute" and
>>>> "Ajouté".
>>>
>>> It sounds like you might want Vim's equivalence classes:
>>>
>>> /Ajout[[=e=]]
>>>
>>> which you can read about at
>>>
>>> :help /[[=
>>>
>>> Note the caveat about Latin1 vs. other encodings.
>>>
>>> -tim
>>
>> Thanks Tim. Do you (or someone else) know someway of making the
>> equivalence class [[=e=]] the default interpretation of an 'e' in the
>> search string? In other words, although it is great that [[=e=]]
>> matches all the versions of 'e', it involves typing seven characters
>> instead of just one.
>>
>
> I don't know of any way to make equivalence classes the default
> interpretation, but you can always define mappings to expand a letter
> into its equivalence class, e.g.:
>
> cnoremap<expr> e getcmdtype() =~ '[?/]' ? '[[=e=]]' : 'e'
>
> If you really need an 'e' you have to press Ctrl-V before 'e' then.
>
> Regards,
> Jürgen
>

Of course, if you want to do it that way, you'll have to do it for every
equivalence class you'll possibly encounter, e.g. for French:

a [[=a=]] aàâ
A [[=A=]] AÀÂ
c [[=c=]] cç
C [[=C=]] cÇ
e [[=e=]] eéêèë
E [[=E=]] eÉÊÈË
i [[=i=]] iîï
I [[=I=]] IÎÏ
o [[=o=]] oô
O [[=O=]] OÔ
u [[=u=]] uùûü
U [[=U=]] uÙÛÜ
y [[=y=]] yÿ
Y [[=Y=]] YŸ

not counting foreign characters as seen in e.g. Dvořak, Białystok,
Timişoara, etc.

This will still not find œ (as in œil, œuf, bœuf, œsophage, etc.) when
searching for oe; similarly for Œ and the rarer (in French) æ Æ (as in
Lætitia, lætare, cæcum, etc.).


Best regards,
Tony.
--
It's no surprise that things are so screwed up: everyone that knows how
to run a government is either driving taxicabs or cutting hair.
-- George Burns

--
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