Author Topic: VI-mode for keyboards?  (Read 1149 times)

0 Members and 1 Guest are viewing this topic.

Offline textmode

  • Thread Starter
  • Posts: 15
VI-mode for keyboards?
« on: Mon, 23 November 2020, 22:54:50 »
Background: My rubber dome IBM Space Saver II is showing signs of wear after about six years of heavy use. Some keys don't react well anymore, some need more force. I'm afraid it won't last for many more years. Sadly those keyboards aren't produced anymore. TKL + trackpoint + real keys (not those flat scissor key abominations that range barely above a virtual keyboard on a phone for me) + German layout = zero keyboards available. The Tex Yoda and like keyboards are close, but also very expensive and not without compromises. I went to TKL + trackpoint after I had to use the mouse more intensely and developed pain in shoulders and hand with a full sized keyboard. The pain went away with the mouse closer to the keyboard and the trackpoint as an often used alternative. My index finger desperately seeks the trackpoint position whenever I have to use a diffrent keyboard. The finger finds the trackpoint on a Thinkpad laptop keyboard - but I can't feel enough of the flat keys, and chicklet is just horrible for me.

While I do like the TKL format, 60% might be more realistic when thinking about building my own or buying one that can be equipped with a trackpoint. However, I often need the cursor keys when writing text in the browser for a forum post like this one. Home and End may also get used under such circumstances. PgUp/PgDown and cursor keys are useful for reading.

My preferred editor is vim. Its keybindings are very comftable to me. I'm wondering if those might be used when having to switch to a 60% keyboard? Though that might actually be something I'd like to have right now. I'm wondering if anyone has tried that yet and has any experience?

I'm not talking about using Fn + <key> for one movement and then hitting Fn + <key> again for the next movement operation. I don't want those movement keys to be on a *layer* like those accessed by the modifier keys Crtl, Alt and Shift. I want a diffrent *mode* - like CapsLock or ScrollLock: Press i.e. CapsLock *once* to switch into edit mode - and afterwards h, j, k, l acts as curser until either CapsLock is pressed again or i is pressed for switching back to insert mode.

I'm sure this can be done with custom firmware. But can it be done with off-the-shelf programmable keyboards, like i.e. a Ducky One? The computer is also aware of the state of the CapsLock key to some degree. Perhaps it can be changed on the OS side (Linux) somehow? But keyboard-side would be more versatile and preferable.

Offline kajahtaa

  • Posts: 272
Re: VI-mode for keyboards?
« Reply #1 on: Tue, 24 November 2020, 00:00:38 »
qmk is beautiful

You can MO rather than toggle.

You have thumbs so use them.

Offline bkrownd

  • Posts: 284
Re: VI-mode for keyboards?
« Reply #2 on: Tue, 24 November 2020, 01:36:12 »
I'm kind of puzzled by the question since almost all of VI/vim is controlled through alphanumerical keys, plus escape and maybe control.  We must be using it differently?  e.g. I get into insertion mode with i/a/o and out of insertion mode with escape. 
« Last Edit: Tue, 24 November 2020, 01:42:41 by bkrownd »

Offline textmode

  • Thread Starter
  • Posts: 15
Re: VI-mode for keyboards?
« Reply #3 on: Tue, 24 November 2020, 03:57:39 »
Quote from: kajahtaa
You have thumbs so use them.
Holding down a modifier key with the thumb all the time when moving a cursor could soon become very tiring for the thumb. Granted, the sequence CapsLock, F1, i would be very inefficient if the only thing you want is to press F1. But then, if that key is needed often, it ought to be a dedicated key anyway. I often have to press multiple navigation keys to get to the place I want to change (or view), so pressing ESC in vi or CapsLock once, then navigate to the target location with hjkl, then entering insert mode with i/o etc. feels very comftable with vi, and I'm missing that where it's not available (i.e. outside of vi(m)). Typing errors just a few letters before the last character entered are easier to correct with backspace.

Quote from: bkrownd
I'm kind of puzzled by the question since almost all of VI/vim is controlled through alphanumerical keys, plus escape and maybe control.  We must be using it differently?  e.g. I get into insertion mode with i/a/o and out of insertion mode with escape.
I probably didn't use the right words there. The keybord would normally be in insert mode. Pressing CapsLock ought to turn it into vi-"normal" mode. Getting back to insert mode with a second press of CapsLock (as I first thought) would be problematic and not very vi-like; i/o ought to do that job (I usually don't use a). As the keyboard cannot be aware of the text, only a limited amount of cursor movement and editing could be supported. Cursor movement, Home (0), End ($) and Delete (x) ought to be easily possible. Space and b could emulate PgUp/PgDown, although that's not very vi-like but comes from scrolling in more/less.

The basic idea is to have to press a mode switch key (like CapsLock or NumLock on a normal keyboard) once and then beeing able to happily move around the cursor without having to hold down a modifier key all the time.

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: VI-mode for keyboards?
« Reply #4 on: Wed, 25 November 2020, 11:55:35 »
Yes this is possible, you can make it so tapping any chosen key toggles to a different layer then on that layer any key can toggle the layer back (or go to a third layer - numberpad perhaps?)
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline textmode

  • Thread Starter
  • Posts: 15
Re: VI-mode for keyboards?
« Reply #5 on: Wed, 25 November 2020, 22:25:37 »
Quote from: suicidal_orange
Yes this is possible, you can make it so tapping any chosen key toggles to a different layer then on that layer any key can toggle the layer back (or go to a third layer - numberpad perhaps?)
Thank you! That's very helpful and good to know. But is it a wide-spread feature of any (common?) factory-made programmable keyboard, or does it take special care when searching for a suitable one?

While browsing the forum, I found spiceBars thread regarding spaceFN. That sounded quite intresting, although the space bar is IMHO too often needed and probably not the best choice for me for an Fn key. Reading further on in the thread, I discovered abrasives software implementation for Linux. It works well with an usb keyboard plugged into my machine for testing. The implementation is also pretty straightforward and easy to adapt for other needs. Just making CapsLock switch to a diffrent layer and i back towards normal layer is a lot less complex than spaceFN, and I was able to adapt the code to my needs. It works mostly, though I forgot to catch the release of CapsLock when in the new layer, but that ought to be easy to fix.

This posting was written and edited using that experimental code, and it works pretty well. All I miss is the trackpoint (all keyboards ought to have one! :-)), and an implementation in hardware would be preferable in the long run.

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: VI-mode for keyboards?
« Reply #6 on: Thu, 26 November 2020, 00:17:57 »
I would hope it would be, that's the point of a 'fully programmable' keyboard though I know there are boards that just let you move keys on the base layer too.  Any board advertised as running QMK definitely will as that's the 'DIY' firmware of choice at the moment.

If you have it working in software that's a bonus as long as you don't need to take it with you :)
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod