You're effectively asking us how to use
vi to take a document with correctly-spelled words and introduce spelling errors: the accents are part of the word's spelling.
The days where you could get away with ignoring Unicode are long past.
There are languages without a J, such as classical Latin. Would you not be annoyed if people called you "Iason335" on this site?
vi clones, Vim has by far the best Unicode support. Vim likes UTF-8 best, though on Windows UTF-16 is sometimes a better idea. See the
unicode section of the Vim manual for more information.
If you absolutely must crush Unicode back to a legacy encoding such as the ancient 7-bit ASCII standard, there are several options I'd choose before resorting to a blind
vi substitution command:
- Replace the words on a case-by-case basis using human intelligence, because accented letters don't have the same meaning in all human languages:
The Germanic name Jörg is best spelled Joerg in ASCII, not "Jorg". But please beware: the "ö" → "oe" rule only applies to German. It doesn't apply even to closely-related languages like Dutch, though the same process exists with different orthography.
English is another German-derived language, but in properly-spelled English, the two-dot accent on top of a letter is almost always a diaeresis, not an umlaut. (Excepting loanwords, of course.)
The English word "cooperate" is sometimes spelled "coöperate" to indicate that the first syllable is "co," not "coop," as in "chicken coop." The proper ASCII-ization is therefore not "cooeperate". Some people spell the word "co-operate" to avoid this problem.
For another example, the English surname Brontë uses a diaeresis to indicate that it is not pronounced as if it were spelled "Bront": the diaeresis tells us that the final "e" is a separate syllable, so that the name is properly pronounced "BRONT-ay". Since that name is not using an umlaut, the proper ASCII-ization is "Bronte", not "Brontee" or something else. (In fact, there is no "ë" in German.)
In the Swedish alphabet, "ä" and "ö" are considered separate letters; there is no umlaut as such in Swedish. The ASCII transliteration rule for German is incorrect for Swedish. For example, the Swedish name Ångström is best ASCII-ized as "Angstrom" not "Angstroem".
iconv(1) to convert the file automatically.
This likely to do less damage to your file than a blind
vi substitution because the conversion routines were written by experts in the topic, who have thought through issues like the above and more.
If your target is plain ASCII, you will have to use the
//translit modifier, the
//ignore modifier, or the
-c flag to make this work. I recommend trying them in that order. For example, on the input text "Please coöperate with Jörg.",
iconv -f utf-8 -t ascii//translit gives
Please coo"perate with Jo"rg.
as output. It is doing its best to show that the input text once had dots over the letters.
A better plan would be to use an 8-bit extension to ASCII that also works on your system, such as ISO 8859-1, which can encode the examples I've given so far directly:
iconv -f utf-8 -t iso-8851-1.
You can use
iconv from within
vi using the various pipe commands. For example, to read a UTF-8-encoded file
x as ASCII into the current buffer:
:r !iconv -t ascii//translit x
Or, you could open a file as Unicode, then mark a section of it using normal
vi commands (e.g. Vim's
V block selection command) then convert it in place using
:'<,'>!iconv -t ascii//translit
You don't have to type the first part if starting from a Vim block selection: the first character you type is the
!, and the rest is filled in automatically. You do have to type it all if using other types of
- Use the Perl module
Text::Unidecode instead of
iconv. Because it isn't part of the Perl core, you'll have to install it by hand.
Beware that it merely provides a different sort of "wrong" than
iconv //translit. Its documentation is well worth reading, particularly the section "When You Don't Like What Unidecode Does".
You can use that from within Vim using this mapping in your
map <F6> !}perl -C -MText::Unidecode -ne 'print unidecode( $_)'<CR>
Pressing F6 will convert the current paragraph.