[EMAIL PROTECTED] wrote:
Hi,

 I want to write a macro, function or what else, which ensures, that
 no german umlauts (äöüÄÖÜ) or the "sz" (ß) will ever occure in any
 file written with vim. It does not matter, if these charactes will
 appear while typing but they should never and under no circumstances
 be saved to disk. Best solution however would be, if they were
 changed "on the fly" to their replacements:
umlaut a ä -> ae
 umlaut o ö -> oe
 umlaut u ü -> ue

 umlaut A Ü -> Ae

I guess you mean Ä -> Ae

 umlaut O Ö -> Oe
 umlaut U Ü -> Ue

 "sz" ß     -> sz

 I did some experiments, which had worked under some circumstances and
 did not under others.
 But I need something, which does the replacements under any
 condition.
Keep editing!
 mcc


Method I: will remove all umlauts in all files, even preexisting ones (if any) at write-time.

function RemoveUmlauts() range
        let l:range = a:firstline . ',' . a:lastline
        exe l:range 's/ä/ae/g'
        exe l:range 's/ö/oe/g'
        exe l:range 's/ü/ue/g'
        exe l:range 's/ß/sz/g'
        exe l:range 's/Ä/Ae/g'
        exe l:range 's/Ö/Oe/g'
        exe l:range 's/Ü/Ue/g'
endfunction
autocmd BufWritePre * %call RemoveUmlauts()

Method II: will remove umlauts only as you type them. Anything preexisting will remain untouched.

        inoremap ä ae
        inoremap ö oe
        inoremap ü ue
        inoremap ß sz
        inoremap Ä Ae
        inoremap Ö Oe
        inoremap Ü Ue

These two solutions are not exclusive of each other: they can be applied 
together.


Note that the official transliteration of the eszett is not sz but ss: upcase("ß") is "SS" and, in de_CH locales, the eszett is not used (other than for "archaic" look, sometimes together with a Fraktur font); ss is used in its stead everywhere.


Best regards,
Tony.
--
George Washington was first in war, first in peace -- and the first to
have his birthday juggled to make a long weekend.
                -- Ashley Cooper

Reply via email to