Vim Mode for the UHK

Hey all,

Recently got the UHK and have been tinkering with it.

I know with QMK you can replicate a vim mode by modifying the firmware code. See

Is there an equivalent for the UHK that has been done before?

Has anyone modified the firmware before for UHK? I had a look at the codebase and it looks scarier than QMK tbh haha.

As an aside, what are the main edits to these keyboards does everyone make that is worth while? Saw the top post on this forum is making keys become repeatable temporary macros which is pretty awesome, so wanting to learn how to set up this keyboard to its potential.

Interesting, I didn’t know that.

As to vim mode for UHK, there have been attempts to do that via macro engine. I have been one of those to attempt it. There are multiple problems with it:

  • Keyboard does not see the text buffer. Unfortunately, many vim features depend on the text buffer content (%,(,{,[,f,F,t,T,/,C-N, small vs long delete register, word or block copy-paste mode, anything that acts on selections). As a result, you have to do a lot of guesswork. You can infer or guess a lot of these information from last used commands, then save them into a variable and act on them, but you get a system that is prone to glitches, unexpected behaviors, etc. .
  • Different OSes / window toolkits use sliiightly different arrow semantics. Stuff like Ctrl+right moving to the end of the current word or the beginning of the next. This can seriously hinder any attempts to implement w,b,e commands…
  • A lot of software has surprising troubles with too fast input, which for instance makes it troublesome to write an adaptor between / (or even f,F,t,T) and Ctrl+f. (Also, the ctrl+f search form usually again does sliightly different things in different software, so it is just not viable.)
  • Obviously, it misses the power of extensions and of all the advanced vim commands. (Jumplist, marks, clist, jumping and cycling through references or definitions.)
  • At the end of the day, it works, but is pretty limitted and is not reliable.
  • (Btw., note that these limitations are exactly the same for what QMK can in theory do.)

Has anyone modified the firmware before for UHK? I had a look at the codebase and it looks scarier than QMK tbh haha.

Yes, there have been people, there have been PRs.

Indeed UHK is not configured via source code, so UHK firmware is probably written in a more generic way… and is not suited to directly add hooks for specific keys and specific functionality.

You are welcome to ask questions regarding the codebase. I am happy to provide answers.

As an aside, what are the main edits to these keyboards does everyone make that is worth while?

Sorry, I don’t understand this sentence :sweat_smile:.

so wanting to learn how to set up this keyboard to its potential.

Docs on advanced macro setups is here: firmware/doc-dev/user-guide.md at master · UltimateHackingKeyboard/firmware · GitHub and firmware/doc-dev/reference-manual.md at master · UltimateHackingKeyboard/firmware · GitHub .

Appreciate the response. Will definitely look into the macros.

Good point about the text buffer issue… Definitely makes it hard to implement. I assume you’ve given up on that quest? / don’t have a sharable config.

I guess having w, b, $, 0, y, d, c, x, would get you the basics for text editing on things like this chatbox (as in the component that we type in to create a message here on this forum). As that’s the main thing I am trying to solve, such as replying to Slack messages using vim keybindings. Not necessarily trying to replicate the whole of vim haha. (Would love to see an example of having “c”, “i”, or "a’ for vim, as my thought was to enable vim in an fn layer, but then we can’t really toggle back to the base layer from my understanding)

Do you have any examples of how you are using the macros currently? Just to see what we can build. I only have the record temporary macro’s setup currently, so haven’t tested the full capability.

My aside question was moreso wondering if there is a knowledgebase/forum sharing other’s configuration’s for inspiration.

don’t have a sharable config.

Here you go: firmware/examples/mirroring_keymap.json at master · kareltucek/firmware · GitHub

It is years old and uses some syntaxies that have been deprecated long since.

//Edit: it is actually from before the extended macro engine got merged into official firmware, and before command action was officially added. (When I originally forked the firmware, I used to use the hijacked write text action.)

but then we can’t really toggle back to the base layer from my understanding

macro-triggered layer toggling is much more powerful than the one available in key popover. (Laszlo insists on keeping things simple in GUI part of Agent…)

Do you have any examples of how you are using the macros currently?

Here is my up-to-date config: My configuration - mirroring setup, runtime macros, etc

My aside question was moreso wondering if there is a knowledgebase/forum sharing other’s configuration’s for inspiration.

The “My configuration” category of this forum is meant that way, but it has not taken off much…

2 Likes

I think it will over time. Been too busy with travelling and more, but I will comment on your config and post my current one as well. :slight_smile:

2 Likes