Chord typing in Vim

564 views
Skip to first unread message

gev...@gmail.com

unread,
Jan 1, 2016, 11:31:26 AM1/1/16
to vim_dev
Last night, just at the New Year, I have discovered for myself a stenotyping with Plover:
http://stenoknight.com/wiki/FAQ
http://www.openstenoproject.org/
http://stenoknight.com/kws.html
and I think it is great!

I do not need or want to learn stenotyping in full (at least because it does not exist in my native language), but I think that it is a very good idea to use customizable chords (that is two or more usual keyboard keys pressed at the same time) in Vim to launch some commands or print some chunk ot text.

The first such chord, that could save for me a lot of time while typing cyrillics would be to simultaneously press, say, "о" and "н" keys in insert mode to go to the nomal mode and switch the keyboard layout to some English layout (for example with the setxkbmap utility).

Another very useful chord for me would be to simultaneously press, say, "i" and "k" keys to return to the insert mode and switch the keyboard layout back to the cyrillic one.

Tony Mechelynck

unread,
Jan 1, 2016, 3:12:51 PM1/1/16
to vim_dev
Vim gets its key in "cooked" mode. Even gvim, which can distinguish
its keys and chords a little more subtly than Console Vim can, gets
its key in a rather standard manner. This means that keys other than
Shift, Ctrl, Alt, and, on the Mac, Cmd, cannot be used as key
modifiers; conversely, the key modifiers just named cannot be used
_except_ as key modifiers. If you hit i and k at the same time, then
depending on which one of them was got by the keyboard a minuscule
fraction of a second before or after the other, you'll get either ik
(start Insert mode and insert the letter k or whatever is langmapped
to it) or ki (move one line up then start Insert mode). You may set a
multicharacter {lhs} in a mapping, but even then, with the example you
give, you'd get either "он" (which, in Russian, would conflict with
e.g. the personal pronoun meaning "he") or "но" (which would conflict
with the conjunction meaning "but"). A mapping triggered by the one
would not recognize the other.

Most of the "printing" keys already have a function: in Insert mode
they of course insert a character into the text, and even in Normal
mode, the unassigned printing keys are few and far between. The same
applies to the "control" chords of these printing characters, of which
only Ctrl-A to Ctrl-Z (which are the same as Ctrl-a to Ctrl-z), plus
Ctrl-@ (Null), Ctrl-[ (Escape), Ctrl-\, Ctrl-], Ctrl-^, Ctrl-_ and
Ctrl-? (the only ones which have a representation in ASCII) can be
sensed by Vim. For this reason, I recommend to concentrate on the F
keys (with or without Shift, and with the exception of F1 = Help and
F10 = Menu) for the {lhs} of mappings, except when the intentionally
replacing an existing binding with a similar but slightly different
function, e.g. with
map j gj
map k gk
to move up or down by screen lines with j and k, leaving <Up> and
<Down> to move by file lines.


Best regards,
Tony.

Drew Neil

unread,
Jan 4, 2016, 4:15:37 AM1/4/16
to vim_dev
I'm a big fan of Plover myself.

You might be interested in Kana's vim-arpeggio plugin: https://github.com/kana/vim-arpeggio

Note that you will need an NKRO keyboard of you want to make full use of this style of chord entry.

Drew
Reply all
Reply to author
Forward
0 new messages