Vim Mode Layers (Mac) #1482
BreitbandModem
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What it is
I created a Kanata config that allows me to enter into a vim-like normal / visual mode by switching to a separate Kanata layer.
This approach is inspired by the Karabiner-Elements Vim Mode Plus mod.
These special Kanata layers are trying to emulate the vim behaviour by mapping the respective keys to a native macOS shortcut.
So switching to the vim normal layer, the
h j k l
keys are now remapped to the arrow keys,w
is mapped toA-rght
, and so on.(Any other keys are deactivated on these layers.)
Whenever I enter these vim layers, I also toggle capslock.
This doesn't affect any of the behaviour, but macOS will then show this little capslock icon next to the text pointer.
So that serves as a nice little visual cue to know that the vim layer is active.
How to use
You can find the config here.
I tried to make it reusable via the Kanata include feature:
Just add a trigger to your keymap that takes you to the vim normal layer:
(layer-switch vim-normal)
This is my alias which I put onto the
caps
key in my default Kanata layer:(Single press yields
esc
. Douple press toggles capslock and switches to the vim normal layer.)Mind that the vim layers are taylored for my QWERY layout with homerow mods.
So you might need to change the keymappings in the vim layers if you're using a different layout.
In particular I have some mappings to keep supporting my homerow mods in the vim layers:
Limitations
W
andB
which move to the next whitespace - but as far as I can tell there's no way to achive that with shortcuts)Personal note
I just wanna mention how cool I think the Kanata project is. I was able to bring my zmk kaymap from my mechanical keyboard pretty much 1:1 to the internal mac keyboard - and the best part is that the config file is super well maintainable.
Which is also the reason I switched from Karabiner to Kanata.
Also just compare how the original Karabiner vim mod is around 4.5k lines of [unreadable] json. Whereas the Kanata implementation of it is not even 200 lines.
Lastly I wanna mention that right now I'm actually not using this vim layer implementation.
I've found a paid app called kindaVim which goes a step further and uses the accessibility API to also support much more complex vim motions.
Beta Was this translation helpful? Give feedback.
All reactions