Thursday, October 5, 2017

Re: Automatically insert a special character at the beginning of a sentence

On Thu, Oct 5, 2017 at 9:36 AM, Steve <dlist@bluewin.ch> wrote:
> Dear Vimers,
>
> In French, some capital letters must be accentuated. For exemple, one must
> write À and not A, especially when at the beginning of a sentence.
>
> I could try to remember to hit "CTRL-k !A" in order to input that
> character, but I'm always ending to forget that. So I go on the A, hit
> z= and choose generally the first option which replaces A by À.
>
> It's no big deal, but if vim could help me to automate this, I would be
> very grateful.
>
> So I'm imagining so kind of pesudo-code like this
>
> if detect A at the beginning of a sentence (not a line)
> then replace A by À
>
>
> But I don't know how to do it and where to put it.
>
> Any help would be greatly appreciated.
>
> Have a nice day,
> Steve

It's dangerous, because in French, the letter A (even at the start of
a sentence) is often (more often than not, I guess) the uppercase
counterpart of unaccented a — and in that case it must not get an
accent. So if you mapped _all_ start-of-sentence A's to À you would
find yourself needing to correct many intances of À (and É and…) to
remove those pesky accents.

What you could do is use a keymap, $VIMRUNTIME/keymap/accents.vim
maybe, or maybe an owncoded one, so that you could type just `A rather
than Ctrl-K A!, and similarly just 'E instead of Ctrl-K E' etc.
Lowercase French letters are available too, but one pair of important
French characters is missing in the Accents keymap: œ (as in œil, œuf,
bœuf, œsophage, etc.) and Œ (as in Œdipe). Even French typewriters
used to lack them, but some "international" keyboards have them: on my
AZERTY keyboard it's AltGr o without or with Shift, but as the Accents
keymap lacks them you may want to define them in some owncoded keymap
based on Accents — as oe and OE maybe.

See http://vim.wikia.com/wiki/How_to_make_a_keymap

Best regards,
Tony.

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: