Vim-like digraph functionality


#1

One feature that I always liked in vim as a French speaker working with qwerty is the ability to input special characters directly in the buffer using digraphs. I decided to extract this functionality in a standalone command-line tool called digraph so it can be used directly in the shell or in kakoune through piping. I find it really useful when writing email in French.

Since, as opposed to Vim, the use of digraphs is non-interactive, a placeholder character (#, but I intend on making this configurable) is used to signal them. For instance f#^ach#'ee becomes fâchée after parsing.

Note that this project is still very young and that I have no prior experience with C, but it should already be usable as-is.


#2

@vxid thanks for this. I look forward to it.

what I’d like to know is how many keystrokes would this take to complete? But the whole idea of having digraphs on kak is nonetheless a step forward.

There’s nothing, depending on your layout of course, that currently would outperform for your example above, say https://github.com/vim/vim/blob/master/runtime/keymap/accents.vim

I do remember coming across this comment that suggested mapping the compose key to a dead key. This is not optimal, but it’s the most natural combination for the layout I have.

edit but although digraphs serve its purpose rightfully so, for plain text this is not the way to go.

Take for example under vim to enter the characters that make up the word the word cigüeña (spanish for stork, and cigogne in french according to translate from google.)

That means that with digraphs I’d have to type for the ü
<ctrl-k> : u and then for the ñ, <ctrl-k> ~ n - this is not good. Of course, the other alternative is worse: for the ü I’d have to u <BS> : and for the ñ n <BS> ~

Nope. thank you.


#3

I think the keycount can actually be lower than standard vim digraphs. I agree that <ctrl-k> is a bit awkward to use, but since accents are likely to be used when writing prose, a unshifted delimiter (on qwerty at least) like ] can be used.
That would be cig]u:e]n~a for your exemple. So three keys for a single accented letters an no modifiers needed.

I also agree that using Alt-gr is probably the best solution to inputting accented characters in general, but digraphs work well in the case where you have a standard qwerty keyboard and don’t want to mess with OS-specific configuration.


#4

Nice tool @vxid thanks!

On a side node this keyboard layout is a nice complementary approach for writing all French and most West-Europe special chars: https://qwerty-lafayette.org/

But as you said, it involved messing with the OS conf, which is doable for a personal machine but not really applicable with others public equipment.


#5

a unshifted delimiter (on qwerty at least) like ] can be used

allow me to go over your suggestion, so what you meant was to modify the closing bracket. I’m assuming this is the placeholder you referred to earlier? Earlier you mentioned as an example the # and not the closing bracket.

the problem when any conversation about this issue comes up, is that any layout has a certain number of keys assigned mapped to whatever the codes are, so a lot of folks (including me), forget that the remapping of a key entails the remapping of the key being replaced. And when we don’t forget this, then we realize that the swapping of these keys is a trade-off in the making.

Even after reading this informative and lengthy article/notes, I realize that it does not contain - for my purposes, and based on the layout again - one piece of noteworthy consideration.

The other vague thought I had for a second, was to swap left alt and right alt keys, but this is cumbersome too, primarily because of the keyboard model I use.

Moolenar probably gave some thought or perhaps not, to the acute character implementation. But emacs won hands down here, because of the vast selection of input methods available. So no competition here.

@vxid digraphs are featured-rich so your idea is novel in itself.