Thursday, August 30, 2012

Re: ASCIIfication (removal of accent, cedilla, etc)

Tim Chase wrote:
> On 08/29/12 21:46, Salman Halim wrote:
> >> I've got some Portuguese text that I need to perform some
> >> transformations on to make them ASCII (7-bit). That means
> >> removing accent marks, cedillas, tildes, etc.
> >>
> >> Is there some fast transform in Vim that I've missed, or an
> >> easy way to go about this?
> >
> > I don't believe there is something that will figure out the
> > non-accented version of a given character, but you could do
> > something similar using tr() by passing in "èéêëē" and "eeeee",
> > for example.
>
> Thanks to everybody for their suggestions. Playing around a little,
> I went with using equivalence classes:
>
> :%s/[[=a=]]/a/g|%s/[[=e=]]/e/g|...
>
> which is still tedious, but at least a little less so. If there's
> some magic method I've missed (this happens to be a work thing, so
> I'm stuck on Win32 without the conversion utility mentioned
> elsewhere in the thread), I'd love to know how to improve this.
>
> -tim

Something like the following to simplify:

function! AEIOU()
for x in ["a","e","i","o","u"]
execute ':%s/[[='.x.'=]]/'.x.'/g'
endfor
endf " :call AEIOU()

Bill

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