cga2000 wrote:
I sometimes need to write text in other languages such as French,
Spanish and occasionally German or Italian.

I would like to do this in Vim.

Unfortunately I only have a US keyboard.

Using Ctrl-K to enter the various digraphs becomes somewhat cumbersome
for anything larger than a short paragraph.

Unfortunately I am only able to type the US keyboard, so remapping the
keyboard might be a better solution than entering digraphs in the long
run but will not be painless..  And since I do not do this on a regular
basis, I am unsure whether it's really worth going to all the trouble.

I was thinking of writing the text without accents, tildes, cedillas,
etc. using the letters on the US keyboard and then feeding the result to
some advanced functionality of a spellchecker that would replace all the
words that can only be spelled one way by their correctly spelled
version - say French 'épeler" (to spell) can only be spelled this way..
there is  no 'epeler' or 'èpeler' or 'êpeler'.

On the other hand, for those words where the accent differs depending
on the semantics such as French 'a' vs. 'à', the script/plugin would
leave them untouched and  - ideally - highlight them, thus leaving me
with only a handful of manual corrections.

Is there anything in Vim that does something like this?

Or is there any other 'smart' way to achieve something like the above?

Thanks

cga



I.

Since you've already used digraphs, and they're too cumbersome for you, you could try a keymap.

There are some keymaps in $VIMRUNTIME/keymap which you can apply by just doing ":setlocal keymap=<keymapname>" (where <keymapname> is the filename without the encoding and .vim endings) or by using the "Edit -> Keymap" menu. Then you can toggle between "US-QWERTY" mode and "keymap" mode by hitting Ctrl-^ in Insert mode, or by toggling 'iminsert' between zero and 1 in any mode. Basically, what a keymap does is establish a set of language-mappings, i.e., insert-mode mappings which can be turned on an off. Try the "accents" keymap, it might be just what you want.

Or, if none of the distributed keymaps is exactly what you want, you can write your own. It isn't hard. See ":help :loadkeymap" for the theory, and look at the contents of Bram's $VIMRUNTIME/keymap/accents.vim and my $VIMRUNTIME/keymap/esperanto_utf8.vim for a couple of simple examples. You might want to write something more extensive but this will show you how to do it.

If and when you write your own keymap, place it in the keymap/ subdirectory of a directory listed early in 'runtimepath' but not in $VIMRUNTIME/keymap itself because any upgrade can silently change anything there.



II. What you are suggesting looks like setting 'spelllang' (with three ells) to whatever means "French" and then spellchecking your US-ASCII-only text. But beware: the Vim spellchecker (which I don't use because of my good innate spelling) might not be clever enough to mark words which have accented homographs, such as "a" ("has") vs. "à" ("at"), "de" ("of") vs. "dé" ("thimble"), "du" ("of the") vs. "dû" ("owed"), "cru" ("believed" or "raw") vs. "crû" ("grown") etc.: so the cure might be worse than the ill, owing to the necessity of looking for unmarked spelling mistakes even after running the spell checker.


Best regards,
Tony.

Reply via email to