pqrs-org / Karabiner-Elements

Karabiner-Elements is a powerful utility for keyboard customization on macOS Sierra (10.12) or later.
https://pqrs.org/osx/karabiner/
The Unlicense
18.72k stars 836 forks source link

Simple Vi Mode? (s + hjkl = arrow keys) #553

Closed jessejanderson closed 6 years ago

jessejanderson commented 7 years ago

I had no idea how reliant I had become on this... anyone have a way to fix?

It was a simple feature that turned your hjkl keys into arrow keys when the s key was held down (otherwise s worked like normal).

I've tried adding hacks to BetterTouchTool and Keyboard Maestro but nothing seems to work without breaking my s key.

Anyone have any idea or a way to hack this into Karabiner Elements?

paxl13 commented 7 years ago

my pseudo solution while waiting on KE is to rebind tab to hyper & use hyper hjkl bound using hammerspoon... But yeah... I am also VERY VERY dependant on this. I used to use df + hjkl...

j0hnsmith commented 7 years ago

I didn't realise upgrading to Sierra would take this away, I really miss it.

frankrei commented 7 years ago

Yes, right now Karabiner + Hammerspoon / Keyboard Maestro seems to be the only game in town.. you use Karabiner to map a key to say "Command+Control+Option" and then HS or KM to map that combo + your preferred key to the cursor key.

juanmiret commented 7 years ago

I loved Vi mode, It's so painful to use the arrows, It's been months waiting for this feature

juanmiret commented 7 years ago

Guys!! Finally found a solution to bring back Simple Vi mode, just not with s + hjkl but with caps_lock + hjkl, while mantaining capslock functionality. Using KE + Hammerspoon, super easy you just can copy my config files for both and modify the bindings to your taste.

Just made a gist, take a look! https://gist.github.com/juanmiret/81a21a5ae8d6b6061b0a4e72a8be61b2

@jessejanderson @paxl13 @frankrei @j0hnsmith

accounthandler commented 7 years ago

@jessejanderson super reliant on it, too. Now it's really painful. @juanmiret I already mapped capslock to cmd. Any other possible solutions?

jesseleite commented 7 years ago

@juanmiret Was harder to setup, but followed the steps in that gist and it seems to work great. I can't wait until this vi mode comes back into karabiner-elements, but until then thank you! 👌

apm1467 commented 7 years ago

The Simple Vi Mode is implemented now. Check the official rules repository.

j0hnsmith commented 7 years ago

I find I have trouble typing s with the default modifier so I've created a config to use caps lock instead (you can still use the caps lock key as normal), here's the import link

karabiner://karabiner/assets/complex_modifications/import?url=https%3A%2F%2Fdl.dropboxusercontent.com%2Fs%2Fhtr8u6x80vp0e0r%2Fvi_mode_caps_lock.json
jesseleite commented 7 years ago

@j0hnsmith How do I download/import?

j0hnsmith commented 7 years ago

I edited a link tag on a webpage in my browser with devtools, eg turn something like

<a href="http://example.com">Link</a>

into

<a href="karabiner://karabiner/assets/complex_modifications/import?url=https%3A%2F%2Fdl.dropboxusercontent.com%2Fs%2Fhtr8u6x80vp0e0r%2Fvi_mode_caps_lock.json">Link</a>

Then click the link. I couldn't figure out a way to import via the app.

jesseleite commented 7 years ago

Thanks @j0hnsmith! Works awesome!

jesseleite commented 7 years ago

I just modified a version of @j0hnsmith's awesome complex modifications, to post escape when pressed alone, instead of caps.

If anyone is interested, you can import these custom modifications here.

j0hnsmith commented 7 years ago

@JesseLeite I'm not the original author, I just modified what I found here https://pqrs.org/osx/karabiner/complex_modifications/

jesseleite commented 7 years ago

Fair @j0hnsmith :) I love how customizable these complex modifications are! Hopefully we'll get better documentation for them soon.

MarcoSero commented 7 years ago

Thanks @JesseLeite. That's exactly what I was looking for.

LynnWalton commented 7 years ago

Anyone know any reason why modifying the official VI mode that seems to give choice of s or d as modifier wouldn't work if I tried to use space as modifier, similar to what @j0hnsmith did with using Caps lock key? I've delayed getting sierra and I haven't installed Karabiner Elements to test with. I can't live without a lot of the modifiers I have in Karabiner. I use space as a modifier for vi stuff, but also have my own shortcuts using "j" and "f" and "l" all as modifiers.

apm1467 commented 7 years ago

@LynnWalton the newer version of the official Vi Mode has some normalization rules. The space will be mapped to s/d + space if Vi Mode is activated.

{
    "type": "basic",
    "from": <%= from("spacebar", [], ["caps_lock"]) %>,
    "to": <%= to([["d"], ["spacebar"], ["vk_none"]]) %>,
    "conditions": [
        { "type": "variable_if", "name": "vi_mode", "value": 1 }
    ]
},

You can check the source code of the official Vi Mode here. There are documentations in it.

LynnWalton commented 7 years ago

Thanks @apm1467. I'm sorry to be a little slow, but I'm not clear what your post means.
when you say the space will be mapped to s/d when I activate do you mean just turning on this configuration or is s or d something you have to keep typing as a trigger to tell it you want to enter vi mode? I don't want the latter. I just want to get the mappings like space+j = Left Arrow, etc. Except I also want the ability to add when s key is added, so Space+s+j = selecting as I arrow left.

Is there a way to do that? I can post my private.xml somewhere if you want to see what I currently have. I would gladly give a donation or amazon gift card to someone who would help me rewrite my complete private xml but I believe once I get an example that matches how I do my spacebar modifications I could take it from there to right other ones I have which give me J+whatever and L+whatever.

My spacebar modifications which includes vi like keys is taken from the "My Touch Cursor" section of this: https://gist.github.com/jeebak/92dcbe61527683b92c84

Then the only thing I'd really be missing that is keeping me from going to sierra is this issue: https://github.com/tekezo/Karabiner-Elements/issues/307

I can provide my email and my private.xml to anyone who would be willing to help me for some gift card amount. I could figure things out if I had endless time, but alas, my life's situation currently does not afford me this time.

apm1467 commented 7 years ago

@LynnWalton Currently, Karabiner-Elements can not control the mouse cursor. If you want to use keyboard shortcuts to move the mouse cursor, you still have to wait.

If you just want to map space + H/J/K/L to keyboard arrow keys, you can modify the current Vi Mode to achieve this.

What I meant was, in this JSON file, if you change s to spacebar at line 10, you should also delete line 778 - 806, and change s to spacebar at line 761, 819, 848, 877 and so an until the last one at line 1979.

Using a non-modifier key (like a letter key or spacebar) to trigger a mode is actually more complicated than one might think. If you want to keep things simple, I suggest you to just map a modifier key (like control or command) + H/J/K/L to arrow keys, like in this JSON file.

LynnWalton commented 7 years ago

Thanks again @apm1467. That helps a lot. I'll try to give it a try on my husband's mac w/ sierra.

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

accounthandler commented 6 years ago

do we still have to use d+hjkl or the s+hjkl issue has been fixed?