Automatically insert a special character at the beginning of a sentence

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Automatically insert a special character at the beginning of a sentence

Steve
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


--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Tony Mechelynck
On Thu, Oct 5, 2017 at 9:36 AM, Steve <[hidden email]> 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Steve
Le 05-10-2017, à 10:10:26 +0200, Tony Mechelynck a écrit :

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

You are totally right Tony. I was thinking at only one use case,
forgetting all the others…

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

That could be a solution indeed, if I'm able to not forget that :)

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

For those, I'm used to type Ctrl-k ae for æ etc… They are simple to
remember.

>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

Thanks for the pointer.

Belle journée,
Steve

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Charles E Campbell Jr
Steve wrote:

> Le 05-10-2017, à 10:10:26 +0200, Tony Mechelynck a écrit :
>
>> 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.
>
> You are totally right Tony. I was thinking at only one use case,
> forgetting all the others…
>
>> 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.
>
> That could be a solution indeed, if I'm able to not forget that :)
[snip]

FYI -- the EasyAccents plugin
(http://www.drchip.org/astronaut/vim/index.html#EASYACCENTS), I think,
makes accents fairly easy:

A' -> Á
o@ -> œ

etc.  Turn it on with :EZA and off with: :EZA .  You can switch the A'
transformation to 'A by changing a variable: g:EasyAccents_VowelFirst,
so whichever way works for you is fine with EasyAccents.

Regards,
Chip Campbell

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Steve
Le 05-10-2017, à 22:41:32 -0400, Charles E Campbell a écrit :

>FYI -- the EasyAccents plugin
>(http://www.drchip.org/astronaut/vim/index.html#EASYACCENTS), I think,
>makes accents fairly easy:
>
>A' -> Á
>o@ -> œ
>
>etc.  Turn it on with :EZA and off with: :EZA .  You can switch the A'
>transformation to 'A by changing a variable: g:EasyAccents_VowelFirst,
>so whichever way works for you is fine with EasyAccents.


Thanks, I'll give it a try.

Have a nice day
Steve

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.