Can UHK be a system wide (macos) VIM keyboard?

I am trying to use vim motion in every application which supports it. Unfortunately, besides from terminal and editors / IDEs there are not many.

On my UHK the only vim thing I binded are the hjkl arrows but I was wondering given the multiple layers, macros and key maps you can use
… how far can it go?

Basically you need just two layers INSERT and COMMAND
INSERT is just the normal Base layer and hitting ESC will switch to a the COMMAND layer (with the hjkl arrow keys)
In the COMMAND layer, pressing i will switch to the INSERT layer. (for now it’s just i)

Then you just need a ton of macros on the COMMAND layer like:

  • paste: pcommand+v
  • moving one word forward / backwards: w / boption+left / `option+right’
    and so on…

I am just not sure how you can bind multiple keys to one macro. Something like this:

  • copy word: yiw → (option+left + option+shift+right + command+c)

If this would be possible, there is a good way to get a vim like keyboard systemwide.

What do you guys think?

Multiple people already tried. My results: it is not working very well. Multiple reasons:

  • different OSes have slightly different semantics of what ctrl+arrows do, e.g., one moves cursor to the end of word, other OS to beginning of next word, etc…
  • UHK has no acces to actual buffer, so it has to guess whether (e.g.) something is selected, etc. Many vim features depend on actual content of the buffer, such as f, t, % commands
  • you can infer and remember a lot of state information via registers, but as a result you still get system which is prone to errors, glitches, unexpected behavior…
  • some software does not like quick scancode sequences which leads to weird glitches
  • again applications semantics of stuff like ctrl+f search vary in details, which makes it impossible to reliably hook /, f, … commands onto ctrl+f

thanks for the input, that’s what I was afraid of.

I was thinking of having just a COMMAND layer with some basic stuff like arrow keys and pasting, copying but copying seems already be tricky when I understand your reply correctly.

But is there a way to have f.e. yiw keystroke execute one macro? I did not see anything like this in the agent.

Yes! Search firmware/doc-dev/ at master · UltimateHackingKeyboard/firmware · GitHub and firmware/doc-dev/ at master · UltimateHackingKeyboard/firmware · GitHub for ifGesture.


The problem is that I can not get the keyID as described in the section:
An ifShortcut macro needs to be placed on the first key of the shortcut, and refers to other keys by Their hardware ids. These ids can be obtained by resolveNextKeyId command (i.e., activating the command and pressing the key while having a text editor

I creates a macro with the resolveNextKeyId and put it on a random key.But whenever I press it, the display on my UHK shows Err. and nothing is printed in the focused text editor.

My guess is that you need to enable extended commands.

Create a macro named $onInit with the following content:

set macroEngine.extendedCommands 1

Otherwise, see what the error is about with the printStatus command.

1 Like

perfect thanks!
That did the trick!